Beginner level · Module 1: Machine Learning Foundations · Lesson 3 of 3
Notebooks, pandas and scikit-learn
Set up the tools, load a data set with pandas and train a first model with scikit-learn's fit and predict.
In this lesson you will
- Use a Jupyter or Colab notebook
- Load data with pandas and train a model with fit and predict
Key concepts
notebookDataFrameestimatorfit and predict
The lesson
Notebooks mix code, results and notes, which suits exploring data. Google Colab runs in a browser with nothing to install; Jupyter runs locally through Anaconda or pip and works offline.
pandas loads tables into DataFrames: df = pd.read_csv("plots.csv"); df.head() shows the first rows and df.describe() summarises the numbers.
scikit-learn gives every model the same interface: create an estimator, call model.fit(X, y) with features X and labels y, then model.predict(X_new). Learning this pattern once lets you try many algorithms with almost no code changes.
Step by step
- Open a notebook in Colab or Jupyter.
- Load a small CSV with pandas and inspect it.
- Split it into features X and label y.
- Fit a simple model and make a prediction.
Practice activity
Load the provided crop-plot data set, train a demonstration model and predict the best crop for two new plots.
Expected result: The notebook runs top to bottom and prints predictions for the two plots.
Check your understanding
-
Which two methods does every scikit-learn model provide?
Show answer
fit and predict.
-
What does df.describe() show?
Show answer
Summary statistics for the numeric columns.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.