Learning from Examples
Part of the Supervised Learning section of Coddy's Machine Learning journey. Lesson 1 of 58.
Time for real models. A model studies labelled rows, features plus a label, and learns to label new ones: supervised learning. Labelled seeds in, a map out:
A variety is a category, so this is classification: the model draws borders. A number label, like a melon's weight, is regression: the model learns a line.
Which kind? .nunique() counts a label's different values: a category repeats a few, a number rarely repeats.
seeds = pd.read_csv("seeds.csv")
print(seeds["variety"].nunique())This prints 3: a classification.
Challenge
EasyA shop for used e-scooters could predict any column of scooters.csv. Which would be classification, which regression? The program reads a column name into label.
- Count the column's different values.
- Print them as below, with the number of scooters.
- Print
A category: classificationfor at most 10 different values, otherwiseA number: regression.
For another shop and the column brand:
brand: 7 different values in 50 scooters
A category: classificationTry it yourself
import pandas as pd
scooters = pd.read_csv("scooters.csv")
label = input()
# Write your code below
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Supervised Learning
1Your First Model
Learning from ExamplesTrain and Test SetsFit and PredictScoring a ModelRecap: Seed Sorter2Nearest Neighbors
How k-NN DecidesChoosing kDecision BoundariesScaling for NeighborsRecap: Wine Neighbors5Measuring Classifiers
The Confusion MatrixPrecision and RecallThe F1 ScoreImbalanced ClassesROC CurvesRecap: Screening Test11Project: Penguin Species
Meet the PenguinsPrepare the DataChoose a ModelTune the WinnerShip the ModelPractice on your own: Online Python compiler