Last updated

How Machine Learning Works

Definition: In supervised ML, each example has features (the inputs, called X) and a label (the answer, called y). The model studies many (X, y) pairs, learns the pattern, then predicts y for new X.

The standard workflow

  1. Collect data — gather examples
  2. Prepare — split into features (X) and labels (y)
  3. Train — the model learns from the data (model.fit)
  4. Predict — use it on new data (model.predict)
  5. Evaluate — check how accurate it is

Example — features and a label

Here the feature is "hours studied" and the label is "passed the exam" (1 = yes, 0 = no). Notice the pattern the model would learn — more hours, more likely to pass:

hours  = [1, 2, 3, 4, 5, 6]
passed = [0, 0, 0, 1, 1, 1]
for h, p in zip(hours, passed):
    print(h, "hours ->", "PASS" if p else "fail")

💡 Key terms: remember X = features (inputs) and y = label (answer). You will see them in every example from here on.

Try it Yourself
Output

          
Ad · responsive