2️⃣

1.2 Libraries: Pandas, Numpy, ScikitLearn and Matplotlib

 

Introduction

Machine Learning is a very unique field, and it involves a lot of math. Thankfully, we don’t always have to deal with these details directly. In this course, we will be using Pandas, NumPy and SciKitLearn, professional libraries that will take care of a lot of the mathematics for us. MatPlotLib will take care of some of the simpler visualizations we'll be doing in this course. To use these, however, we need to import these libraries first.

Pandas

import pandas as pd
The above is the syntax for importing pandas. That’s the code in the first cell. Click the cell, and run it. There should be no active output, but now you have access to the pandas library. We’ll get to what it does in a minute. Meanwhile, this is a good place to explain what the import syntax means. The first two words should be fairly obvious, we’re just importing pandas. However, we’ll be calling pandas functions a lot, and typing out pandas every time will be really tiresome. So instead, we import pandas with a nickname, so to speak. For convention, we’ll be using pd, but you could really use anything.

Numpy

import numpy as np
NumPy is a math library, but even though we’re going to be doing a lot of math, we’ll use NumPy somewhat rarely. np is our standard “nickname” for NumPy.

Matplotlib

import matplotlib.pyplot as plt
Matplotlib is our graphing library, and we’ll be using this to visualize our problems and results. We won't go very far into detail about this library in this course, but we’ll do more in the next course on Classification. At any rate, MatPlotLib is still a really important library, and you should know how to use it.

ScikitLearn

Scikit-Learn is our Machine Learning library, and contains the actual algorithms that perform the ML. We’re going to be importing it a lot, but not as a full package, the way we imported Pandas or NumPy. SciKitLearn contains an incredible number of functions and functionalities, so we’ll be importing the individual components instead of the entire thing.
 

Previous Section

Next Section

 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.