classifiers module¶
This script provides four classifiers (K-NN, SVM, Random Forest, and Naive Bayes) to solve a classification problem.
The script receives the training and test datasets (labels and data) as well as the mRMR ranking to perform the
classification. The optimisation of the parameters in the different models is carried out through a grid search,
using sklearn.model_selection.GridSearchCV. Different subsets of features of the mRMR ranking are
selected in order to determine which subset is the best.
-
classifiers.fit_model(model, data_train, data_test, labels_train, labels_test, features_mrmr, max_features)[source]¶ Fit the model.
Parameters: - model (
sklearn.model_selection.GridSearchCV) – Classifier model created by the GridSearchCV function - data_train (
numpy.ndarray) – Training dataset data - data_test (
numpy.ndarray) – Test dataset data - labels_train (
numpy.ndarray) – Training dataset labels - labels_test (
numpy.ndarray) – Test dataset labels - features_mrmr (
list) – mRMR ranking - max_features (
int) – First selected features of the mRMR ranking
:return Accuracy :rtype:
float- model (