# underfitting linear regression

import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error from sklearn.datasets import load_breast_cancer # Load the Breast Cancer Dataset data = load_breast_cancer() X = data.data y = data.target # Split the dataset into training and testing sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # Train a simple linear regression model lr = LinearRegression() lr.fit(X_train, y_train) # Calculate training and testing errors train_error = mean_squared_error(y_train, lr.predict(X_train)) test_error = mean_squared_error(y_test, lr.predict(X_test)) print(f'Training error: {train_error:.2f}') print(f'Testing error: {test_error:.2f}')