0% found this document useful (0 votes)
2 views

Machine Learning Lab Manual

The document outlines two experiments in a Machine Learning Lab Manual. Experiment 1 focuses on data exploration and visualization using the Iris dataset, while Experiment 2 implements simple linear regression using sklearn. Each experiment includes code snippets and expected output descriptions for clarity.

Uploaded by

vishakha.sonie25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Machine Learning Lab Manual

The document outlines two experiments in a Machine Learning Lab Manual. Experiment 1 focuses on data exploration and visualization using the Iris dataset, while Experiment 2 implements simple linear regression using sklearn. Each experiment includes code snippets and expected output descriptions for clarity.

Uploaded by

vishakha.sonie25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Machine Learning Lab Manual

Experiment 1: Data Exploration and Visualization


**Objective:** Understand dataset structure, perform EDA and basic visualization.

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())

# Pairplot for visualization


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

Expected Output:
The output shows the first five rows, summary statistics and a pairplot of the Iris dataset.

Experiment 2: Simple Linear Regression


**Objective:** Implement simple linear regression using sklearn.

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.

You might also like