0% found this document useful (0 votes)
49 views2 pages

Machine Learning Lab Manual

The document outlines two lab exercises in a Machine Learning Lab Manual. Lab 1 focuses on data exploration and visualization using the Iris dataset, including basic EDA and a pairplot. Lab 2 involves implementing simple linear regression on the Boston Housing dataset, with a focus on visualizing the regression line against the data points.

Uploaded by

vishakha.sonie25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

Machine Learning Lab Manual

The document outlines two lab exercises in a Machine Learning Lab Manual. Lab 1 focuses on data exploration and visualization using the Iris dataset, including basic EDA and a pairplot. Lab 2 involves implementing simple linear regression on the Boston Housing dataset, with a focus on visualizing the regression line against the data points.

Uploaded by

vishakha.sonie25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Machine Learning Lab Manual

Lab 1: Data Exploration and Visualization


Load the Iris dataset, perform basic exploratory data analysis (EDA) and visualize the
features.

Python Code

import seaborn as sns


import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
import pandas as pd

# Load Iris dataset


iris = load_iris()
df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
df['species'] = iris.target

# Display head
print(df.head())

# Pairplot
sns.pairplot(df, hue='species')
plt.show()

Expected Output
The output will display the first few rows of the Iris dataset and a pairplot visualizing the
relationships between features.

Lab 2: Simple Linear Regression


Implement simple linear regression using Scikit-learn on the Boston Housing dataset.

Python Code

from sklearn.datasets import load_diabetes


from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt

# Load dataset
X, y = load_diabetes(return_X_y=True)
X = X[:, None, 2] # Use one feature

# Create linear regression model


model = LinearRegression()
model.fit(X, y)

# Predict
y_pred = model.predict(X)

# Plot
plt.scatter(X, y, color='black')
plt.plot(X, y_pred, color='blue', linewidth=3)
plt.title("Simple Linear Regression")
plt.show()

Expected Output
The output is a scatter plot of the data with a fitted regression line.

You might also like