Logistic Regression in Python – Setting Up a Project
Logistic Regression in Python – Setting Up a Project
In this chapter, we’ll take a detailed look at the process of setting up a project in Python to perform logistic regression.
Installing Jupyter
We will be using Jupyter, one of the most widely used platforms for machine learning. If you don’t have Jupyter installed on your machine, download it from here. For installation, you can follow the instructions on their website. As the website suggests, you may prefer to use the Anaconda Distribution, which comes with Python and many common Python packages for scientific computing and data science. This will alleviate the need to install these packages separately.
After successfully installing Jupyter, start a new project. At this stage, your screen will look something like the one below, ready to accept your code.
Now, change the name of the project from Untitled1 to “Logistic Regression” by clicking on the title and editing it.
First, we’ll import a few Python packages that we’ll need in our code.
Importing Python Packages
To do this, enter or cut and paste the following code into your code editor −
In [1]: # import statements
import pandas as pd
import
Click the "Run" button to run the code. If no errors are generated, you have successfully installed Jupyter and can now proceed with the rest of your development.
The first three import statements import the pandas, numpy, and matplotlib.pyplot packages from our project. The next three statements import the specified modules from sklearn.
Our next task is to download the data we need for our project. We will learn about this in the next chapter.