Practical Exercises Chapter 13
Here are some practical exercises to reinforce your understanding of the concepts covered in Chapter 13.
Exercise 13.1: Types of Machine Learning
Problem:
Classify the following scenarios as supervised, unsupervised, or reinforcement learning tasks:
- Teaching a drone to navigate through an obstacle course.
- Grouping articles based on their content.
- Predicting the weather for the next week.
- Recommending music based on a user's previous listening habits.
Solution:
- Reinforcement Learning
- Unsupervised Learning
- Supervised Learning
- Reinforcement Learning or Supervised Learning (depending on how it's implemented)
Exercise 13.2: Implement a Basic Algorithm
Problem:
Implement a basic K-Nearest Neighbors (KNN) algorithm to classify the following dataset into two classes:
# Data
X = [[2, 3], [4, 1], [1, 4], [4, 4], [2, 1], [3, 2]]
y = [0, 1, 0, 1, 0, 1]
Solution:
from sklearn.neighbors import KNeighborsClassifier
# Create a...