0% found this document useful (0 votes)
8 views7 pages

AIML Assignment_merged

The document outlines a comprehensive curriculum for an Artificial Intelligence & Machine Learning Laboratory course at the University of Engineering & Management, Kolkata. It includes weekly topics covering Numpy, Pandas, Matplotlib, and various supervised learning techniques such as Linear Regression, Logistic Regression, Decision Trees, Random Forests, SVM, and KNN, along with practical assignments for each topic. Each week features specific programming tasks and assignments aimed at reinforcing the concepts learned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
8 views7 pages

AIML Assignment_merged

The document outlines a comprehensive curriculum for an Artificial Intelligence & Machine Learning Laboratory course at the University of Engineering & Management, Kolkata. It includes weekly topics covering Numpy, Pandas, Matplotlib, and various supervised learning techniques such as Linear Regression, Logistic Regression, Decision Trees, Random Forests, SVM, and KNN, along with practical assignments for each topic. Each week features specific programming tasks and assignments aimed at reinforcing the concepts learned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

University of Engineering & Management, Kolkata

Department of Computer Science and Engineering


Paper Name: Artificial Intelligence & Machine Learning Laboratory
_______________________________________________________________
Week-1 (Introduction to Numpy)

1. Make the array [0, 1, 2] with np.array.


2. Make the array [0, 1, 2] with np.arange.
3. Make the array [0, 0, 0] with np.zeros.
4. Make the matrix [[0, 1], [2, 3]] with np.array.
5. Make the matrix [[0, 1], [2, 3]] with np.arange and np.reshape.
6. Print the shape of the matrix from the previous part with .shape.
7. Take the average of elements in a vector (np.average).
8. Add two vectors (numpy arrays) element-wise, which means that the
each element in the result vector is the sum of the corresponding
elements in two vectors.
9. Take the sum of elements in a vector (np.sum).
10. Take the square root of elements in a vector (np.sqrt).
11. Write a program to convert a list of numeric values into a one-
dimensional NumPy array.
12. Write a program to create a 3x3 matrix with values ranging from 4 to 12.
13. Write a program to create a null vector of size 10 and update the sixth
value to 15.
14. Write a program to reverse an array (the first element becomes the last).
15. Write a program to create a 2D array with 1 on the border and 0 inside.
16. Write a program to create an 8x8 matrix and fill it with a checkerboard
pattern.
17. Write a program to save a NumPy array to a text file.
18. Write a program to create a 2-dimensional array of size 2 x 3 (composed
of 4-byte integer elements), also print the shape, type and data type of the
array.
19. Write a NumPy program to create a 2-D array whose diagonal equals [4,
5, 6, 8] and 0's elsewhere.
20. Write a program to create a 1-D array of 30 evenly spaced elements
between 2.5 and 6.5, inclusive.
21. Write a program to split an array of 14 elements into 3 arrays, each with
2, 4, and 8 elements in the original order.
22. Write a program to calculate the difference between the maximum and
the minimum values of a given array along the second axis.

Week-2 (Introduction to Pandas)

1. Use pandas to create a student mark-sheet with Student ID, Name, and
marks obtained in 6 subjects
2. Use pandas to get the name and ID of the student with the highest
percentage of marks.
3. Use pandas to identify the student who got lowest marks in more than 2
subjects.
4. Save the dataFrame as a csv file called marksheet.csv.
5. How to iterate over rows in Pandas Dataframe.
6. Different ways to iterate over rows in Pandas Dataframe.
7. Selecting rows in pandas DataFrame based on conditions.
8. Select any row from a Dataframe using iloc[] and iat[] in Pandas.
9. Limited rows selection with given column in Pandas.
10. Drop rows from the dataframe based on certain condition applied on a
column.
11. Insert row at given position in Pandas Dataframe.
12. Create a pandas column using for loop.
13. How to get column names in Pandas dataframe.
14. How to rename columns in Pandas DataFrame.
15. Collapse multiple Columns in Pandas.
16. Get unique values from a column in Pandas DataFrame.
17. Conditional operation on Pandas DataFrame columns.
18. Create a Pandas Series from array.
19. Creating a Pandas Series from Dictionary.
20. Creating a Pandas Series from Lists.
21. Create Pandas Series using NumPy functions.
22. Access the elements of a Series in Pandas.
Week-3 (Introduction to Matplotlib)

1. Change the legend position in Matplotlib.


2. How to Change Legend Font Size in Matplotlib?
3. How Change the vertical spacing between legend entries in Matplotlib?
4. Use multiple columns in a Matplotlib legend.
5. How to Create a Single Legend for All Subplots in Matplotlib?
6. How to manually add a legend with a color box on a Matplotlib figure?
7. How to Add Title to Subplots in Matplotlib?
8. How to Set a Single Main Title for All the Subplots in Matplotlib?
9. How to Turn Off the Axes for Subplots in Matplotlib?
10. How to Create Different Subplot Sizes in Matplotlib?
11. How to set the spacing between subplots in Matplotlib in Python?
12. Plot a Horizontal line in Matplotlib.
13. Plot a Vertical line in Matplotlib.
14. Change the line opacity in Matplotlib.
15. Increase the thickness of a line with Matplotlib.
16. How to Fill Between Multiple Lines in Matplotlib?
17. Draw a horizontal bar chart with Matplotlib.
18. How to display the value of each bar in a bar chart using Matplotlib?
19. How to Annotate Bars in Barplot with Matplotlib in Python?
20. How to Annotate Bars in Grouped Barplot in Python?
21. How to add a legend to a scatter plot in Matplotlib?
22. How to create a Scatter Plot with several colors in Matplotlib?
23. How to increase the size of scatter points in Matplotlib?
24. How to Connect Scatterplot Points with Line in Matplotlib?

