student notes / est. for the classroom

HTML, CSS, JavaScript, Python, data science, computer networks — written the way you'd explain it to a classmate, not a compiler.

Top Job & Internship Portals

Handpicked portals for fresher jobs, tech roles, and listings in Hyderabad

GFG

GeeksforGeeks

Tech & Software Roles

Visit →
INT

Internshala

Fresher Jobs & Internships

Visit →
GOOG

Google Careers

Global Google Openings

Visit →
APN

Apna Jobs

Local Jobs in Hyderabad

Visit →
INS

Instahyre

Tech Roles in Hyderabad

Visit →
NAUK

Naukri.com

Fresher Jobs in Hyderabad

Visit →
📢 Updated daily

Internship & Job Alerts

01

Latest notes

July 03, 2026

Machine Learning Lab (Practice)

 

Machine Learning Lab (AM505PC) syllabus for B.Tech III Year I Semester.


Vision and Mission of ACE Engineering College

Vision

To build a strong, dynamic, and inclusive alumni network that contributes meaningfully to the academic excellence, professional growth, and societal impact of ACE Engineering College.

Mission

  • To foster lifelong relationships between alumni and the institution.
  • To promote continuous interaction among alumni, students, faculty, and management.
  • To encourage alumni participation in academic, technical, and career-oriented activities.
  • To support institutional development through knowledge sharing, mentoring, and resource mobilization.
  • To uphold the values, traditions, and reputation of ACE Engineering College.


Vision and Mission of AI and ML (CSM)

Vision of the Department

To be an epicentre of excellence in education by offering cutting-edge technologies, research, and product-based opportunities to students, enabling them to succeed in global professional competitions with a foundation of core knowledge, entrepreneurial skills, ethical values, and social responsibility.

Mission of the Department

Imparting quality technical education to young computer engineers by providing them

  • M1: Impart quality technical education with state-of-the-art laboratories, analytical and core technical skills of international standards, delivered by qualified and experienced faculty.
  • M2: Prepare students for global professional competitions, examinations for higher studies, and employment in product-based companies.
  • M3: Develop professional attitudes, research aptitude, critical reasoning, problem-solving skills, and technical consultancy capabilities by providing training in cutting-edge technologies.
  • M4: Promote and nurture knowledge, lifelong learning, entrepreneurial practices, ethical values, and social responsibility.


Programme Educational Objectives (PEOs)

PEO1: Equip students with strong foundations in mathematics, statistics, programming, and machine learning for solving real-world problems.

PEO2: Enable students to design, develop, and implement machine learning models using modern programming languages and software tools.

PEO3: Develop analytical thinking, problem-solving abilities, and data-driven decision-making skills through practical laboratory experiments.

PEO4: Prepare students for higher education, research, entrepreneurship, and successful careers in Artificial Intelligence, Machine Learning, and Data Science.

PEO5: Encourage lifelong learning, professional ethics, teamwork, and effective communication in multidisciplinary environments.


Programme Outcomes (POs)

After successful completion of the Machine Learning Laboratory, students will be able to:

PO1: Apply knowledge of mathematics, statistics, computer science, and engineering fundamentals to machine learning problems.

PO2: Identify, formulate, analyze, and solve data-driven problems using appropriate machine learning techniques.

PO3: Design and implement machine learning models for prediction, classification, clustering, and regression tasks.

PO4: Conduct experiments, analyze datasets, interpret results, and draw meaningful conclusions.

PO5: Use modern engineering tools, programming languages, libraries, and frameworks such as Python, NumPy, Pandas, SciPy, Matplotlib, and Scikit-learn.

PO6: Understand the impact of machine learning solutions in societal, environmental, and industrial contexts.

PO7: Apply ethical principles while handling data and developing intelligent systems.

PO8: Function effectively as an individual and as a member or leader in multidisciplinary teams.

PO9: Communicate technical concepts, experimental findings, and project results effectively.

PO10: Recognize the importance of lifelong learning and adapt to emerging technologies in AI and Machine Learning.


Programme Specific Outcomes (PSOs)

After completing the Machine Learning Laboratory, students will be able to:

PSO1: Perform statistical analysis using Python libraries including Statistics, NumPy, SciPy, and Math.

