Posts

Showing posts with the label MNIST

Measuring Accuracy Using Cross-Validation

Image
  Measuring Accuracy Using Cross-Validation •         A good way to evaluate a model is to use cross-validation . •         Let’s use the cross_val_score() function to ü   evaluate our SGDClassifier model , ·        using K-fold cross-validation with three folds . •         Remember that K-fold cross-validation means ü   splitting the training set into K folds (in this case, three), then ·        making predictions and ·        evaluating them on each fold using ü   a model trained on the remaining folds . from sklearn.model_selection import cross_val_score cross_val_score ( sgd_clf , X_train , y_train_5 , cv = 3 , scoring = "accuracy" )                         array([0.96355, 0.93795, 0.95615]) ü   Above 93% accuracy (ratio of correct predictions) on all cross-validation folds? ü   This looks amazing, doesn’t it? ü   let’s look at a very dumb classifier that just classifies every single image in the “not-5” class: from sklearn.

Training a Binary Classifier

Image
  Training a Binary Classifier ·        Let’s simplify the problem for now and ü   only try to identify one digit —for example, the number 5 . ·        This “ 5-detector ” will be an example of a binary classifier , ü   capable of distinguishing between just two classes, ·        5 ·        not-5.   ü   Let’s create the target vectors for this classification task : y_train_5 = ( y_train == 5 ) # True for all 5s, False for all other digits y_test_5 = ( y_test == 5 ) ·        Now let’s pick a classifier and train it . ·        A good place to s tart is with a ü   Stochastic Gradient Descent (SGD) classifier , ·        using Scikit-Learn’s SGDClassifier class. ·        This classifier has the advantage of being capable of handling very large datasets efficiently. ·        This is in part because SGD deals with training instances independently , one at a time. ü   Let’s create an SGDClassifier and train it on the whole training set: fr

Machine Learning - Classification MCQs

 Machine Learning - Classification - MCQs 1.      By default, SGD classifier follows this strategy for multi-class classification: Top of Form A)    OvO strategy B)     OvA strategy C)     Both D)    None Ans: B 2.      SGD Classifiers and Linear Classifiers are strictly A)    Binary Classifier B)     Multiclass classifier C)     Both D)    None      Ans: A 3.      The greater the value for ROC AUC, better the model: Top of Form A)    True B)     False Bottom of Form Ans: A 4.      The maximum value of the ROC AUC is Top of Form A)     0.8 B)      0.9  C)      1 D)     0.7 Bottom of Form Ans: C 5.      Recall can be increased by increasing the decision threshold. True or False Top of Form ? A)     False B)      True Ans: A 6.      Precision can be increased by increasing the decision threshold. True or False? A)    True B)     False Ans: A   7.      Which of these is a good measure to decide which threshold to use?