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

ML Practicals

This document outlines an introduction to machine learning course. It is divided into 4 units that cover the basics of machine learning, Python libraries for machine learning, preparing data for modeling, and supervised machine learning models. Unit 1 introduces machine learning concepts and applications. Unit 2 focuses on Python libraries like NumPy, Pandas, Matplotlib and scikit-learn. Unit 3 covers data preprocessing activities and preparing data for modeling. Unit 4 defines supervised learning and describes classification algorithms like K-Nearest Neighbors and linear regression models.

Uploaded by

Pooja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

ML Practicals

This document outlines an introduction to machine learning course. It is divided into 4 units that cover the basics of machine learning, Python libraries for machine learning, preparing data for modeling, and supervised machine learning models. Unit 1 introduces machine learning concepts and applications. Unit 2 focuses on Python libraries like NumPy, Pandas, Matplotlib and scikit-learn. Unit 3 covers data preprocessing activities and preparing data for modeling. Unit 4 defines supervised learning and describes classification algorithms like K-Nearest Neighbors and linear regression models.

Uploaded by

Pooja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction to Machine Learning Course Code: 4350702

Unit Unit Outcomes (UOs) Topics and Sub-topics


Unit – I 1.1 Describe basic concept of 1.1.1 Overview of Human Learning and
Introduction machine learning and its Machine Learning
to machine applications 1.1.2 Types of Machine Learning
learning Supervised Machine Learning
Unsupervised Machine
Learning Reinforcement
Learning.
1.1.3 Applications of Machine Learning
1.1.4 Tools and Technology for
Machine Learning
Unit – II 2.1. Develop Program using 2.1 Numpy
Python Python Libraries • Creating Array: array()
libraries • Accessing Array: by referring to its
suitable for index number
Machine • Stacking & Splitting:
stack(),
Learning
array_split()
• Maths Functions: add(), subtract(),
multiply(), divide(), power(), mod()
• Statistics Functions: amin(), amax(),
mean(), median(), std(), var(),
average(), ptp()
2.2 Pandas
• Series: Series()
• Dataframes: DataFrames()
• Read CSV File: read_csv()
• Cleaning Empty Cells: dropna()
• Cleaning Wrong Data: drop()
• Removing Duplicates: duplicated()
• Pandas Plotting: plot()
2.3 Matplotlib
• Pyplot.plot: plot()
• Show: show()
• Labels: xlabel(), ylabel()
• Grid: grid()
• Bars: bar()
• Histogram: hist()
• Subplot: subplot()
• pie chart: pie()
• Save the plotted images into pdf:
savefig()
2.4 sklearn
• Key concepts and features

GTU - COGC-2021 Curriculum


Page 1 of 10
Introduction to Machine Learning Course Code: 4350702

• Steps to Build a Model in Sklearn:


Loading a Dataset- read_csv(),
train_test_split- train_test_split()

Unit – III 3.1 Describe different types of 3.1.1 Machine Learning activities
Preparing to Machine learning Activities • Preparing to Model
Model and 3.2 Explain Data preprocessing • Learning: Data Partition-k-fold cross
Preprocessing validation, Model Selection
• Performance Evaluation: confusion
matrix
• Performance Improvement:
Ensemble
3.2.1 Types of Data
• Qualitative/Categorical Data:
Nominal, Ordinal
• Quantitative/Numeric Data:
Interval, Ratio
3.2.2 Data quality and remediation
• Handling outliers
• Handling missing values
3.2.3 Data Pre-Processing
Dimensionality reduction
• Feature subset selection: Filter,
Wrapper, Hybrid, Embedded

GTU - COGC-2021 Curriculum


Page 2 of 10
Introduction to Machine Learning Course Code: 4350702

Unit– IV 4.1 Define Supervised Learning 4.1.1 Introduction of Supervised


Supervised 4.2 List types of Supervised Learning
Machine Learning, Describe K-Nearest • Brief explanation of Supervised
Learning Neighbour and Simple linear Machine Learning
Models regression • Working of Supervised Machine
4.3 Advantage and disadvantage of learning
supervised machine learning • Real world Applications/Examples
of Supervised Machine learning
• Steps in Supervised Machine
learning
4.2.1 Types of Supervised Learning
● Classification: Define Classification,
list types of classification, list types
of Machine learning classification
algorithms (list linear models,
nonlinear models), list use cases of
classification algorithms. K-Nearest
Neighbour (K-NN) : Working of
KNN, Need of KNN algorithm, steps
of working of K-NN, Select value of
K, advantage and disadvantage of
K-NN algorithm
● Regression: Define Regression
analysis,
▪ list types of regression analysis,
▪ list real world examples of
regression analysis
● Linear regression:
List types of linear regression,
mathematical equation of linear
regression, diagram of
linear regression line (positive, negative)