PSO2: Apply data preprocessing, visualization, and exploratory data analysis using Pandas and Matplotlib.

PSO3: Develop supervised learning models such as Linear Regression, Multiple Linear Regression, Logistic Regression, Decision Trees, and K-Nearest Neighbors.

PSO4: Implement unsupervised learning techniques such as K-Means Clustering for data grouping and pattern discovery.

PSO5: Evaluate and compare machine learning algorithms using appropriate performance metrics and parameter tuning techniques.

PSO6: Build complete machine learning solutions by integrating data preprocessing, model training, testing, evaluation, and visualization.


Course Objective

  • To provide an overview of various machine learning techniques and demonstrate them using Python.

Laboratory Course Outcomes (COs)

CO1Apply Python programming and scientific libraries for statistical computations and data analysis.
CO2Perform data preprocessing, visualization, and exploratory analysis using Pandas and Matplotlib.
CO3Develop and evaluate regression models for prediction problems using Scikit-learn.
CO4Implement classification algorithms including Decision Tree, KNN, and Logistic Regression.
CO5Apply clustering techniques such as K-Means to discover hidden patterns in datasets.
CO6Analyze and compare the performance of different machine learning algorithms through a mini project.


List of Experiments

Exp. No.Experiment
1Write a Python program to compute Central Tendency Measures (Mean, Median, Mode) and Measures of Dispersion (Variance, Standard Deviation).
2Study Python basic libraries such as Statistics, Math, NumPy, and SciPy.
3Study Python libraries for ML applications such as Pandas and Matplotlib.
4Write a Python program to implement Simple Linear Regression.
5Implement Multiple Linear Regression for House Price Prediction using scikit-learn.
6Implement a Decision Tree using scikit-learn and perform parameter tuning.
7Implement K-Nearest Neighbors (KNN) using scikit-learn.
8Implement Logistic Regression using scikit-learn.
9Implement K-Means Clustering.
10Performance analysis of Classification Algorithms on a specific dataset (Mini Project).

Text Book

  • Tom M. Mitchell – Machine Learning (MGH).

Reference Book

  • Stephen Marsland – Machine Learning: An Algorithmic Perspective (Taylor & Francis).

 

 

Install python

 https://youtu.be/rgf0-Uypb28?si=SWeb1LZo_3ziqO08

 

 

 

 

LAB 1

  

 1. Find mean of numbers?

numbers = [10, 20, 30, 40, 50]

mean = sum(numbers) / len(numbers)

print("Mean =", mean)

 OUTPUT

Mean = 30.0


2. Find median of numbers?

# Program to find Median

numbers = [10, 20, 30, 40, 50]

numbers.sort()
n = len(numbers)

