concept model performance in category R

appears as: model performce
Machine Learning with R, the tidyverse, and mlr

This is an excerpt from Manning's book Machine Learning with R, the tidyverse, and mlr.

  • How to validate model performance and prevent overfitting
  • Repeat the nested cross-validation using 5-fold, non-repeated cross-validation as the outer loop. Which of these methods gives you a more stable MMCE estimate when you repeat them?
    outerKfold <- makeResampleDesc("CV", iters = 5, stratify = TRUE)
    
    kFoldCVWithTuning <- resample(knnWrapper, irisTask,
                                  resampling = outerKfold)
    
    kFoldCVWithTuning
    
    resample(knnWrapper, irisTask, resampling = outerKfold)
    
    # Repeat each validation procedure 10 times and save the mmce value.
    # WARNING: this may take a few minutes to complete.
    
    kSamples <- map_dbl(1:10, ~resample(
      knnWrapper, irisTask, resampling = outerKfold)$aggr
      )
    
    hSamples <- map_dbl(1:10, ~resample(
      knnWrapper, irisTask, resampling = outerHoldout)$aggr
      )
    
    hist(kSamples, xlim = c(0, 0.11))
    hist(hSamples, xlim = c(0, 0.11))
    
    # Holdout CV gives more variable estimates of model performance.
  • Figure 20.3. Holdout cross-validation. The data is randomly split into a training set and a test set. The training set is used to train the model, which is then used to make predictions on the test set. The similarity of the predictions to the true values of the test set is used to evaluate model performance.

    In chapter 3, you learned that an important concept to understand when evaluating model performance is the bias-variance trade-off. As the complexity of a model increases, and the more closely it fits the training set, the more variable its predictions will be on unseen data. Models that are too simple and don’t capture the relationships in the data well are biased toward making consistently poor predictions. As we increase the complexity of our model, its variance will increase, and its bias will decrease; the inverse is also true.

    Practical Data Science with R, Second Edition

    This is an excerpt from Manning's book Practical Data Science with R, Second Edition.

    The null model represents the lower bound on model performance that you should strive for. You can think of the null model as being “the obvious guess” that your model must do better than. In situations where there’s a working model or solution already in place that you’re trying to improve, the null model is the existing solution. In situations where there’s no existing model or solution, the null model is the simplest possible model: for example, always guessing GoodLoan, or always predicting the mean value of the output when you’re trying to predict a numerical value.

    Testing on holdout data, while useful, uses each example only once: either as part of the model construction or as part of the held-out model evaluation set. This is not statistically efficient,[3] because the test set is often much smaller than our whole dataset. This means we are losing some precision in our estimate of model performance by partitioning our data so simply. In our example scenario, suppose you were not able to collect a very large dataset of historical used car prices. Then you might feel that you do not have enough data to split into training and test sets that are large enough to both build good models and evaluate them properly. In this situation, you might choose to use a more thorough partitioning scheme called k-fold cross-validation.

    6.2.2. Measures of model performance

    In this section, we’ll introduce some quantitative measures of model performance. From an evaluation point of view, we group model types this way:

    Listing 11.3. Calculating model performance
    ``` {r}
    rtest <- data.frame(truth = buzztest$buzz,
    pred = predict(fmodel, newdata = buzztest, type = "prob")[, 2, drop = TRUE])
    print(accuracyMeasures(rtest$pred, rtest$truth))
    ```
    
        ## [1] "precision= 0.832402234636871 ; recall= 0.84180790960452"
        ##      pred
        ## truth FALSE TRUE
        ##     0   584   30
        ##     1    28  149
        ##   model  accuracy        f1 dev.norm       AUC
        ## 1 model 0.9266751 0.8370787  0.42056 0.9702102
    Figure 12.19. Showing model performance