Before Step 0

Get your laptop ready

You do not need to know how to code. You need a laptop, about an hour, and the willingness to type things you do not understand yet.

About 1 hour 20 minutes8 partsDo this once
Read this bit

What is about to happen

By the end of this page you will have typed a line, pressed two keys, and watched your laptop work out an answer. That is all a program is.

Right now your laptop cannot do that. It can browse and it can play video, but nobody has put the tools on it. This page puts the tools on it.

Why this page is long

Installing things is the part where most people quit. Not because it is hard, but because something goes wrong and nobody says what it means.

So every step here tells you what you should see. If you see that, carry on. If you see something else, there is a box underneath telling you what it means and what to do. You will not need to ask anybody.

What is wrong with this page

Every other page in this course promises you exact numbers, because the course controls the data. This page cannot. Your laptop is yours, and I have never seen it.

So when this page says you should see something, take it as close enough rather than exact. If a version number here says 3.12 and yours says 3.13, you are fine.

Part 1Words5 min

Ten words you are about to meet

You will see these words everywhere from now on. Read them once. You do not have to remember them. You will meet each one again when it matters.

Program
A list of instructions your laptop follows, in order, from the top.
Python
The language you write those instructions in. It is the one most people doing this work use.
Library
Work somebody else already did, that you are allowed to use. You install it once and then it is there.
Pandas
The library for tables. It opens a table, counts it, and does sums on it. You will use it in every step.
Scikit-learn
The library of models. You install it under that name and then type sklearn to use it. Two names, one thing, and nobody warns you.
Terminal
A window where you type commands instead of clicking. You will use it a handful of times on this page and then rarely again.
Notebook
A page you can write in and run code in at the same time. Yours will be called band-00.ipynb.
Cell
One box inside a notebook. You put code in it and run it. A notebook is a stack of cells.
Output
What appears underneath a cell after you run it. Plenty of cells do their work and show nothing, so no output is not the same as nothing happening.
Kernel
The part of JupyterLab that actually runs your code, and remembers everything you have run so far. Restarting it makes it forget, so after a restart you run your cells again from the top.
Do not memorise these

Nobody learned these words by reading them. You will learn them by using them in the next hour. Come back to this list when a word stops making sense.

Part 2Identify2 min

Which laptop do you have?

The next part is different depending on your laptop. Work out which one you have, then read only your part.

Write down which one you have. Every later step will say which laptop it is for.

Part 3Run20 min

Put Python on your laptop

Python is free. It comes from one place. Do not download it from anywhere else.

If you have Windows

  1. Go to python.org in your browser. Click Downloads. There is a big yellow button with a version number on it. Click it.

    You should see

    A file downloading, with a name that starts python-3 and ends .exe.

  2. Open the file you just downloaded. A window appears with two buttons and some tick boxes at the bottom.

    Before you click anything, look at the tick boxes at the bottom. One of them mentions PATH. Tick it.

    This is the single most skipped step in all of programming. If you skip it, Python installs fine and then your laptop cannot find it, and the error you get later says nothing about this box.

    You should see

    The PATH box with a tick in it. Then click Install Now and wait.

  3. When it finishes, close the window.

If you have a Mac

  1. Go to python.org in your browser. Click Downloads. There is a big yellow button with a version number on it. Click it.

    You should see

    A file downloading, with a name that starts python-3 and ends .pkg.

  2. Open the file. Click Continue until it installs. There is no box to tick on a Mac.

  3. Your Mac already had a Python on it before you started. That is normal and it is old. The one you just installed sits alongside it. On a Mac you always type python3, with the 3, so you get the new one.

If you have Linux

You almost certainly have Python already. Skip to Part 4 and check. If the check fails, install it with your package manager.

Part 4Run10 min

Open a terminal and prove Python is there

You installed something. Now you find out whether it worked. Do not skip this. Finding out now takes two minutes. Finding out in Step 0 costs you an evening.

Open the terminal

This window is waiting for you to type a command. It will do nothing until you press Enter.

Ask Python what version it is

Type this and press Enter. On a Mac and on Linux, use python3. On Windows, use python.

python3 --version
You should see

A line starting Python 3. and then some more numbers. Anything from 3.11 upwards is fine.

That is Python telling you it is installed and awake. You have just run your first command.

If Windows says 'python' is not recognized

This is the PATH box from Part 3. It was not ticked.