Simple linear regression :


(Description, objective, demonstrate
example of salary prediction using python)
(Steps: Prepare dataset, split data set into
training and testing set, visualize training
data set and testing data set, i.e. plot it,
initialize the training set and fitting it using
training set, Predict) list applications of
linear regression 4.3.1 Advantage and
disadvantage of supervised machine
learning

GTU - COGC-2021 Curriculum


Page 3 of 10
Introduction to Machine Learning Course Code: 4350702

Unit– V 5.1 Define Unsupervised Learning 5.1.1 Introduction of Unsupervised


Unsupervised 5.2 List types of Unsupervised Learning
Machine Learning • Brief explanation of unsupervised
Learning 5.3 Differentiate Supervised and Machine Learning
Models Unsupervised Learning • Need of unsupervised learning
• Working of unsupervised learning
• Real world examples of
unsupervised Learning
• List unsupervised learning
algorithms
5.2.1 Types of Unsupervised Learning
• Clustering: Definition, list clustering
methods, list real world
applications/examples (fruits,
vegetables, computer devices
(input and output etc)),
● Association: Definition, list
association methods, list real world
applications/examples
● Advantage and Disadvantage of
unsupervised learning algorithm
5.3.1 Differentiate Supervised and
Unsupervised Learning

GTU - COGC-2021 Curriculum


Page 4 of 10
Introduction to Machine Learning Course Code: 4350702

Approx.
S.
Practical Outcomes (PrOs) Unit No. Hrs.
No.
required
Explore any one machine learning tool. I 4
1
(like Weka, Tensorflow, Scikit-learn, Colab, etc.)
Write a NumPy program to implement following operation
• to convert a list of numeric values into a one-dimensional
NumPy array
2 • to create a 3x3 matrix with values ranging from 2 to 10 II 4
• to append values at the end of an array
• to create another shape from an array without changing its
data(3*2 to 2*3)
Write a NumPy program to implement following operation
• to split an array of 14 elements into 3 arrays, each with 2, 4, and
3 II 4
8 elements in the original order
• to stack arrays horizontally (column wise)
4 Write a NumPy program to implement following operation
• to add, subtract, multiply, divide arguments element-wise
• to round elements of the array to the nearest integer
II 4
Operators arithmetic

• to calculate mean across dimension, in a 2D numpy array


• to calculate the difference between neighboring elements,
elementwise of a given array
Write a NumPy program to implement following operation
5 • to find the maximum and minimum value of a given flattened
array II 4
• to compute the mean, standard deviation, and variance of a
given array along the second axis
Write a Pandas program to implement following operation
• to convert a NumPy array to a Pandas series
• to convert the first column of a DataFrame as a Series
II 4
6 • to create the mean and standard deviation of the data of a given
Series
• to sort a given Series
Write a Pandas program to implement following operation
• to create a dataframe from a dictionary and display it
7 • to sort the DataFrame first by 'name' in ascending order II 4
• to delete the one specific column from the DataFrame
• to write a DataFrame to CSV file using tab separator

Write a Pandas program to create a line plot of the opening, closing


8 II 4
stock prices of given company between two specific dates.

Write a Pandas program to create a plot of Open, High, Low, Close,


9 Adjusted Closing prices and Volume of given company between two 4
II
specific dates.

GTU - COGC-2021 Curriculum


Page 5 of 10
Introduction to Machine Learning Course Code: 4350702

Write a Pandas program to implement following operation


10 • to find and drop the missing values from the given dataset III 4
• to remove the duplicates from the given dataset

Write a Pandas program to filter all columns where all entries


11 present, check which rows and columns has a NaN and finally drop III 4
rows with any NaNs from the given dataset.
Write a Python program using Scikit-learn to print the keys, number
12
of rows-columns, feature names and the description of the given III 4
data.
Write a Python program to implement K-Nearest Neighbour
13 IV 4
supervised machine learning algorithm for given dataset.