Assignment-4

Linear Regression – Supervised Learning (Regression)

1. a. Load the boston dataset from sklearn.datasets and display its


description.
b. Keep the data in a dataframe.
c. Find the self-correlation of the data features, upto 2 decimal places.
d. Add boston.target as the target variable “MEDV” to the dataframe, for
regression
e. Determine the variables which have minimum and maximum self-
correlation values and use them as training variables (x).
f. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets
g. With the use of sklearn.linear_model module, load the Linear
Regression model, train it using training data (x_train) and get the
predictions on test data (y_pred)
h. Determine and print the Mean Squared Error, Root Mean Squared Error,
and R2 score for the regression model performance.

2. Keeping everything same till Q1 part f, train a Ridge regression model


with same split ratio, feature variables and target. For the Ridge
regression, use alpha values in a range from 0 upto 100 with a step size of
5, i.e. 0<=α <=100, α=α+5. Record these 21 values of RMSE and R2 scores
in separate lists.

3. Keeping everything same till Q1 part f, train a Lasso regression model


with same split ratio, feature variables and target. For the Lasso regression,
use alpha values in a range from 0 upto 100 with a step size of 5, i.e. 0<=α
<=100, α=α+5. Record these 21 values of RMSE and R2 scores in separate
lists.

4. Using the RMSE and R2 score lists from Q2 and Q3, plot the values in
two separate line plots with the help of matplotlib. The first plot should
illustrate the RMSE scores achieved using Ridge and Lasso regression for
given set of α values, and the second plot should illustrate the R2 scores
for the same.

5. Keeping everything same till Q1 part f, train a ElasticNet regression


model with same split ratio, feature variables and target. For the ElasticNet
regression, use l1_ratio values in a range from 0 upto 1 with a step size of
0.1, i.e. 0<=l1_ratio <=1, l1_ratio=l1_ratio+0.1 Record the corresponding
10 values of RMSE and R2 scores in separate lists. Plot these RMSE and
R2 score values in separate plots.
Assignment-5

Logistic Regression– Supervised Learning (Classification)

1. a. Load the Irish dataset and display its description.


b. Keep the data in a dataframe.
c. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets.
d. Train the model with (x_train), (y_train) and get the predictions on test
data (y_pred). Use 3 different models with max_iter values as 100, 500,
1000, 5000 and 10000.
e. Determine and record all the R2 scores in a list.

2. Repeat the experiment as given in Q1, using split ratios of 60:40 and
80:20. Record the R2 scores in separate lists.
3. Plot the R2 scores from the 3 lists obtained from Q1 and Q2 and
illustrate how the R2 scores vary for different split ratios and different
max_iter values.

Assignment-6

Decision Tree and Random Forest Regression – Supervised Learning


(Regression)

1. a. Load the boston dataset from sklearn.datasets and display its


description.
b. Keep the data in a dataframe.
c. Find the self-correlation of the data features, upto 3 decimal places.
d. Add boston.target as the target variable “MEDV” to the dataframe, for
regression
e. Determine the variables which have minimum and maximum self-
correlation values and use them as training variables (x).
f. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets
g. With the use of sklearn.tree module, load the DecisionTreeRegressor
model, train it using training data (x_train) and get the predictions on test
data (y_pred)
h. Determine and record the Mean Squared Error, Root Mean Squared
Error, and R2 score for the regression model performance, in separate lists.

2. Repeat the experiment as given in Q1, using split ratios of 60:40 and
80:20. Record the Mean Squared Error, Root Mean Squared Error, and R2
scores in separate lists for each case.

3. Keeping everything same till Q1 part f, train a RandomForestRegressor


model from sklearn.ensemble module. Use the different sets of split ratios
as mentioned in Q2. Record the Mean Squared Error, Root Mean Squared
Error, and R2 scores in separate lists for each case.

4. Plot the Mean Squared Error, Root Mean Squared Error, and R2 scores
in separate plots using matplotlib module. For each plot, use the calculated
scores for the 3 different splits of train and test data. Do this for both the
DecisionTreeRegressor and RandomForestRegressor models.

Assignment-7

Decision Tree and Random Forest Classification– Supervised


Learning (Classification)

1. a. Load the Iris dataset and display its description.


b. Keep the data in a dataframe.
c. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets.
d. Train the model with (x_train), (y_train) and get the predictions on test
data (y_pred).

2. Repeat the experiment as given in Q1, using split ratios of 60:40 and
80:20.
3. Repeat the above set of experiments for the RandomForestClassifier
from sklearn.ensemble.
Assignment-8

Classification using SVM

1. a. Load the Iris dataset and display its description.


b. Keep the data in a dataframe.
c. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets.
d. Train the model with (x_train), (y_train) and get the predictions on test
data (y_pred). Use 3 different values of regularization.
e. Display the accuracy, F1-score, confusion matrix.

2. Repeat the experiment as given in Q1, using split ratios of 60:40 and
80:20.

Assignment-9

Classification using KNN

1. a. Load the Diabetes dataset and display its description.


b. Keep the data in a dataframe.
c. Using a 70:30 split ratio, create the training (x_train, y_train) and test
(x_test, y_test) datasets.
d. Train the model with (x_train), (y_train) and get the predictions on test
data (y_pred). Use 3 different values of n_neighbors.
e. Display the accuracy, F1-score, confusion matrix.

2. Repeat the experiment as given in Q1, using split ratios of 60:40 and
80:20.

You might also like