Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
The Applied Artificial Intelligence Workshop

You're reading from  The Applied Artificial Intelligence Workshop

Product type Book
Published in Jul 2020
Publisher Packt
ISBN-13 9781800205819
Pages 420 pages
Edition 1st Edition
Languages
Authors (3):
Anthony So Anthony So
Profile icon Anthony So
William So William So
Profile icon William So
Zsolt Nagy Zsolt Nagy
Profile icon Zsolt Nagy
View More author details

Table of Contents (8) Chapters

Preface
1. Introduction to Artificial Intelligence 2. An Introduction to Regression 3. An Introduction to Classification 4. An Introduction to Decision Trees 5. Artificial Intelligence: Clustering 6. Neural Networks and Deep Learning Appendix

4. An Introduction to Decision Trees

Activity 4.01: Car Data Classification

Solution:

  1. Open a new Jupyter Notebook file.
  2. Import the pandas package as pd:
    import pandas as pd
  3. Create a new variable called file_url that will contain the URL to the raw dataset:
    file_url = 'https://raw.githubusercontent.com/'\
               'PacktWorkshops/'\
               'The-Applied-Artificial-Intelligence-Workshop/'\
               'master/Datasets/car.csv'
  4. Load the data using the pd.read_csv() method.:
    df = pd.read_csv(file_url) 
  5. Print the first five rows of df:
    df.head()

    The output will be as follows:

    Figure 4.13: The first five rows of the dataset

  6. Import the preprocessing module from sklearn:
    from sklearn import preprocessing
  7. Create a function called encode() that takes a DataFrame...
lock icon The rest of the chapter is locked
arrow left Previous Chapter
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}