Question: n this assignment, you will work with an Activity Recognition dataset to explore, preprocess, and apply various classification algorithms. You will build a Bayesian Classifier

n this assignment, you will work with an Activity Recognition dataset to explore, preprocess, and apply various classification algorithms. You will build a Bayesian Classifier from scratch and implement Kernel Discriminant Analysis (KDA) using different kernels. Additionally, you will apply multiple classifiers using the scikit-learn library on both the entire dataset and the PCA-reduced dataset, comparing their performance.
Part 1: Data Preprocessing
Loading the Dataset:
Load the Activity Recognition dataset into a pandas DataFrame.Display the first few rows and check for any missing values.Handle missing values if necessary.
Train-Test Split:
Split the dataset into training and testing sets.Use an 80/20 split, where 80% of the data is used for training and 20% for testing.
Part 2: Classification on the Entire Dataset
In this part, you will apply several classifiers to the entire dataset without any dimensionality reduction.
Bayesian Classifier (from scratch):
Implement a Bayesian classifier by calculating the prior probabilities and modeling the likelihood with a Gaussian distribution.Use Bayes' Theorem to compute the posterior probability for each class and classify the test data.
Other Classifiers (using scikit-learn): Apply the following classifiers from scikit-learn:
Support Vector Machine (SVM):
Use both Linear SVM and Kernel SVM (RBF and Polynomial kernels).
k-Nearest Neighbors (KNN):
Experiment with different values for k.
Naive Bayes:
Implement Gaussian Naive Bayes using GaussianNB.
Linear Discriminant Analysis (LDA):
Use LinearDiscriminantAnalysis.
Kernel Discriminant Analysis (KDA):
Implement KDA using different kernels (RBF, Polynomial).
Evaluation:
Evaluate the performance of all classifiers on the test set using the following metrics:
AccuracyPrecisionRecallF1-Score
Generate a confusion matrix for each classifier.
Part 3: Dimensionality Reduction Using PCA
Principal Component Analysis (PCA):
Apply PCA to the dataset to reduce its dimensionality.Choose the number of components based on the explained variance ratio (e.g., retain 95% of the variance).Visualize the first two principal components.
Kernel PCA (Optional):
Experiment with Kernel PCA using different kernels (linear, RBF, polynomial) and visualize the results.
Part 4: Classification on the PCA-Reduced Dataset
Now, apply the same classifiers used in Part 2 to the PCA-reduced dataset:
Bayesian Classifier (from scratch):
Apply the Bayesian Classifier you built from scratch to the PCA-reduced data.
Other Classifiers (using scikit-learn):
Apply the following classifiers on the PCA-reduced dataset:
Linear SVM and Kernel SVM.k-Nearest Neighbors (KNN).Naive Bayes.Linear Discriminant Analysis (LDA).Kernel Discriminant Analysis (KDA).
Evaluation:
Evaluate the classifiers again using the same metrics (accuracy, precision, recall, F1-score).Compare their performance with and without PCA.
Part 5: Performance Comparison
Evaluation:
Create a summary table comparing the performance of all classifiers on the entire dataset and the PCA-reduced dataset.Discuss how the classifiers performed with and without PCA.
Comparison and Discussion:
Compare the Bayesian classifier built from scratch to its scikit-learn counterparts.Analyze the impact of PCA on the classifiers performance.Discuss the effect of using different kernels in SVM and KDA.
Submission Instructions:
Submit your work in a Jupyter notebook named firstname_lastname.ipynb.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!