DEV Community

Cover image for The Gemika's Magical Guide to Sorting Hogwarts Students using the Decision Tree Algorithm (Part #2)
gerry leo nugroho
gerry leo nugroho

Posted on • Updated on

The Gemika's Magical Guide to Sorting Hogwarts Students using the Decision Tree Algorithm (Part #2)

2. Preparing Your Wand: Setting Up Your Magical Tools ๐Ÿช„

Preparing Your Wand: Setting Up Your Magical Tools

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 and Jupyter Notebook, which will be our magical companions in this adventure. ๐Ÿช„โœจ


2.1 Installing Python ๐Ÿ๐Ÿง™โ€โ™‚๏ธ

Imagine a grand, ancient library, its shelves brimming with enchanted tomes of knowledge. This is where we, young wizards and witches, must venture to acquire our most potent tool: Python. Just as a wand chooses a wizard, Python will become our faithful companion in the magical realm of data science. ๐Ÿช„๐Ÿ

Python is no ordinary language; it's a spellbook of extraordinary power, capable of conjuring intricate patterns from raw data. With Python, we can transfigure numbers into meaningful insights, just as Professor McGonagall transforms animals into objects. It is the cornerstone of our magical education, the foundation upon which we shall build our data sorcery. ๐Ÿง™โ€โ™‚๏ธ

To summon Python onto your computer, you must embark on a digital quest. Seek out the Python website, a mystical portal to this wondrous language. Download the installer, a magical elixir that will infuse your computer with Python's essence. Once downloaded, run the installer, and with a final, decisive click, you will have summoned Python to your aid. ๐Ÿฐ

With Python at your side, you are ready to embark on a thrilling adventure through the enchanted forest of data. Let your imagination soar, for the possibilities are as boundless as the starry sky. ๐ŸŒŒโœจ

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.
  • 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 Mac OS 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 (a package manager for macOS). If you don't have Homebrew, install it first by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode
  • Once Homebrew is installed, run:
brew install python
Enter fullscreen mode Exit fullscreen mode
  • And to verify your installation, run the following :
which python
Enter fullscreen mode Exit fullscreen mode

And

python version
Enter fullscreen mode Exit fullscreen mode

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:
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install python3
Enter fullscreen mode Exit fullscreen mode
  • And to verify your installation, run the following :
which python
Enter fullscreen mode Exit fullscreen mode
python version
Enter fullscreen mode Exit fullscreen mode

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


2.2 Installing Libraries with Pip โœจ๐Ÿงช

Just as a skilled potioneer requires specific ingredients to brew a powerful elixir, a data wizard needs essential tools to conjure meaningful insights from raw data. These tools come in the form of Python libraries, magical artifacts brimming with spells and enchantments. ๐Ÿช„

To acquire these invaluable resources, we turn to pip, a magical incantation that summons libraries from the vast digital realm. Think of pip as a wise old owl, delivering packages of knowledge straight to our wizarding workstation. ๐Ÿฆ‰

Among the libraries we seek are four particularly potent elixirs: pandas, numpy, matplotlib, and seaborn. Pandas, a versatile potion, grants us the power to organize and manipulate data with unparalleled precision. It transforms raw information into structured tables, ready for further enchantment. ๐Ÿ“Š

Numpy, another essential ingredient, bestows upon us the ability to perform complex mathematical operations with astonishing speed. Numbers dance and swirl at our command, forming the foundation for our data-driven spells. ๐Ÿงฎ

Matplotlib and seaborn, our visualization masters, allow us to transform cold, hard data into captivating visual stories. With a flick of our coding wand, we can conjure mesmerizing charts and graphs that reveal hidden patterns and trends. ๐Ÿ–ผ๏ธ๐ŸŽจ

Armed with these magical libraries, we are ready to embark on our data-driven adventure. Let the enchantment begin! โœจ๐Ÿงชโœจ

# Install Pandas for data manipulation
pip install pandas
Enter fullscreen mode Exit fullscreen mode
# Install NumPy for numerical operations
pip install numpy
Enter fullscreen mode Exit fullscreen mode
# Install Matplotlib and Seaborn for data visualization
pip install matplotlib seaborn
Enter fullscreen mode Exit fullscreen mode
# Install Scikit-Learn for machine learning algorithms
pip install scikit-learn
Enter fullscreen mode Exit fullscreen mode

2.3 Installing Jupyter Notebook ๐Ÿ“œโœจ

Imagine a magical parchment, not made of sheepskin, but of shimmering code and endless possibilities. This is Jupyter Notebook, our wizarding tool for crafting spells (code) and observing their enchanting effects. It's like a blank canvas where we can paint with numbers, conjure graphs, and weave tales of data. ๐ŸŽจโœจ

Jupyter Notebook is a place where magic happens. It's where we can experiment, learn, and share our discoveries. Think of it as your very own Hogwarts library, filled with endless knowledge just waiting to be explored. ๐Ÿ“š๐Ÿง™โ€โ™€๏ธ

To summon Jupyter Notebook, we need to cast a special incantation. Open your trusty command line (your magical wand) and utter these words:

pip install jupyterlab
Enter fullscreen mode Exit fullscreen mode

To launch Jupyter Notebook, simply use:

jupyter lab
Enter fullscreen mode Exit fullscreen mode

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


2.4 Gemika's Pop-Up Quiz: Preparing Your Wand ๐Ÿง™โ€โ™‚๏ธโœจ

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! ๐Ÿง™โ€โ™‚๏ธโœจ

Top comments (0)