Book Image

Become a Python Data Analyst

By : Alvaro Fuentes
Book Image

Become a Python Data Analyst

By: Alvaro Fuentes

Overview of this book

Python is one of the most common and popular languages preferred by leading data analysts and statisticians for working with massive datasets and complex data visualizations. Become a Python Data Analyst introduces Python’s most essential tools and libraries necessary to work with the data analysis process, right from preparing data to performing simple statistical analyses and creating meaningful data visualizations. In this book, we will cover Python libraries such as NumPy, pandas, matplotlib, seaborn, SciPy, and scikit-learn, and apply them in practical data analysis and statistics examples. As you make your way through the chapters, you will learn to efficiently use the Jupyter Notebook to operate and manipulate data using NumPy and the pandas library. In the concluding chapters, you will gain experience in building simple predictive models and carrying out statistical computation and analysis using rich Python tools and proven data analysis techniques. By the end of this book, you will have hands-on experience performing data analysis with Python.
Table of Contents (8 chapters)

Building a regression model using scikit-learn

The previous section showed us an example of a classification model using scikit-learn. In this section, we will train a random forest model and use it to make predictions. We will also be building a classification model as the target variable in this scenario. This will be a categorical value that depicts the drinking habits of teenagers.

To do this, we first load the students dataset from the previous chapter. We will then train a logistic regression model and take a look at how to evaluate the classification model at a very basic level.

To begin, we load the libraries and import the students dataset and make some transformations to it, just as we did in the previous section. Our goal is to use the features of the students to predict the level of alcohol. These features are categorical values that can either be high or low. The...