8 Machine learning

 

This chapter covers

  • Solving problems with machine learning algorithms
  • Grasping a machine learning life cycle, preparing data, and selecting algorithms
  • Understanding and implementing a linear-regression algorithm for predictions
  • Understanding and implementing a decision-tree learning algorithm for classification
  • Gaining intuition about other machine learning algorithms and their usefulness

What is machine learning?

Machine learning can seem like a daunting concept to learn and apply, but with the right framing and understanding of the process and algorithms, it can be interesting and fun.

Suppose that you’re looking for a new apartment. You speak to friends and family, and do some online searches for apartments in the city. You notice that apartments in different areas are priced differently. Here are some of your observations from all your research:

  • A one-bedroom apartment in the city center (close to work) costs $5,000 per month.
  • A two-bedroom apartment in the city center costs $7,000 per month.
  • A one-bedroom apartment in the city center with a garage costs $6,000 per month.
  • A one-bedroom apartment outside the city center, where you will need to travel to work, costs $3,000 per month.
  • A two-bedroom apartment outside the city center costs $4,500 per month.
  • A one-bedroom apartment outside the city center with a garage costs $3,800 per month.

Problems applicable to machine learning

Supervised learning

Unsupervised learning

Reinforcement learning

A machine learning workflow

Collecting and understanding data: Know your context

Preparing data: Clean and wrangle

Training a model: Predict with linear regression

Testing the model: Determine the accuracy of the model

Improving accuracy

Classification with decision trees

Classification problems: Either this or that

The basics of decision trees

Training decision trees

Classifying examples with decision trees

Other popular machine learning algorithms

Use cases for machine learning algorithms

Summary of machine learning