Setup and Your First Model
scikit-learn is Python's most widely used library for classical machine learning: classification, regression, clustering, and everything around evaluating and tuning those models. Unlike this course's quantum computing or game-development siblings, scikit-learn (along with numpy and pandas) actually runs directly in this course's browser sandbox, every lesson here is genuinely runnable, no local install required.
What "machine learning" actually means
A traditional program is a set of rules a human writes by hand: "if the email contains these words, mark it as spam." A machine learning model instead learns those rules from examples: show it thousands of emails already labeled spam/not-spam, and it figures out the patterns itself. scikit-learn's entire API is built around two verbs that capture this idea:
fit(X, y), learn patterns from labeled training data (X= inputs,y= correct answers).predict(X), apply what was learned to new, unseen inputs.
Your first model
load_iris()loads a small, classic dataset (bundled with scikit-learn, no download needed) of 150 flowers, each described by 4 measurements (.data) and labeled with one of 3 species (.target).train_test_split(...)splits the data into a chunk for training and a chunk held back for testing, covered in depth next lesson.DecisionTreeClassifier()creates an untrained model, a decision tree specifically, but every scikit-learn model shares this samefit/predictshape regardless of what's happening internally.model.fit(X_train, y_train)is where the actual learning happens, before this line,modelknows nothing about flowers.model.predict(X_test)asks the now-trained model to guess the species of flowers it has never seen, comparing its guesses to the real answers is exactly how you'll judge whether it learned anything useful.
NOTE
The first time any lesson in this course imports sklearn, numpy, or pandas, your browser downloads those packages (compiled to WebAssembly), which can take a little while, subsequent runs on the same page are instant. No pip install needed, this is genuinely different from the Kivy, Qiskit, and Cirq courses.