The Gemika's Magical Guide to Sorting Hogwarts Students using the Decision Tree Algorithm (Part #2)
Tags: machinelearning, ai, python, harrypotter
Published: 2024-07-06 23:20:44

## 2. Preparing Your Wand: Setting Up Your Magical Tools 🪄

![Preparing Your Wand: Setting Up Your Magical Tools](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pyrwsbs03wp2ipfa5f3w.jpg)

_Ah_, young **wizards and witches**, before we can embark on our journey through the enchanted world of **data science**, we must first prepare our **wands** — or in this case, our computers. Just as a wand chooses the wizard, the right tools will choose the data scientist. For our journey into the enchanted realm of data science, we shall need the right incantations and artifacts—beginning with the installation of Python, the most essential of all. 

Just as a wizard requires a wand, a data scientist requires Python to cast their spells. Let’s gather around the cauldron and brew a potion of installations, setting up [Python](https://www.python.org/) and [Jupyter Notebook](https://jupyter.org/), which will be our magical companions in this adventure. 🪄✨

## 2.1 **Installing Python**

As we gather in the dimly lit classroom of Professor McGonagall's Transfiguration, our wands at the ready, we must first ensure that our magical tools are properly prepared. For our journey into the enchanted realm of data science, we shall need the right incantations and artifacts—beginning with the installation of Python, the most essential of all. Just as a wizard requires a wand, a data scientist requires Python to cast their spells.

### 2.1.1 **Windows Operating System**

To summon Python on a Windows machine, visit the Python website and download the installer. Once downloaded, run the installer and be sure to check the box that says `"Add Python to PATH"` before you proceed. This ensures that the Python magic is accessible from anywhere on your system.

- Visit the [Python website](https://www.python.org/downloads/windows/).
- Download the latest version of Python.
- Run the installer and make sure to check the box that says `"Add Python 
to PATH"` before clicking "Install Now".

### 2.1.2 **macOS Operating System**

For those with the heart of a lion and the spirit of a **Gryffindor**, macOS users can summon Python using Homebrew, a magical package manager. Open your Terminal and cast the following spells:

- Open the Terminal, if you don't know what a Terminal is or where to locate them, click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal. In the Finder , open the `/Applications/Utilities` folder, then double-click Terminal.
- Use [Homebrew](https://brew.sh/) (a package manager for macOS). If you don't have Homebrew, install it first by running:   

```sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
- Once Homebrew is installed, run:

```sh
brew install python
```

### 2.1.3 **Linux Operating System**

The wizards and witches of the Linux world can summon Python using their distribution's package manager. For Debian-based systems, use apt-get

- Open the Terminal, using the shortcut key: The most common way to open the terminal is by pressing the `"Ctrl + Alt + T"` keys simultaneously. From the applications menu, some Linux distributions have a terminal icon in the applications menu that you can click to open.
- Run the following command to install Python:
   
```sh
sudo apt-get update
sudo apt-get install python3
```

With Python installed, our wands are now primed and ready for the next enchantment. ✨

---

## 2.2 Installing Libraries with Pip

Once Python is installed, we need to equip ourselves with the essential libraries. These libraries are like potion ingredients, each adding its own special property to our spells. We shall use pip, Python's package installer, to fetch these magical ingredients. To cast our data science spells, we need a few key libraries: `pandas`, `numpy`, `matplotlib`, and `seaborn`. Think of these as the potions and ingredients essential for our magical experiments from our Terminal.

```
# Install Pandas for data manipulation
pip install pandas
```

```
# Install NumPy for numerical operations
pip install numpy
```

```
# Install Matplotlib and Seaborn for data visualization
pip install matplotlib seaborn
```

```
# Install Scikit-Learn for machine learning algorithms
pip install scikit-learn
```

Here's the spell (script) to cast in your terminal:

```python
# Importing essential libraries (if needed)
import os

# Install necessary libraries
os.system('pip install pandas numpy matplotlib seaborn')
```

---

## 2.3 Installing Jupyter Notebook

_Ah_, Jupyter Notebook! Our magical parchment where we’ll inscribe our spells (code) and see the results unfold before our eyes. Jupyter Notebook is our enchanted scroll, a place where we can write, run, and visualize our code. It is where our spells come to life. To install Jupyter Notebook, is as simple as waving your wand, cast the following incantation in your command line :

```sh
pip install jupyter
```

To launch Jupyter Notebook, simply use:

```sh
jupyter notebook
```

This will open a portal (web browser) to the realm where our magical scripts will come to life. Here's a preview once you've managed to download and properly installed them. 🌟

![Gemika Haziq Nugroho's Pop-Up Quiz: Preparing Your Wand](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fgj9wapb1sam6yrkdd7v.png)

---

## 2.4 Gemika's Pop-Up Quiz: Preparing Your Wand 🧙‍♂️✨

And now, a little challenge from young Gemika! Can you answer these questions to prove your readiness?

1. What command do you use to install Python on macOS?
2. How do you launch Jupyter Notebook after installation?
3. Name the four essential libraries we installed with pip.

Think carefully, and may your answers be as sharp as the fangs of a Hungarian Horntail! 🐉 Thus, with our wands (tools) at the ready, we are now prepared to delve deeper into the magical world of data science. Remember, the magic lies not just in the tools, but in how we wield them. 

Together, we'll uncover secrets and make predictions that even the greatest seers would envy. Now, with our wands (or rather, our Python installations) at the ready, we are prepared to dive deeper into the magical world of data science. May your journey be filled with wonder and discovery! 🧙‍♂️✨ Onward, to our next adventure! 🧙‍♂️✨