if n % 2 == 0:
    median = (numbers[n//2 - 1] + numbers[n//2]) / 2
else:
    median = numbers[n//2]

print("Median =", median)

 OUTPUT

Median = 30


3. Find mode of numbers?

# Program to find Mode

numbers = [10, 20, 20, 30, 40, 20, 50]

mode = max(set(numbers), key=numbers.count)

print("Mode =", mode)

 OUTPUT

Mode = 20


4. Find Variance of numbers?

# Program to find Variance

numbers = [10, 20, 30, 40, 50]

mean = sum(numbers) / len(numbers)

variance = sum((x - mean) ** 2 for x in numbers) / len(numbers)

print("Variance =", variance)

 OUTPUT

Variance = 200.0


 5. Find standard deviation of numbers?

# Program to find Standard Deviation

numbers = [10, 20, 30, 40, 50]

mean = sum(numbers) / len(numbers)

variance = sum((x - mean) ** 2 for x in numbers) / len(numbers)

std_deviation = variance ** 0.5

print("Standard Deviation =", std_deviation)

 OUTPUT

Standard Deviation = 14.142135623730951


 6. Find mean, median, mode, variance and standard deviation of numbers?

# Experiment 1
# Program to compute Mean, Median, Mode, Variance, and Standard Deviation

import statistics

# Input numbers from user
data = list(map(float, input("Enter numbers separated by space: ").split()))

# Mean
mean = statistics.mean(data)

# Median
median = statistics.median(data)

# Mode
try:
    mode = statistics.mode(data)
except statistics.StatisticsError:
    mode = "No unique mode"

# Variance
variance = statistics.variance(data)

# Standard Deviation
std_dev = statistics.stdev(data)

# Display Results
print("\n----- Statistical Measures -----")
print("Mean =", mean)
print("Median =", median)
print("Mode =", mode)
print("Variance =", variance)
print("Standard Deviation =", std_dev)

 OUTPUT

Enter numbers separated by space: 5 6 4 8 5 9 4 5 6 8 9 2 1 45


----- Statistical Measures -----

Mean = 8.357142857142858

Median = 5.5

Mode = 5.0

Variance = 117.01648351648352

Standard Deviation = 10.817415750376036



LAB 2 

 1. Find mean with statistics library?

# Study of Statistics Library

import statistics

data = [10, 20, 30, 40, 50]

print("Mean:", statistics.mean(data))
print("Median:", statistics.median(data))
print("Mode:", statistics.mode(data))
print("Variance:", statistics.variance(data))
print("Standard Deviation:", statistics.stdev(data))

 OUTPUT

Mean: 30

Median: 30

Mode: 10

Variance: 250

Standard Deviation: 15.811388300841896


 2. Write a simple program using math library?

# Study of Math Library

import math

num = 25

print("Square Root:", math.sqrt(num))
print("Power (5^2):", math.pow(5, 2))
print("Factorial of 5:", math.factorial(5))
print("Value of Pi:", math.pi)
print("Value of e:", math.e)
print("Ceil of 4.3:", math.ceil(4.3))
print("Floor of 4.7:", math.floor(4.7))

 OUTPUT

Square Root: 5.0

Power (5^2): 25.0

Factorial of 5: 120

Value of Pi: 3.141592653589793

Value of e: 2.718281828459045

Ceil of 4.3: 5

Floor of 4.7: 4


 3. Write a simple python program using scipy library?

# Study of SciPy Library

from scipy import stats

data = [10, 20, 30, 40, 50]

print("Mean:", stats.tmean(data))
print("Variance:", stats.tvar(data))
print("Standard Deviation:", stats.tstd(data))

 OUTPUT

Mean: 30.0 Variance: 250.0 Standard Deviation: 15.811388300841896


 4. Write a simple program using numpy?

# Study of NumPy Library

import numpy as np

arr = np.array([10, 20, 30, 40, 50])

print("Array:", arr)
print("Sum:", np.sum(arr))
print("Mean:", np.mean(arr))
print("Maximum:", np.max(arr))
print("Minimum:", np.min(arr))

 OUTPUT

Array: [10 20 30 40 50]

Sum: 150

Mean: 30.0

Maximum: 50

Minimum: 10



 5. Write a python program using statistics, math, scipy and numpy?

# Experiment 2
# Study of Python Libraries: Statistics, Math, NumPy, and SciPy

import statistics
import math
import numpy as np
from scipy import stats

# Sample Data
data = [10, 20, 30, 40, 50]

# Statistics Library
print("=== Statistics Library ===")
print("Mean:", statistics.mean(data))
print("Median:", statistics.median(data))
print("Mode:", statistics.mode(data))

# Math Library
print("\n=== Math Library ===")
print("Square Root of 25:", math.sqrt(25))
print("Factorial of 5:", math.factorial(5))
print("Value of Pi:", math.pi)

# NumPy Library
arr = np.array(data)
print("\n=== NumPy Library ===")
print("Array:", arr)
print("Sum:", np.sum(arr))
print("Average:", np.mean(arr))
print("Maximum:", np.max(arr))
print("Minimum:", np.min(arr))

# SciPy Library
print("\n=== SciPy Library ===")
print("Mean:", stats.tmean(data))
print("Variance:", stats.tvar(data))
print("Standard Deviation:", stats.tstd(data))

 OUTPUT

=== Statistics Library === Mean: 30 Median: 30 Mode: 10 === Math Library === Square Root of 25: 5.0 Factorial of 5: 120 Value of Pi: 3.141592653589793 === NumPy Library === Array: [10 20 30 40 50] Sum: 150 Average: 30.0 Maximum: 50 Minimum: 10 === SciPy Library === Mean: 30.0 Variance: 250.0 Standard Deviation: 15.811388300841896


 LAB 3

 1. Write a python program using pandas library?

# Study of Pandas Library

import pandas as pd

data = {
    "Name": ["Alice", "Bob", "Charlie"],
    "Marks": [85, 90, 78]
}

df = pd.DataFrame(data)

print(df)

 OUTPUT

      Name  Marks

0    Alice     85

1      Bob     90

2  Charlie     78


 2. Write a python program using matplotlib library?

# Study of Matplotlib Library

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [10, 20, 30, 40, 50]

plt.plot(x, y)
plt.title("Simple Line Graph")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()

 OUTPUT




 3. line graph

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [10, 20, 30, 40, 50]

plt.plot(x, y)
plt.title("Line Graph")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()

 OUTPUT




 4. Bar graph

import matplotlib.pyplot as plt

students = ["A", "B", "C", "D"]
marks = [80, 90, 75, 85]

plt.bar(students, marks)
plt.title("Bar Graph")
plt.xlabel("Students")
plt.ylabel("Marks")
plt.show()

 OUTPUT




 5. Pie chart

import matplotlib.pyplot as plt

labels = ["Python", "Java", "C++", "C"]
sizes = [40, 30, 20, 10]

plt.pie(sizes, labels=labels, autopct="%1.1f%%")
plt.title("Pie Chart")
plt.show()

 OUTPUT




 6. Column chart

import matplotlib.pyplot as plt

months = ["Jan", "Feb", "Mar", "Apr"]
sales = [200, 300, 250, 400]

plt.bar(months, sales)
plt.title("Column Graph")
plt.xlabel("Months")
plt.ylabel("Sales")
plt.show()

 OUTPUT



 

 LAB 4

 

1. Write a simple python code for linear regression using scikit-learn 

# Simple Linear Regression

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

# Input data
x = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)
y = np.array([2, 4, 5, 4, 5])

# Create and train the model
model = LinearRegression()
model.fit(x, y)

# Predict values
y_pred = model.predict(x)

# Print equation
print("Slope:", model.coef_[0])
print("Intercept:", model.intercept_)

# Plot graph
plt.scatter(x, y, color="blue", label="Actual Data")
plt.plot(x, y_pred, color="red", label="Regression Line")
plt.title("Simple Linear Regression")
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
plt.show()

 OUTPUT




 LAB 5

 1. Implement Multiple Linear Regression for House Price Prediction using scikit-learn.

# Multiple Linear Regression

import pandas as pd
from sklearn.linear_model import LinearRegression

# Sample dataset
data = {
    "Area": [1000, 1200, 1500, 1800, 2000],
    "Bedrooms": [2, 2, 3, 3, 4],
    "Price": [300000, 350000, 450000, 500000, 600000]
}

# Create DataFrame
df = pd.DataFrame(data)

# Features (Independent variables)
X = df[["Area", "Bedrooms"]]

# Target (Dependent variable)
y = df["Price"]

# Create and train the model
model = LinearRegression()
model.fit(X, y)

# Predict house price
predicted_price = model.predict([[1600, 3]])

print("Predicted House Price =", predicted_price[0])

 OUTPUT

Predicted House Price = 469158.87850467284


 LAB 6

 1. Implement a Decision Tree using scikit-learn and perform parameter tuning.

# Decision Tree with Parameter Tuning

from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

# Sample dataset
X = [
    [22, 0],
    [25, 1],
    [47, 1],
    [52, 0],
    [46, 1],
    [56, 0],
    [48, 1],
    [33, 0]
]

# Target (0 = No, 1 = Yes)
y = [0, 0, 1, 1, 1, 1, 1, 0]

# Split dataset
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.25, random_state=42
)

# Create Decision Tree with parameter tuning
model = DecisionTreeClassifier(max_depth=3)

# Train model
model.fit(X_train, y_train)

# Predict
y_pred = model.predict(X_test)

# Accuracy
print("Accuracy:", accuracy_score(y_test, y_pred))

 OUTPUT

Accuracy: 1.0


 LAB 7

1. Implement a Decision Tree using scikit-learn and perform parameter tuning?

# Decision Tree with Parameter Tuning

from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

# Sample dataset
X = [
    [22, 0],
    [25, 1],
    [47, 1],
    [52, 0],
    [46, 1],
    [56, 0],
    [48, 1],
    [33, 0]
]

# Target (0 = No, 1 = Yes)
y = [0, 0, 1, 1, 1, 1, 1, 0]

# Split dataset
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.25, random_state=42
)

