Project - Classify Clothes from Fashion MNIST Dataset using Machine Learning Techniques

You are currently auditing this course.
21 / 30

End to End ML Project - Fashion MNIST - Selecting the Model - Cross-Validation - RandomForestClassifier

We will be performing k-fold cross-validation with 3 folds (cv=3) on the RandomForestClassifier model, and calculating the mean accuracy, precision, recall and F1 score values for the same.

INSTRUCTIONS

Please follow the below steps:

Please create an instance of RandomForestClassifier called rnd_clf by passing to it the parameters - n_estimators=20, max_depth=10 and random_state=42

rnd_clf = RandomForestClassifier(<<your code comes here>>)

Please call cross_val_score() function by passing following parameters to it - the model (rnd_clf), the training dataset (X_train), y_train, cv=3 and scoring="accuracy" - and save the returned value in a variable called rnd_cv_scores.

Call display_scores() function, by passing to it the rnd_cv_scores variable, to calculate and display(print) the 'accuracy' score, the mean of the 'accuracy' score and the 'standard deviation' of the 'accuracy' score.

rnd_cv_scores = cross_val_score(<<your code comes here>>) 
display_scores(rnd_cv_scores)

Call mean() method on rnd_cv_scores object to get the mean accuracy score and store this mean accuracy score in a variable rnd_cv_accuracy.

rnd_cv_accuracy = rnd_cv_scores.<<your code comes here>>

Please call cross_val_predict() function by passing following parameters to it - the model (rnd_clf), the training dataset (X_train), y_train, cv=3 - and save the returned value in a variable called y_train_pred.

y_train_pred = cross_val_predict(<<your code comes here>>)

Compute the confusion matrix by using confusion_matrix() function

confusion_matrix(y_train, <<your code comes here>>)

Calculate the precision score by the using the precision_score() function

rnd_cv_precision = precision_score(y_train, <<your code comes here>>, average='weighted')

Calculate the recall score by the using the recall_score() function

rnd_cv_recall = recall_score(y_train, <<your code comes here>>, average='weighted')

Calculate the F1 score by the using the f1_score() function

rnd_cv_f1_score = f1_score(y_train, <<your code comes here>>, average='weighted')

Print the above calculated values of rnd_cv_accuracy, rnd_cv_precision, rnd_cv_recall , rnd_cv_f1_score

Get Hint

Answer is not availble for this assesment

Loading comments...