Skip to content

Draft: Submission: A4 - Machine Learning

Submission Report

Submit status

  • I have started working on the assignment.
  • All mandatory requirements for the grade I'm aiming for are met (see below).
  • I have completed the assignment report (see below).

  • I intend to submit the assignment, and at the same time, I guarantee that I am the one who created the submitted code. When I have used external libraries or used code from other sources, the source has been clearly stated.

    (Swedish: Jag avser göra en inlämning av uppgiften och samtidigt garanterar jag att det är jag som skapat den inlämnade koden. När jag använt externa bibliotek, eller använt kod från andra källor, har källan angetts tydligt.)

Requirement fulfillment

Requirements

Grade E

  • Implement the Naïve Bayes algorithm, using the code structure below (you are allowed to add more classes and methods if needed).
  • Train the model on the Iris and Banknote authentication datasets (see Datasets page).
  • Calculate classification accuracies for both datasets (use all data for both training and testing).

Grade C-D

  • Implement code for generating confusion matrices, using the code structure below.

Grade A-B

  • Implement code for n-fold cross-validation, using the code structure below.
  • It shall be possible to use 3, 5 or 10 folds (it is okay if your implementation supports other folds).
  • Calculate accuracy score for 5-fold cross-validation on both datasets.

Code structure requirements

NaiveBayes class
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
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.

Input data (a float matrix with input variables as columns and examples as rows) is usually denoted with X. The categories/labels (a list of integers) is usually denoted as y. Predictions (a list of integers) shall be compared with the actual labels (y) when calculating the accuracy score (percentage correct predictions) and generating the confusion matrix.

Assignment report

This assignment was carried out to achieve an E grade and was implemented using a C# console application. The implementation was guided by course materials and supplemented with information found on the interne

👉 Did you forget to replace this text?

Reflection

👉 Did you forget to replace this text?

Further improvements

👉 Did you forget to replace this text?

Extras

👉 Did you forget to replace this text?

Feedback

👉 Did you forget to replace this text?

Merge request reports