You do not have to understand PATH. You have to install Python again.

Run the installer file again and choose Uninstall. Then run it a second time for a fresh install. On the very first screen, before you click anything, tick the box at the bottom. Depending on your version it says Add python.exe to PATH or Add Python to environment variables. Both are the same box.

Then close the terminal, open a new one, and try again.

A new terminal matters. An open one does not notice the change.

If Windows opens the Microsoft Store instead

Windows does this when it cannot find a real Python. It is the same problem as above. Do not install from the Store. Fix the PATH box instead.

If a Mac says command not found, or Python 2 something

Most likely you typed python without the 3. On a Mac it is always python3. Try again with the 3 on the end.

If python3 itself brings up a box offering to install developer tools, let it. That is your Mac fetching the pieces it needs, and it only happens once.

If it prints Python 3.10 or lower

Your laptop found an older Python that was already there. The course needs 3.11 or above, because the newest pandas will not install below it. Install from python.org as in Part 3, then close this terminal and open a new one.

Part 5Run10 min

Install the three things you need

Python on its own cannot open a table. You need three libraries. Pandas handles tables. JupyterLab gives you the notebooks you work in. Scikit-learn holds the models, which you meet in Step 2.

You install libraries with a tool called pip. It comes with the Python you installed from python.org in Part 3. Type this one line and press Enter.

python3 -m pip install pandas jupyterlab scikit-learn

On Windows, use python instead of python3.

Lots of text will scroll past. That is normal. It is downloading. Wait until the typing prompt comes back.

You should see

Near the end, a line starting Successfully installed followed by a long list of names, with pandas, jupyterlab and scikit-learn among them.

Then the prompt comes back and waits for you again.

If Linux says No module named pip

Some Linux versions ship Python without it. Install it with your package manager, the same way you installed Python: on Ubuntu or Debian that is sudo apt install python3-pip, and on Fedora sudo dnf install python3-pip. Then run the line above again.

If it says Requirement already satisfied

Good. It was already there. Carry on.

If it prints a yellow warning about upgrading pip

Ignore it. A warning is not an error. The difference matters, and you will meet it again: a warning is your laptop mentioning something. An error is your laptop refusing.

If it says externally-managed-environment

Some Linux and Mac systems protect their own Python from being changed. Read to the end of that message: it names the way out, and the way out is a longer command.

python3 -m pip install --break-system-packages pandas jupyterlab scikit-learn

The name sounds alarming and is not. It means "yes, I know, do it anyway". These three libraries do not break anything.

Adding --user instead does not get past this. It is the first thing everybody tries and it fails with the same message.

If it fails with a wall of red text

Read the last three lines, not the first thirty. The answer is almost always in the last three.

If those lines mention a network or a proxy, you are behind a connection that blocks it. Try a different network.

Part 6Run10 min

Get the course folder

The course is a folder of files. It has the pages, the notebooks and the data in it.

  1. Open your browser and go to the course page:

    https://github.com/ehoneahobed/ml-course

    That is GitHub, a website where people keep folders of files so other people can copy them. Near the top of the file list there is a green button that says Code. Click it, then click Download ZIP.

  2. Find the file you downloaded and unzip it. On Windows, right click and choose Extract All. On a Mac, double click it.

  3. Move the unzipped folder somewhere you will find it again. Your Documents folder is fine. Do not leave it in Downloads, because you will delete it by accident.

    You should see

    A folder holding one .ipynb file per step that has been built so far, starting with band-00.ipynb, plus folders called data, bands and tools. More notebooks appear as more steps are written, so do not worry about the exact count.

  4. Now tell your terminal to go and stand in that folder. Type cd, then a space, then drag the folder from your file browser onto the terminal window and let go. The path appears. Press Enter.

    The letters cd mean change directory. Directory is an old word for folder.

    You should see

    The prompt changes to show the folder name. Then type dir on Windows, or ls on a Mac or Linux, and press Enter.

    You should see band-00.ipynb in the list. If you do not, your terminal is standing somewhere else.

This is the step everything else rests on

The notebooks look for the data at data/bank.csv. That only works if your terminal is standing in the course folder when you start.

If you get a FileNotFoundError later, this is why, and coming back here fixes it.

Part 7Run10 min

Run your first cell

From the same terminal, in the same folder, type this and press Enter.

