haotianblog
Machine Learning From Scratch

Machine Learning From Scratch

Machine Learning From Scratch

This hub is for readers who want to understand a machine learning workflow before relying on a large framework or a copied notebook. The route connects small datasets, C/Python implementations, feature processing, training loops, and evaluation metrics. It uses familiar material such as Iris and K-means because those examples are small enough to inspect completely: the input rows, distance calculations, cluster assignment, center update, SSE, and final interpretation can all be checked by hand or with short scripts.

The site treats “from scratch” as an explanation standard, not as a claim that libraries are bad. A useful implementation should show the assumptions that libraries normally hide: how data is represented, what preprocessing changes, how parameters move, which metric is being optimized, and how a result can be misleading when the data split or initialization is weak.

Recommended Reading Path

Start with the machine learning workflow article if you need the whole pipeline: task definition, dataset inspection, feature processing, model fitting, validation, and error analysis. Then read the K-means and Iris material to see how an unsupervised algorithm updates internal state without labels. The feature engineering and model evaluation notes help connect the toy examples to practical mistakes, such as data leakage, overfitting, underfitting, and choosing a metric that does not match the real question.

While reading, keep a small notebook of the inputs and outputs at each stage. For K-means, track the centroids and SSE after each iteration. For supervised examples, track train/test separation, target labels, confusion patterns, and the baseline that the model must beat. This habit makes the article more than a recipe: it turns the example into a reproducible experiment.

Review Criteria

A page in this route should make the model behavior inspectable. It should tell the reader what the data looks like, what transformation is applied, what parameter or state is updated, what metric is reported, and what limitation remains. If a result is good, the page should explain why it is believable; if a result is weak, the page should show what evidence points to the weakness. That is the difference between a durable learning article and a pasted demo.

From Toy Data to Evaluation Discipline

Small datasets are useful because they make the mechanics visible, but they can also make a weak workflow look stronger than it is. This route asks the reader to separate algorithm behavior from evaluation behavior. K-means can show clear centroid movement while still choosing a poor cluster count. A classifier can show high accuracy while still leaking data or ignoring a minority class. The article should make those distinctions explicit.

When a result is reported, the surrounding explanation should identify the baseline, split strategy, metric, and failure pattern. For supervised work, that means checking train/test separation, class distribution, confusion patterns, and whether the chosen metric matches the task. For unsupervised work, it means checking initialization, scaling, stability, and whether the cluster interpretation is justified by the data rather than only by a nice chart.

What to Record While Reproducing

A reader should record the input file, feature columns, preprocessing steps, random seed, parameter values, command, output files, and any warning messages. Those details make it possible to compare a local run with the article instead of guessing why results differ. They also turn a simple example into an audit trail that can be improved later.

This is especially important when translating a C implementation into Python or a Python notebook into a library-based workflow. The same algorithm name does not guarantee the same initialization, stopping rule, numeric precision, or metric calculation. The page should help the reader notice those differences and treat them as part of the learning process.

Experiment Audit Checklist

Step Common risk What to inspect during reproduction
Data loading Column order, missing values, label encoding, or type conversion is ignored. Sample count, feature columns, label column, missing values, and parse errors.
Preprocessing Scaling or encoding leaks across the train/test boundary. Fit/transform boundary, random seed, category mapping, and scaling parameters.
Training loop Stopping rule, learning rate, or initialization creates a misleading result. Iteration count, loss movement, parameter update size, and unusual samples.
Evaluation report Accuracy is reported while imbalance or error type is ignored. Baseline, confusion matrix, error cases, metric definition, and scope limit.

Topic hub

Machine Learning From Scratch Tutorials

A project-based hub for K-means, the Iris dataset, K-means++, SSE, feature engineering, model training, and evaluation.

Covers long-tail searches around K-means in C, Iris clustering tutorials, machine learning workflow, feature engineering, and evaluation.

Editorial notes

Why these articles belong in one route

This hub turns machine learning from an abstract definition into a complete experiment: define the task and table, process features, train a baseline, read evaluation metrics, then inspect K-means iteration in C.

The K-means article does not only show final centroids. It explains how standardization, K-means++ initialization, repeated restarts, and SSE selection change the outcome, so readers understand why the result moves.

The route keeps both the Python workflow and the lower-level C implementation, which makes it easier to review engineering pipeline choices, numerical details, and visualization output together.

What you will build

You will follow a reproducible ML workflow: inspect data, process features, train models, evaluate output, and study K-means from scratch.

  • K-means from scratch in C
  • Iris clustering tutorial
  • K-means++ initialization
  • machine learning workflow tutorial

Recommended reading order

Start with concepts, then move into runnable projects

Machine Learning Workflow

Follow the practical path from data and features to training, prediction, and evaluation.

Level: Beginner Reading time: 9 min
  • Machine Learning
  • Features
  • scikit-learn

Model Training and Evaluation

Understand loss, overfitting, train/test splits, accuracy, recall, and F1.

Level: Beginner Reading time: 9 min
  • Model Training
  • Metrics
  • Evaluation

Python AI Mini Practice

Run a small scikit-learn classification task and read the experiment output.

Level: Practice Reading time: 10 min
  • Python
  • scikit-learn
  • Classification

K-means clustering on the Iris dataset in C

Study standardization, K-means++ initialization, restart selection, SSE, and the final clustering result.

Level: Beginner Reading time: 10 min
  • C
  • Python
  • Backtracking
  • K-means

Resources and distribution assets

Code, data, diagrams, and share assets in one place

FAQ

Direct answers to common search questions

Should I study K-means or the ML workflow first?

If you are starting out, read the ML workflow first. If you already understand training and evaluation, jump into K-means in C.

Are the dataset and source code downloadable?

Yes. The resources include Iris.csv, C source, flowchart, visualization SVG, and a zip bundle.

Scroll down