Sample Practical Questions
Mid-Term Practical Examination
(Machine Learning Deep Learning Lab)
The following questions are sample questions intended to help you understand the type
and format of coding questions that may appear in the practical examination.
These are indicative only and may not be exhaustive.
1. Data Loading and Inspection – Iris Dataset
Load the Iris dataset and perform the following tasks:
1. Display the first 5 rows of the dataset.
2. Display the last 5 rows of the dataset.
3. Print the shape of the dataset.
4. Display the column names and data types.
5. Check whether the dataset contains missing values.
6. Generate a bar chart showing the count of each species.
2. Data Cleaning – Titanic Dataset
Load the Titanic dataset using Seaborn and perform the following tasks:
1. Display the missing values in each column.
2. Check whether the dataset contains duplicate rows.
3. Generate a box plot for the Fare column.
4. Remove duplicate rows from the dataset.
5. Fill missing values in numerical columns using median.
6. Fill missing values in categorical columns using mode.
7. Display the shape of the cleaned dataset.
3. Data Pre-processing – Adult Dataset
Load the Adult dataset and perform the following steps:
1. Replace all "?" values with NaN.
2. Display the missing values per column.
3. Drop rows where occupation is missing.
4. Fill missing values in workclass and [Link] using mode.
5. Encode the sex column numerically.
6. Apply StandardScaler to the [Link] column.
7. Display the first 5 rows of the processed dataset.
4. Palmer Penguins Dataset – Inspection and Missing Value Handling
Load the Palmer Penguins dataset using Seaborn and perform the following tasks:
1. Display the first 5 rows and last 5 rows.
2. Display the dataset structure using [Link]().
3. Calculate the number of missing values in each column.
4. Drop rows where the sex column contains missing values.
5. Fill missing values in bill_length_mm using mean.
6. Fill missing values in flipper_length_mm using median.
7. Generate a box plot for flipper_length_mm.
8. Display the final shape of the cleaned dataset.
5. Simple Linear Regression – Salary Dataset
Using the Salary dataset, perform the following tasks:
1. Load the dataset and display the first 5 rows.
2. Define YearsExperience as the independent variable and Salary as the
dependent variable.
3. Split the dataset into training and testing sets.
4. Train a Linear Regression model.
5. Predict the salary values for the test dataset.
6. Plot the regression line for the training dataset.
7. Print the coefficient and intercept of the model.
6. Multiple Linear Regression – 50 Startups Dataset
Using the 50_Startups dataset, perform the following tasks:
1. Load the dataset and display the first 5 rows.
2. Define Profit as the dependent variable.
3. Apply One-Hot Encoding to the State column.
4. Split the dataset into training and testing sets.
5. Train a Multiple Linear Regression model.
6. Predict the profit values for the test set.
7. Display the predicted and actual values side by side.
7. KNN Classification – Social Network Ads Dataset
Using the Social Network Ads dataset, perform the following tasks:
1. Load the dataset and display the first 5 rows.
2. Drop the User ID column.
3. Encode the Gender column.
4. Select Age and EstimatedSalary as features and Purchased as the target
variable.
5. Split the dataset into training and testing sets.
6. Apply StandardScaler for feature scaling.
7. Train a KNN classifier with K = 5.
8. Predict the test set results.
9. Calculate the accuracy score and display the confusion matrix.
8. K-Means Clustering – Mall Customers Dataset
Using the Mall Customers dataset, perform the following tasks:
1. Load the dataset and display the first 5 rows.
2. Select Annual Income and Spending Score as features.
3. Apply feature scaling using StandardScaler.
4. Use the Elbow Method to determine the optimal value of K.
5. Apply K-Means clustering with K = 5.
6. Plot the clusters using different colors.
7. Mark the centroids on the cluster plot.
Note:
These questions are provided only as sample practice questions.