Book Image

The Supervised Learning Workshop - Second Edition

By : Blaine Bateman, Ashish Ranjan Jha, Benjamin Johnston, Ishita Mathur
Book Image

The Supervised Learning Workshop - Second Edition

By: Blaine Bateman, Ashish Ranjan Jha, Benjamin Johnston, Ishita Mathur

Overview of this book

Would you like to understand how and why machine learning techniques and data analytics are spearheading enterprises globally? From analyzing bioinformatics to predicting climate change, machine learning plays an increasingly pivotal role in our society. Although the real-world applications may seem complex, this book simplifies supervised learning for beginners with a step-by-step interactive approach. Working with real-time datasets, you’ll learn how supervised learning, when used with Python, can produce efficient predictive models. Starting with the fundamentals of supervised learning, you’ll quickly move to understand how to automate manual tasks and the process of assessing date using Jupyter and Python libraries like pandas. Next, you’ll use data exploration and visualization techniques to develop powerful supervised learning models, before understanding how to distinguish variables and represent their relationships using scatter plots, heatmaps, and box plots. After using regression and classification models on real-time datasets to predict future outcomes, you’ll grasp advanced ensemble techniques such as boosting and random forests. Finally, you’ll learn the importance of model evaluation in supervised learning and study metrics to evaluate regression and classification tasks. By the end of this book, you’ll have the skills you need to work on your real-life supervised learning Python projects.
Table of Contents (9 chapters)

1. Fundamentals

Activity 1.01: Implementing Pandas Functions

  1. Open a new Jupyter notebook.
  2. Use pandas to load the Titanic dataset:
    import pandas as pd
    df = pd.read_csv(r'../Datasets/titanic.csv')
  3. Use the head function on the dataset as follows:
    # Have a look at the first 5 sample of the data
    df.head()

    The output will be as follows:

    Figure 1.26: First five rows

  4. Use the describe function as follows:
    df.describe(include='all')

    The output will be as follows:

    Figure 1.27: Output of describe()

  5. We do not need the Unnamed: 0 column. We can remove the column without using the del command, as follows:
    del df['Unnamed: 0']
    df = df[df.columns[1:]] # Use the columns
    df.head()

    The output will be as follows:

    Figure 1.28: First five rows after deleting the Unnamed: 0 column

  6. Compute the mean, standard deviation, minimum, and maximum values for the columns of the DataFrame without using describe:
    df.mean()

    The output will be as follows:

    Figure 1.29: Output...