Menu

I built Logistic Regression, Decision Trees, Random Forests, and K-Means from scratch :.. here's what surprised me
📰

I built Logistic Regression, Decision Trees, Random Forests, and K-Means from scratch :.. here's what surprised me

DEV Community: github·Hariom Lohar·3 days ago
#ULBTSJEQ
#devtogithub#technology#devto#dev#sklearn
Reading 0:00
15s threshold

Available on github https://github.com/hariomlohardev/mini-sklearn

KMeans matched sklearn to the decimal while every classifier trailed.

What I built

minisklearn : five from-scratch models plus hand-rolled metrics, all

stdlib Python, trained on the Titanic dataset (889 rows, 7 features,

~38% survived). Same split throughout ( test_ratio=0.2, seed=0 ), all

scored with my own confusion-matrix metrics.

The surprise

All the other models that i tested against the sklearn library are performing a bit bad than sklearn implementation but the KMeans matched exectly each things no differance

I didn't expect that to happend

The numbers

Same split, same ruler — my models vs scikit-learn :

model mine (acc / P / R / F1) sklearn (acc / P / R / F1) gap verdict

LogisticRegression 0.684 / 0.714 / 0.294 / 0.417 0.847 / 0.806 / 0.794 / 0.800 0.164 investigate

DecisionTree 0.706 / 0.682 / 0.441 / 0.536 0.780 / 0.716 / 0.706 / 0.711 0.073 investigate

RandomForest 0.695 / 0.652 / 0.441 / 0.526 0.831 / 0.828 / 0.706…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.