# Create Decision Tree with parameter tuning
model = DecisionTreeClassifier(max_depth=3)

# Train model
model.fit(X_train, y_train)

# Predict
y_pred = model.predict(X_test)

# Accuracy
print("Accuracy:", accuracy_score(y_test, y_pred))

 OUTPUT

Accuracy: 1.0


 LAB 8

 1. Implement Logistic Regression using scikit-learn?

# Logistic Regression

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

# Sample dataset
X = [
    [20], [25], [30], [35], [40],
    [45], [50], [55], [60], [65]
]

# Target (0 = No, 1 = Yes)
y = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]

# Split data
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# Create Logistic Regression model
model = LogisticRegression()

# Train the model
model.fit(X_train, y_train)

# Predict
y_pred = model.predict(X_test)

# Accuracy
print("Accuracy:", accuracy_score(y_test, y_pred))

# Predict for a new value
new_data = [[42]]
prediction = model.predict(new_data)

print("Prediction for Age 42:", prediction[0])

 OUTPUT

Accuracy: 1.0 Prediction for Age 42: 1


LAB 9

1. Implement k-means clustering?

# K-Means Clustering

import matplotlib.pyplot as plt
from sklearn.cluster import KMeans

# Sample data
X = [
    [1, 2],
    [2, 3],
    [3, 3],
    [8, 7],
    [8, 8],
    [9, 8]
]

