Skip to content

Machine Learning Files (backend.ml)

Hassan Naveed edited this page Nov 4, 2022 · 5 revisions

About

This page contains documentation for the files in the /backend/ml directory of the Github repo. This page is regularly updated when new changes are added to these files.

ML Model Parser (ml_model_parser.py)

To keep it consistent with the dl_model_parser.py file, we had an ml_model_parser.py. However, it is relatively simple since classical ML models don't have any layers. It is just one element. The code is shown below:

def get_object_ml(element):
    return eval(
        element[0]
    )

ML Trainer (ml_trainer.py)

Endpoint that deals with the training of classical ML models (eg: decision tree, random forest, linear regression, SVM, KNN). Training of classical ML models is done through sklearn!

For Classification models, this model currently uses soft labels (probabilities instead of hard 0 or 1 labels). It outputs the predictions as a Confusion Matrix using the method in common/utils

For Regression models, the Root Mean Square Error (rmse) and Mean Absolute Percentage Error (mape) to the console. We will be working on bringing better visualization methods in a future iteration.

Models Supported

We currently have the following models supported:

  1. Classification:
  2. Regression:

It also includes the following hyper-parameters (not applicable to all models):

  • num_estimators: The number of trained trees in the forest
  • max_depth: The maximum depth of the tree
  • min_samples_split: The minimum number of samples needed to split a leaf node
  • fit_intercept: Whether a bias term is added to Linear or Logistic regression models
  • C: The strength of regularization. Ranges from 0 to 1

Additional details about parameters can be founded in the model documentations.

Possible Cases For Errors

  • In Regression models, the intercept needs to be a boolean, and generates an error for being outside the desired range.
Clone this wiki locally