Write a Python program to implement a machine learning algorithm


14 for given dataset. (It is recommended to assign different machine V 4
learning algorithms group wise – micro project)

Total 56

Unit Unit Title Teaching Distribution of Theory Marks


No. Hours
R U A Total
Level Level Level Marks

I Introduction to machine learning 06 4 4 4 12

II Python libraries suitable for Machine 09 3 4 7 14


Learning

III Preparing to Model and Preprocessing 09 6 6 4 16

IV Supervised Machine Learning Models 10 5 7 4 16

V Unsupervised Machine Learning 08 5 4 3 12


Models

Total 42 23 25 22 70

GTU - COGC-2021 Curriculum


Page 6 of 10
Introduction to Machine Learning Course Code: 4350702

Working of supervised learning:


• Gather a dataset of labeled examples: The first step in supervised
learning is to gather a dataset of labeled examples that the model will be
trained on. The examples should be representative of the problem at hand
and should include both the input data and the correct output labels.
• Preprocess the data: Next, the data may need to be preprocessed in order
to prepare it for use in a machine learning model. This may include tasks
such as cleaning the data, filling in missing values, or normalizing the data.
• Train the model: Once the data is prepared, the model can be trained on it.
This involves using an optimization algorithm to adjust the parameters of
the model in order to minimize the error between the model’s predictions
and the correct output labels.
• Test the model: After the model is trained, it can be tested on a separate
dataset to evaluate its performance. The model’s accuracy can be
measured using metrics such as precision, recall, and F1 score.
• Use the model to make predictions: Once the model has been trained
and tested, it can be used to make predictions on new, unseen data. The
model will use the patterns and relationships learned during training to
make predictions based on the input data.

GTU - COGC-2021 Curriculum


Page 7 of 10
Introduction to Machine Learning Course Code: 4350702

1. Simple linear regression : (Description, objective, demonstrate example of salary


prediction using python) (Steps: Prepare dataset, split data set into training and testing set,
visualize training data set and testing data set, i.e. plot it, initialize the training set and
fitting it using training set, Predict)

Ex:

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

# Generating some sample data


np.random.seed(42)
years_of_experience = np.random.rand(100, 1) * 10
salary = 5000 + 2000 * years_of_experience + np.random.randn(100, 1) * 1000

# Splitting the data into training and testing sets


X_train, X_test, y_train, y_test = train_test_split(years_of_experience, salary, test_size=0.2,
random_state=42)

# Creating a linear regression model


model = LinearRegression()

# Training the model


model.fit(X_train, y_train)

# Making predictions on the test set


predictions = model.predict(X_test)

# Plotting the results


plt.scatter(X_test, y_test, color='black', label='Actual data')
plt.plot(X_test, predictions, color='blue', linewidth=3, label='Regression line')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')
plt.title('Salary Prediction based on Years of Experience')
plt.legend()
plt.show()

# Predicting salary for a new input


new_experience = np.array([[8]])
predicted_salary = model.predict(new_experience)
print(f'Predicted salary for {new_experience[0][0]} years of experience:
${predicted_salary[0][0]:,.2f}')

GTU - COGC-2021 Curriculum


Page 8 of 10
Introduction to Machine Learning Course Code: 4350702

1-8 yrs of experience

2. Write a Python program using Scikit-learn to print the keys, number of rows-columns,
feature names and the description of the given data.

import pandas as pd
iris_data = pd.read_csv("iris.csv")
print("\nKeys of Iris dataset:")
print(iris_data.keys())
print("\nNumber of rows and columns of Iris dataset:")
print(iris_data.shape)

o/p:

Keys of Iris dataset:


Index(['Id', 'SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm',
'Species'],
dtype='object')

Number of rows and columns of Iris dataset:


(150, 6)

GTU - COGC-2021 Curriculum


Page 9 of 10
Introduction to Machine Learning Course Code: 4350702

3. Write a Pandas program to implement following operation

• to find and drop the missing values from the given dataset
https://www.w3resource.com/python-exercises/pandas/filter/pandas-filter-exercise-4.php

• to remove the duplicates from the given dataset


https://www.w3resource.com/python-exercises/pandas/filter/pandas-filter-exercise-5.php

Advantage and Disadvantage of unsupervised learning algorithm

GTU - COGC-2021 Curriculum


Page 10 of 10

You might also like