I built Logistic Regression, Decision Trees, Random Forests, and K-Means from scratch :.. here's what surprised me
Описание и применение
Автор реализовал пять моделей машинного обучения с нуля и сравнил их с scikit-learn на наборе данных Titanic, обнаружив, что KMeans совпадает по инерции, а остальные модели уступают по точности и полноте.
Задача
Implementing common machine learning models from scratch and comparing their performance to scikit-learn on the Titanic dataset.
Результат
Custom classifiers lag behind scikit-learn in accuracy and recall, except KMeans which matches scikit-learn inertia exactly.
Рабочий процесс
- 1. Clone mini-sklearn repository
- 2. Load Titanic dataset (889 rows, 7 features)
- 3. Split data with test_ratio=0.2, seed=0
- 4. Train LogisticRegression, DecisionTree, RandomForest, and KMeans from scratch
- 5. Compute accuracy, precision, recall, F1 for classifiers; inertia for KMeans
- 6. Compare metrics to scikit-learn equivalents
- 7. Analyze gaps and identify reasons for underperformance
Доказательства
KMeans matched sklearn to the decimal while every classifier trailed.
Same split, same ruler — my models vs scikit-learn:
The pattern: my classifiers systematically under-predict "survived" (recall 0.29–0.44 vs sklearn's 0.71–0.79)
- Дата записи: 2026-10-24T09:11:45.970Z