Practical Exercises Chapter 14
Exercise 1: Implementing Simple Linear Regression
Your first task is to implement simple linear regression from scratch. You'll predict house prices based on the number of bedrooms.
Dataset: You can generate or find a small dataset containing house prices and the number of bedrooms.
import numpy as np
import matplotlib.pyplot as plt
# Sample Data
X = np.array([1, 2, 3, 4, 5]) # Number of bedrooms
y = np.array([100, 150, 200, 250, 300]) # House prices in thousands
# Implement simple linear regression here
Exercise 2: Classify Iris Species Using k-NN
Dataset: Use the famous Iris dataset, which is available through scikit-learn.
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
# Load data
iris = load_iris()
# Train a k-NN classifier
Exercise 3: Decision Tree Classifier for Breast Cancer Data
Dataset: Use the Breast Cancer dataset from scikit-learn.
from sklearn.datasets import...