Machine Learning Lab Manual
Machine Learning Lab Manual
Code:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Load dataset
df = sns.load_dataset('iris')
print(df.head())
# Summary statistics
print(df.describe())
Expected Output:
The output shows the first five rows, summary statistics and a pairplot of the Iris dataset.
Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# Data
X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)
y = np.array([2, 4, 5, 4, 5])
# Model training
model = LinearRegression()
model.fit(X, y)
# Prediction
y_pred = model.predict(X)
# Plotting
plt.scatter(X, y, color='blue')
plt.plot(X, y_pred, color='red')
plt.title('Simple Linear Regression')
plt.xlabel('X')
plt.ylabel('y')
plt.show()
Expected Output:
The output displays a scatter plot of the data points and the best fit regression line.