jupyter lab
You should see

Text scrolling in the terminal, and then your browser opens on its own with a page called JupyterLab. Down the left is a list of the files in your course folder.

Leave the terminal window open. Closing it stops JupyterLab. It looks like a website but it is running on your own laptop.

If it says jupyter is not recognized or command not found

Part 5 did not finish, or it installed somewhere your laptop does not look. Try this instead, which asks Python to run it directly.

python3 -m jupyter lab

If the browser does not open on its own

Look in the terminal for a line starting http://localhost:8888. Copy that whole line, including the long code after token=, and paste it into your browser.

  1. In the file list on the left, double click band-00.ipynb. It opens as a notebook. You will see boxes. Those are cells.

  2. Look at the boxes. There are two kinds and you need to tell them apart.

    • Code cells are grey, and have [ ]: written just to their left.
    • Text cells look like ordinary writing, with no brackets beside them. The first cell in the notebook is one of these.

    Click on the first code cell, the first grey one with brackets. A blue bar appears down its left side. That means it is the one that will run.

  3. Hold Shift and press Enter.

    You should see

    Text appear underneath the cell, and the blue bar move down to the next one.

    The first cell prints your Python version and your pandas version. Two lines. That is your output.

    If nothing appears and the cell shows [*]

    It is still working. The star means running. Wait. The star becomes a number when it is done.

    If it stays a star for more than a minute on the first cell, go to the top menu, choose Kernel, then Restart Kernel, and run it again.

How to write in a notebook

The steps keep telling you to write things down in your notebook. Here is how, because it is not obvious.

Scroll down to a text cell that says My prediction. Double click on it. It turns into an editable box, and the neat writing turns into plain text with some symbols in it. Type your answer at the end.

Then hold Shift and press Enter, the same as running a cell. It turns back into neat writing with your answer in it.

You should see

Your own words sitting in the notebook, in the same style as the rest of the writing.

Do that now, once, on any text cell, so you know you can. Every step asks for it repeatedly.

Paper works too, and for the pen and paper parts it is better. When a step says notebook, either is fine. What is not fine is answering in your head.

What you just did

You wrote nothing. You pressed two keys, and your laptop read some instructions somebody else wrote, followed them in order, and told you the answer.

That is the whole job. Everything after this is about which instructions, and whether the answer means anything.

Part 8Modify10 min

Break it on purpose

You will see errors constantly. Everybody does, forever. The difference between somebody who can do this and somebody who cannot is not how many errors they get. It is whether they read them.

So make one now, while nothing is at stake.

  1. Go to the empty cell at the very bottom of the notebook. Click in it and type this, exactly, with the spelling mistake.

    prnt("hello")

    Then hold Shift and press Enter.

    You should see

    Red text. The last line says NameError: name 'prnt' is not defined.

    If you ever run the same thing in a terminal rather than a notebook, Python adds a helpful guess on the end: Did you mean: 'print'?. Same error, one extra sentence.

  2. Read that last line slowly. It is not shouting at you. It is telling you exactly what happened: it looked for something called prnt and there is no such thing.

    Now fix the spelling and run it again.

    You should see

    hello, in plain black text, underneath the cell.

  3. Now make a different mistake. Type this and run it.

    print("hello"
    You should see

    Red text again, and this time it says SyntaxError. A different error, because a different thing went wrong. You left a bracket open.

How to read an error, for the rest of your life
  1. Go to the last line. The first thirty lines are your laptop showing its working. The last line is the answer.
  2. The word before the colon is the kind of problem. NameError means it could not find something. SyntaxError means you typed something it could not read.
  3. The bit after the colon names the thing. If it puts a word in quotes, that word is where to look.

You now know more about errors than most people who have been coding for a month.

Before you move on

All five, or you will lose an evening in Step 0.

  1. python3 --version prints 3.11 or higher.
  2. jupyter lab opens in your browser.
  3. The first cell of band-00.ipynb runs and prints two lines.
  4. You have made an error on purpose, read the last line, and fixed it.
  5. In a notebook cell, import pandas, sklearn runs and prints nothing at all. Nothing is the right answer here: it means both libraries are there. A red ModuleNotFoundError means Part 5 did not finish.

Point four is not padding. Step 0 hides a cell that misbehaves without complaining at all, and you are meant to find it. Knowing what a real error looks like is how you notice that this one is missing.