I built a random forest model that yields very poor results and I'm trying to evaluate the model's probabilities of class membership instead of how good it is in classifications.
The data is made up of many predictive features and a target feature (the columns) and the samples (rows). The target feature is binary ( yes / no ). All predictive features are numeric. Only the target feature is catigorical.
This is the model fitting, using the caret
package:
ctrlCV = trainControl(method = 'cv', number = 10 , classProbs = TRUE , savePredictions = TRUE, summaryFunction = twoClassSummary )
rfFit <- train(y~., data = train_set,
importance = TRUE,
method = "rf",
metric="ROC",
trControl = ctrlCV,
tuneLength = 5
)
There is a similar subject I saw here, I took this code from it but it didn't work:
prediction = predict(rfFit, train_set , na.action="na.impute")
BrierScore(as.numeric(train_set$y) - 1, prediction$predicted[, 1L])
This is the error it yields:
Error in na.impute(list(Adipocytes = c(0.0148875691547336, 0.0148875691547336, :
could not find function "na.impute"
How do I calculate the Brier score for such a model ?
EDIT - A sample of the data:
structure(list(response = c("NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "NoResponse", "NoResponse", "NoResponse", "NoResponse",
"NoResponse", "Response", "Response", "Response", "Response",
"Response", "Response", "Response", "Response", "Response", "Response",
"NoResponse"), Adipocytes = c(0.0148875691547336, 0.0148875691547336,
0.0148875691547336, 0.0148875691547336, 0.0213214758191608, 0.0711663970487551,
0.0148875691547336, 0.0148875691547336, 0.0148875691547336, 0.195678965015043,
0.0148875691547336, 0.031597518280539, 0.0210749233513755, 0.0148875691547336,
0.0148875691547336, 0.0148875691547336, 0.0386946286430843, 0.0148875691547336,
0.457259819150423, 0.0148875691547336, 0.0148875691547336, 0.0148875691547336,
0.0148875691547336, 0.023032072529065, 0.0373511495950606, 0.0148875691547336,
0.157860885224959, 0.395127785573274, 0.0148875691547336, 0.117206058831837,
0.0201265559280696, 0.0148875691547336, 0.0148875691547336, 0.0148875691547336,
0.0148875691547336, 0.0148875691547336, 0.0148875691547336, 0.0148875691547336,
0.0148875691547336, 0.0307193488214309, 0.0463334794186272, 0.126003283111471,
0.0148875691547336, 0.0148875691547336, 0.0503553785018031, 0.0148875691547336,
0.0148875691547336, 0.023654425422698, 0.0148875691547336, 0.00301575533285113
), B.cells = c(0.0800057551371177, 0.0376859010636605, 1.23476138825399,
0.169686091992878, 0.0318719603730758, 0.031752160845938, 0.0120156131970648,
0.618090954863207, 0.0573855654207301, 0.201270076200368, 0.0348008563091038,
0.02697257318329, 0.083033553134568, 0.0587037531654018, 0.0120156131970648,
0.0400051010042196, 0.100754967768784, 0.0924894252873105, 0.043296797638842,
0.0120156131970648, 0.018436681190321, 0.0120156131970648, 0.0221023538252602,
0.0371660161819204, 0.12021632580784, 0.0270346525210825, 0.0350567231064043,
0.135118624367071, 0.0645035015441352, 0.0120156131970648, 0.0593102756741702,
0.0370267152338414, 0.0599853534350651, 0.0120156131970648, 0.0494246572280471,
0.0232776770252547, 0.584766970357701, 0.0120156131970648, 0.0448607293071243,
0.0359477973801615, 0.0481903125819609, 0.0120156131970648, 0.0120156131970648,
0.0120156131970648, 0.0120156131970648, 0.0441403932340056, 0.062472410164602,
0.056576445991063, 0.0347151937202121, 0.428724007963313), CD4..memory.T.cells = c(0.053222426779995,
0.00498569417349055, 0.285609459967325, 0.00498569417349055,
0.0133818188350683, 0.00498569417349055, 0.00498569417349055,
0.079643550328675, 0.018577779597057, 0.0591669720162329, 0.00498569417349055,
0.0346796513361763, 0.00498569417349055, 0.00498569417349055,
0.00498569417349055, 0.00498569417349055, 0.0128068287182537,
0.0387932856534556, 0.0106166902578661, 0.00498569417349055,
0.00498569417349055, 0.00498569417349055, 0.00498569417349055,
0.0221443888308076, 0.0384697960774856, 0.00498569417349055,
0.00498569417349055, 0.0353051264006193, 0.0150418989575268,
0.00498569417349055, 0.00498569417349055, 0.00498569417349055,
0.00498569417349055, 0.00498569417349055, 0.0104113831098345,
0.00498569417349055, 0.115449562173739, 0.00498569417349055,
0.00498569417349055, 0.00498569417349055, 0.00498569417349055,
0.00498569417349055, 0.00498569417349055, 0.00498569417349055,
0.00498569417349055, 0.0225942479194889, 0.00498569417349055,
0.0359483855877116, 0.00498569417349055, 0.101333999071329),
CD4..naive.T.cells = c(0.020901284410029, 0.020901284410029,
0.216356106690824, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.0272690699659605,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.05928196459289, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.020901284410029, 0.0307199625074524,
0.020901284410029, 0.020901284410029, 0.020901284410029,
0.020901284410029, 0.0431367056639914), CD4..Tcm = c(0.00836792326030943,
0.00836792326030943, 0.0266310567341346, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.00836792326030943,
0.00836792326030943, 0.00836792326030943, 0.0169971803647614,
-0.0204734455314671), CD4..Tem = c(0.206302749124715, -0.0244639754370864,
0.383601750395274, 0.242753205862255, 0.111328153713519,
-0.0244639754370864, -0.0244639754370864, 0.241512725539202,
0.111071231217901, 0.190558406554486, 0.0383129229978951,
0.0022412336023283, -0.0244639754370864, 0.0346711117924738,
0.00490133880667979, -0.0244639754370864, 0.0955966676796488,
0.216327052965482, 0.0681402041738468, 0.108890303649405,
0.0309347894717559, -0.0244639754370864, 0.0161582022784044,
0.00946526991437974, 0.25444349293939, 0.0716967817511924,
0.0139475994797827, 0.22914061844728, 0.198185709502971,
0.00865385720717036, 0.167278869093713, -0.0183825320496806,
0.0350849726004794, -0.0150080105365044, 0.0531566439902232,
-0.00449122205516312, 0.229384982409473, -0.0244639754370864,
-0.0244639754370864, 0.0545693572660695, -0.00331283339707623,
-0.0244639754370864, 0.00924886188293827, 0.00975290100631425,
-0.0167953556780208, 0.130572694535018, 0.0967256087562913,
0.143433987544022, -0.0244639754370864, -0.0224591675274701
), CD8..T.cells = c(0.0494421812434541, 0.0153720771909336,
0.328623899153089, 0.047123341544761, 0.0399043585541585,
0.0153720771909336, 0.0153720771909336, 0.127964069489891,
0.0275505013045806, 0.0377127445480443, 0.0278609203031339,
0.0153720771909336, 0.0529588569745465, 0.0153720771909336,
0.0153720771909336, 0.0153720771909336, 0.0661779921579517,
0.151158251824574, 0.0153720771909336, 0.0328009642097115,
0.0153720771909336, 0.0153720771909336, 0.0153720771909336,
0.0656077436202632, 0.0353675321661888, 0.0153720771909336,
0.0153720771909336, 0.141924398969414, 0.0873594820276492,
0.0153720771909336, 0.0610798919413866, 0.0153720771909336,
0.0153720771909336, 0.0153720771909336, 0.0257557521848714,
0.0153720771909336, 0.209423182002428, 0.0153720771909336,
0.0153720771909336, 0.0481306539314116, 0.0153720771909336,
0.0153720771909336, 0.0153720771909336, 0.0153720771909336,
0.0153720771909336, 0.0153720771909336, 0.102816726458688,
0.030999206233028, 0.0153720771909336, 0.204491328877077),
CD8..Tcm = c(0.182655282069243, 0.0117462052409156, 0.495215120490835,
0.227880294685582, 0.0698694847307345, 0.0238038922607861,
0.0117462052409156, 0.247847344393474, 0.139818473994039,
0.156670399719073, 0.0196128414307518, 0.0117462052409156,
0.0689481809558008, 0.0242014999089269, 0.0117462052409156,
0.0117462052409156, 0.113544492227536, 0.355698724201404,
0.0266780373934053, 0.0117462052409156, 0.0117462052409156,
0.0117462052409156, 0.0235022694727878, 0.144004767057848,
0.167211701854574, 0.0301097999856445, 0.080556252303148,
0.283560664982896, 0.147464940726628, 0.0192381999158116,
0.141148752440528, 0.0117462052409156, 0.0517643693261223,
0.0117462052409156, 0.0882990671784781, 0.0117462052409156,
0.356308067249892, 0.0117462052409156, 0.0298887060164754,
0.0844591798293132, 0.0465262390088157, 0.0117462052409156,
0.0117462052409156, 0.0205168923809264, 0.0117462052409156,
0.101746427178873, 0.209704179153438, 0.0830545342236262,
0.0117462052409156, 0.26678368565526), Class.switched.memory.B.cells = c(0.0154278203400193,
0.00778932880649851, 0.302227838730229, -0.00231066892896069,
-0.00231066892896069, -0.00231066892896069, -0.00231066892896069,
0.148842253393486, 0.018778759533204, 0.0898876156071992,
0.0201233633505071, 0.0221733171102808, 0.0214641801215066,
-0.00231066892896069, -0.00231066892896069, -0.00231066892896069,
-0.00231066892896069, 0.0712514966558366, 0.0101921500375092,
0.00953688941379467, -0.00231066892896069, -0.00231066892896069,
-0.00231066892896069, 0.00559918348827802, 0.0654889081665769,
0.0205563942162596, -0.00231066892896069, 0.0318000693656408,
-0.00231066892896069, 0.0232386635787137, 0.0162856041653171,
-0.00231066892896069, 0.0300686782099929, -0.00231066892896069,
-0.00231066892896069, -0.00231066892896069, 0.134260586988978,
-0.00231066892896069, -0.00231066892896069, -0.00231066892896069,
-0.00231066892896069, 0.00380814505188035, 0.0150252067990864,
0.0608010413803588, -0.00231066892896069, -0.00231066892896069,
-0.00231066892896069, 0.00311225914281913, 0.00773503495835955,
0.103793499371134), DC = c(0.062858927374447, -0.00157027191007548,
0.0491499387582655, 0.131563704962779, 0.00976038525278434,
0.0740363133877171, -0.00157027191007548, 0.0334247652293954,
0.017894340214428, 0.030439379583282, 0.00761730816714917,
-0.00157027191007548, 0.0151466295174413, 0.0297754282391564,
0.0067404510395591, -0.00157027191007548, 0.0462874051801632,
0.0328917267552703, 0.0687751392609319, 0.0387877001182527,
-0.00157027191007548, -0.00157027191007548, -0.00157027191007548,
0.0520816557349031, 0.0625494571602841, 0.0706355004446451,
0.0272684889182969, 0.0725509330002818, 0.0107631059573476,
0.009204296428937, 0.039634588278359, -0.00157027191007548,
0.0135112531085166, 0.00862495276532101, -0.00157027191007548,
-0.00157027191007548, 0.0573993499097638, -0.00157027191007548,
-0.00157027191007548, 0.0289341561422192, 0.0193173718440713,
-0.00157027191007548, -0.00157027191007548, 0.0157651995699005,
0.0197454477651669, 0.07226644705888, 0.0367330767543925,
0.0168560525366573, -0.00157027191007548, 0.0125106374064303
), Eosinophils = c(0.00203350395818403, -0.00513306460276474,
0.0193546103291045, -0.00513306460276474, -0.00513306460276474,
-0.00513306460276474, -0.00513306460276474, 0.0669363329519432,
-0.00513306460276474, 0.00752583023074009, -0.00513306460276474,
0.0321429327736095, -0.00513306460276474, -0.00513306460276474,
-0.00513306460276474, -0.00513306460276474, -0.00513306460276474,
0.0397050656315528, 0.0136397820218079, 0.00131659974331692,
0.0027710771316982, -0.00513306460276474, -0.00513306460276474,
-0.00513306460276474, -0.00513306460276474, -0.00513306460276474,
0.000860123203078086, -0.00513306460276474, 0.00127759700392978,
0.00140233894838766, 0.00321693253506162, -0.00513306460276474,
-0.00513306460276474, -0.00513306460276474, 0.00235993780568866,
-0.00513306460276474, 0.00510952967006255, -0.00513306460276474,
0.00105592699141208, 0.000801671659317727, 0.0144008770887672,
-0.00513306460276474, -0.00513306460276474, 0.0184714491021452,
-0.00513306460276474, -0.00513306460276474, -0.00513306460276474,
0.0139325163221551, 0.00146984998387666, -0.00457158372125087
), Fibroblasts = c(0.117552680782007, 0.143756425262346,
0.109626696263205, 0.314530973382078, 0.28909098520659, 0.104495463653684,
0.254460081984213, 0.0990444041072488, 0.218292210655419,
0.280641610277368, 0.153482104053917, 0.108680452857488,
0.178688100844781, 0.191991739756879, 0.120209244912694,
0.110381577944953, 0.27755472545994, 0.240766255508157, 0.473966461223323,
0.199285187835139, 0.181992922154544, 0.254707722989717,
0.14334132750358, 0.265326164460366, 0.344790199060847, 0.191655701024498,
0.205052745010361, 0.290044964563019, 0.0935189113224119,
0.236758027474316, 0.203696962917397, 0.153718200997139,
0.164157082777622, 0.116272308304605, 0.103943706108928,
0.0935189113224119, 0.236344115551931, 0.170883236535753,
0.141869052373999, 0.289138127524291, 0.229046323956004,
0.339614115033585, 0.140962944183055, 0.220272844717841,
0.177302974786942, 0.0935189113224119, 0.256734959611151,
0.223781672761716, 0.197495962363125, -0.0555466171957452
), Hepatocytes = c(0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0283051081094157, 0.0216226440735431,
0.027225448286286, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.482243001193291, 0.0216226440735431, 0.0216226440735431,
0.358862707585874, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.039040887979119,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.11408346667815,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0216226440735431,
0.0216226440735431, 0.0216226440735431, 0.0149773950899646
), ly.Endothelial.cells = c(0.0166411831489929, 0.0166411831489929,
0.0347756518348397, 0.0533549270947112, 0.0319012352481457,
0.0166411831489929, 0.0166411831489929, 0.0390436796950553,
0.0321905606146469, 0.0517365585557776, 0.0166411831489929,
0.0166411831489929, 0.0166411831489929, 0.0166411831489929,
0.0166411831489929, 0.0166411831489929, 0.0281967723988932,
0.0166411831489929, 0.126460416535433, 0.0166411831489929,
0.0166411831489929, 0.0166411831489929, 0.0166411831489929,
0.0166411831489929, 0.0411609219065621, 0.0166411831489929,
0.0494280729154472, 0.0995281169010334, 0.0166411831489929,
0.0232397214310027, 0.0264444078129541, 0.0166411831489929,
0.0166411831489929, 0.0166411831489929, 0.0166411831489929,
0.0166411831489929, 0.0632255860984502, 0.0223371324350743,
0.0166411831489929, 0.0381409123497947, 0.0166411831489929,
0.0166411831489929, 0.0166411831489929, 0.0579165289705117,
0.0166411831489929, 0.0166411831489929, 0.0389383046357601,
0.0746421132626324, 0.0166411831489929, -0.0510045740152101
), Macrophages.M1 = c(0.0939027028913093, 0.00991806048158322,
0.0307250297361532, 0.111143332595117, 0.0292284276226276,
0.0381839764683231, 0.0103302886442727, 0.0398979819807463,
0.105491423751765, 0.150250611917613, 0.00272760279247674,
0.030352141019262, 0.019100544774407, 0.0481314865500234,
0.0204723732124283, 0.00838577053175601, 0.0212662830801156,
0.176020297845548, 0.00272760279247674, 0.00997760514093038,
0.0178614585003549, 0.00272760279247674, 0.0138362702729734,
0.0385921702605774, 0.154611609585058, 0.0355816943811817,
0.0429897179271763, 0.06341462292347, 0.0376788779822781,
0.0424460141081865, 0.118451043972679, 0.0104964633803846,
0.0616039925956695, 0.0189581728968219, 0.0131898549270135,
0.0227127506572289, 0.0501975621261345, 0.00272760279247674,
0.00877120965369497, 0.0422300236889794, 0.0431469259855728,
0.00272760279247674, 0.0141554863447003, 0.0166436263190985,
0.0298201923666392, 0.0481122432136814, 0.0842495692975132,
0.0435379661848463, 0.0304321030763242, 0.0858878607975676
), Macrophages.M2 = c(0.0950370387250134, 0.0341021814039373,
0.0129080389068132, 0.136032292676889, 0.0500615096525892,
0.0261538120522582, 0.0262035916343674, 0.0379314707513149,
0.0634308346430593, 0.229510962749818, 0.0129080389068132,
0.0397807872973065, 0.031996379798556, 0.0490437826861079,
0.0129080389068132, 0.0129080389068132, 0.0479132930965825,
0.179068336862642, 0.167470177529083, 0.0210840359218022,
0.0247881531036544, 0.0129080389068132, 0.0241373555223528,
0.0129080389068132, 0.220088283054851, 0.0363913474266373,
0.102746064255281, 0.0568930515962548, 0.0730618463614969,
0.0190480628578201, 0.140445976081207, 0.0414388510084821,
0.0182236555221719, 0.0181665441709514, 0.0129080389068132,
0.0269146240316719, 0.0129080389068132, 0.0129080389068132,
0.0129080389068132, 0.031739051141187, 0.0643613066122741,
0.0263740661987764, 0.0129080389068132, 0.0129080389068132,
0.0129080389068132, 0.0359960508390566, 0.0276881038962302,
0.0880892425295165, 0.0486983682712236, 0.0819337135938423
), Mast.cells = c(0.00262272709651714, 0.00918956479724631,
0.0237863628013975, 0.0120882313148399, 0.00262272709651714,
0.00262272709651714, 0.0132078489828078, 0.00262272709651714,
0.00925484950428775, 0.0148295850584796, 0.0216140469381388,
0.0201444625393507, 0.00262272709651714, 0.00262272709651714,
0.00262272709651714, 0.00262272709651714, 0.00262272709651714,
0.0177982493490349, 0.0399020678006343, 0.00262272709651714,
0.0127350032738263, 0.010122250042933, 0.00262272709651714,
0.00262272709651714, 0.0560153757178254, 0.00262272709651714,
0.00262272709651714, 0.00262272709651714, 0.00262272709651714,
0.00262272709651714, 0.0100042201637379, 0.00262272709651714,
0.00262272709651714, 0.00262272709651714, 0.00262272709651714,
0.00262272709651714, 0.00262272709651714, 0.00262272709651714,
0.00262272709651714, 0.00262272709651714, 0.00262272709651714,
0.00966452021833436, 0.00262272709651714, 0.0162426439532491,
0.00262272709651714, 0.00262272709651714, 0.00882907219428391,
0.00262272709651714, 0.00936334626318404, 0.0325805463741492
), Melanocytes = c(0.197208530782834, 0.117972703910268,
-0.0602878219630949, 0.0094514247329539, 0.0720302427467801,
0.0535616550191451, 0.147656564458396, 0.00506865434571719,
0.0506729519536773, -0.0602878219630949, 0.171976680921397,
0.0391064859618761, 0.138335210852028, 0.0204085278110901,
0.166543177510308, 0.0391339248224207, -0.00585060388562906,
0.0907762414421459, -0.0602878219630949, 0.0942830836322463,
0.0722107746330366, 0.0489720312042079, 0.0101547247380102,
-0.0323689704172642, -0.0602878219630949, 0.0302364995883101,
-0.0164214064240953, 0.119210025484646, 0.125847753429396,
-0.0179013729637403, 0.0883487098541815, 0.111938605148703,
0.14062692562277, 0.126009766715894, 0.0090037910293348,
0.0714671785039881, -0.0142319167468624, 0.0692781943357738,
0.099402208705842, 0.04947201823059, 0.130279017998432, 0.136333775892651,
0.0607280725769218, 0.00232142515516216, -0.0602878219630949,
0.122589465900189, 0.0462738574752271, 0.131398436138857,
0.124808922845939, 0.0286661474012692), naive.B.cells = c(-0.00189298072743305,
-0.00189298072743305, 0.131760794411808, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
0.0576111720143354, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, 0.0356853961207387,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
-0.00189298072743305, -0.00189298072743305, -0.00189298072743305,
0.0789824945659587)), row.names = c("Pt1", "Pt10", "Pt101",
"Pt103", "Pt106", "Pt11", "Pt17", "Pt18", "Pt2", "Pt24", "Pt26",
"Pt27", "Pt28", "Pt29", "Pt3", "Pt30", "Pt31", "Pt34", "Pt36",
"Pt37", "Pt38", "Pt39", "Pt4", "Pt44", "Pt46", "Pt47", "Pt48",
"Pt49", "Pt5", "Pt52", "Pt59", "Pt62", "Pt65", "Pt66", "Pt67",
"Pt72", "Pt77", "Pt78", "Pt79", "Pt8", "Pt82", "Pt84", "Pt85",
"Pt89", "Pt9", "Pt90", "Pt92", "Pt94", "Pt98", "EA595454"), class = "data.frame")
CodePudding user response:
Your code will work if you make 2 changes
- You have to calculate the predicted probability and
- Convert the observations to 0 and 1 like
library(caret)
library(DescTools)
prediction = predict(rfFit, train_set, type = "prob")
BrierScore(prediction[,1], ifelse(train_set$response == "Response", 1, 0))
#> [1] 0.86336