18 mar 2020

Tidyverse and Chemometrics (part 17): Selecting samples for monitoring

Now we can select the samples manually from the scores maps using the identify funtion, so we vcan enlarge the maps and select the samples we consider that cupture the structure of the new population and at the same time expand the calibration.

These are  the views for the samples wher the blue ones are the samples from the seasons 1 and 2, the ones used for the calculation of the principal components. The red ones and green ones are the projected samples of Fish3 season, beeing the red ones the selected ones to send to the laboratory for the calculation of "dry matter", "protein", "fat" and "ash".

Now we process these selected sample by the model to get the predictions.

library(caret)
fish3_caret_prot_pred<-predict(model_fish12_prot_pls,

                               ncomp=10,
                               newdata =fish3_sel_df )
fish3_caret_dm_pred<-predict(model_fish12_dm_pls,ç

                             ncomp=10,
                             newdata =fish3_sel_df )
fish3_caret_fat_pred<-predict(model_fish12_fat_pls,

                              ncomp=4,
                              newdata =fish3_sel_df )
fish3_caret_ash_pred<-predict(model_fish12_ash_pls,

                              ncomp=10,
                              newdata =fish3_sel_df ) 

Ans finally we create a dataframe with the predicted and reference values to check the performance of the predictions. 

> fish3_selected_monitor
   Sample Month Year    DM PROTEIN   FAT   ASH DM_PRED PROT_PRED FAT_PRED ASH_PRED
7     7F2    12 1991 93.57   70.90 10.66 18.34   93.95     71.93     9.67    16.68
8     8F2    12 1991 94.25      NA    NA    NA   94.56     75.94    10.22    13.13
9     9F2    12 1991 94.01   75.05  9.83 14.90   94.41     75.74     9.19    14.03
11   11F2    12 1991 93.60   75.35 11.53 12.91   93.84     77.20    10.89    11.17
12   12F2    12 1991 93.68   71.14 11.50 16.93   93.97     72.40    10.87    15.98
13   13F2    12 1991 93.44   70.15 10.77 17.16   93.67     72.21    10.29    16.06
16   16F2    12 1991 92.89   70.70 12.22 16.86   93.25     71.27    11.14    16.66
17   17F2    12 1991 94.66   71.71 10.94 16.72   94.73     74.51    10.34    15.38
18   18F2    12 1991 93.27   72.81 10.49 16.06   93.44     74.84     9.60    14.82
23   23F2    12 1991 93.96   73.76 10.37 15.45   94.39     74.62    10.23    15.47
27   27F2    12 1991 93.41   66.88  9.37 22.79   93.84     66.99     8.05    22.22
28   28F2    12 1991 94.11   77.25 11.96 10.16   94.34     78.92    11.54    10.18
29   29F2    12 1991 93.16   68.53 11.28 20.09   93.76     70.97    10.27    18.75
33   33F2    12 1991 94.33   78.06 11.50 10.86   94.72     78.70    11.63    10.55
34   34F2    12 1991 93.72   65.04  9.35 25.08   94.08     66.04     8.40    23.49
36   36F2    12 1991 94.18   64.49  9.17 26.03   94.57     64.41     8.16    25.56
38   38F2    12 1991 92.65   63.69 10.24 25.11   93.10     64.09     8.88    24.41
  

No hay comentarios:

Publicar un comentario