# Create K-Means model
kmeans = KMeans(n_clusters=2, random_state=0)

# Train the model
kmeans.fit(X)

# Cluster labels
print("Cluster Labels:", kmeans.labels_)

# Cluster centers
print("Cluster Centers:")
print(kmeans.cluster_centers_)

# Plot clusters
plt.scatter([i[0] for i in X], [i[1] for i in X], c=kmeans.labels_)
plt.scatter(kmeans.cluster_centers_[:,0],
            kmeans.cluster_centers_[:,1],
            color='red', marker='X', s=200)

plt.title("K-Means Clustering")
plt.xlabel("X")
plt.ylabel("Y")
plt.show()

 OUTPUT

Cluster Labels: [1 1 1 0 0 0]
Cluster Centers:
[[8.33333333 7.66666667]
 [2.         2.66666667]]





 

 

 

No comments:

Post a Comment

02

Capstone resource hub

Codingacharya

Capstone Learning Resources, Notes & Project Hub

TCS NQT Questions
Read Notes
Machine Learning – ACE Theory
Read Notes
Machine Learning PPT
Read Notes
MachienLearning LAB
Read Notes
CSPT LAB programs
Read Notes
Time table and CSPT syllabus
Read Notes
Appreciations
Read Notes
ISTE life memberships
Read Notes
Artificial Intelligence & Analytics
Read Notes
Fullstack Web Dev
Read Notes
MERN Web Dev
Read Notes
Course Structure
Read Notes
Cloud Computing
Read Notes
90 Days ML Challenge
Read Notes
Advanced Analytics & Viz
Read Notes
Advanced Machine Learning
Read Notes
React JS
Read Notes
ML Chaitanya
Read Notes
Important Links
Read Notes
CSS Effects
Read Notes
RESUME
Read Notes
Bootstrap CSS
Read Notes
MongoDB
Read Notes
OWN Python Package
Read Notes
HTML Course
Read Notes
HTML Projects
Read Notes
GitHub Projects
Read Notes
Angular JS
Read Notes
Journals
Read Notes
NLP Notes
Read Notes
Videos
Read Notes
Data Analytics & Viz
Read Notes
Cloud Computing (Archive)
Read Notes
Open CV
Read Notes
jQuery
Read Notes
React JS (Archive)
Read Notes
Node JS
Read Notes
DAV Theory
Read Notes
DAV Lab
Read Notes
Big Data Notes
Read Notes
R-Programming
Read Notes
HADOOP Lab
Read Notes
GATE DA
Read Notes
JAVA Lab
Read Notes
Computer Networks
Read Notes
03

Live projects & profiles