A4 - Machine Learning
Description
Section titled “Description”- In this assignment, you shall implement the Naïve Bayes machine learning algorithm and use it on some datasets.
- You can use any programming language you like.
- You shall present your application and code at an oral examination.
- You are not required to build a REST web service for this assignment.
Submission instructions
Section titled “Submission instructions”See the Deadlines and Submissions page.
Requirements
Section titled “Requirements”| Grade | Requirements |
|---|---|
| E |
|
| C-D |
|
| A-B |
|
Code structure requirements
Section titled “Code structure requirements”| NaiveBayes class | Description |
|---|---|
void fit(X: float[][], y: int[]) |
Trains the model on input examples X and labels y. |
int[] predict(X: float[][]) |
Classifies examples X and returns a list of predictions. |
| Other methods | Description |
|---|---|
float accuracy_score(preds: int[], y: int[]) |
Calculates accuracy score for a list of predictions. |
int[][] confusion_matrix(preds: int[], y: int[]) |
Generates a confusion matrix and returns it as an integer matrix. |
int[] crossval_predict(X: float[][], y: int[], folds: int) |
Runs n-fold cross-validation and returns a list of predictions. |
Test cases
Section titled “Test cases”You can verify your results with the results in Web ML Demonstrator. The Iris dataset is built-in in Web ML (click the Try Iris dataset button), and the Banknote authentication can be uploaded from the CSV file. Note that the cross-validation results can differ slightly due to how the data is split into folds, but the accuracy you get should be almost similar to the accuracy in Web ML.