make predictions from a "plus" object. This function makes predictions from plus object. Is in essence a cross-validated glmnet model, optimized with the plus algorithm. It use the optimal value chosen for lambda for a fit.
predict.plus.Rdmake predictions from a "plus" object.
This function makes predictions from plus object. Is in essence a cross-validated glmnet model,
optimized with the plus algorithm. It use the optimal value chosen for
lambda for a fit.
Usage
# S3 method for class 'plus'
predict(object, ..., newx = NULL, s = "lambda.min", type = "response")Arguments
- object
Fitted
"pluse"object.- ...
additional predict arguments
- newx
Matrix of new values for
xat which predictions are to be made. Must be a matrix; can be sparse as inMatrixpackage.- s
Value(s) of the penalty parameter
lambdaat which predictions are required. Default is the values="lambda.min"stored on the CVobject. Alternativelys="lambda.1se"can be used. Ifsis numeric, it is taken as the value(s) oflambdato be used. (For historical reasons we use the symbol 's' rather than 'lambda' to reference this parameter)- type
Type of prediction required. Type
"link"gives the linear predictors for"binomial". Type"response"gives the fitted probabilities for"binomial". Type"coefficients"computes the coefficients at the requested values fors. Type"class"produces the class label corresponding to the maximum probability. Type"nonzero"returns a list of the indices of the nonzero coefficients for each value ofs.
Examples
x_train <- matrix(rnorm(650 * 20), 650, 20)
x_test <- matrix(rnorm(350 * 20), 350, 20)
y_train <- ifelse(rnorm(650) > 0, 1, 0)
y_test <- ifelse(rnorm(350) > 0, 1, 0)
fit <- plus(x_train, y_train)
predict(fit, newx = x_test)
#> lambda.min
#> [1,] 0.99952688
#> [2,] 0.99826664
#> [3,] 0.95006667
#> [4,] 0.95408550
#> [5,] 0.71817550
#> [6,] 0.89609004
#> [7,] 0.99066159
#> [8,] 0.96628925
#> [9,] 0.99340019
#> [10,] 0.89908171
#> [11,] 0.99970437
#> [12,] 0.97181588
#> [13,] 0.90034216
#> [14,] 0.99425173
#> [15,] 0.70545914
#> [16,] 0.99853546
#> [17,] 0.99358192
#> [18,] 0.99219259
#> [19,] 0.99867484
#> [20,] 0.99869853
#> [21,] 0.98317854
#> [22,] 0.94518625
#> [23,] 0.99901150
#> [24,] 0.99140267
#> [25,] 0.86243051
#> [26,] 0.50564842
#> [27,] 0.96677281
#> [28,] 0.97897547
#> [29,] 0.99916021
#> [30,] 0.99282488
#> [31,] 0.95951688
#> [32,] 0.99737830
#> [33,] 0.99891396
#> [34,] 0.98475789
#> [35,] 0.99686883
#> [36,] 0.99977459
#> [37,] 0.99695951
#> [38,] 0.98872125
#> [39,] 0.99028407
#> [40,] 0.99996358
#> [41,] 0.99511237
#> [42,] 0.93124240
#> [43,] 0.99980979
#> [44,] 0.93138922
#> [45,] 0.96360917
#> [46,] 0.99603767
#> [47,] 0.99763972
#> [48,] 0.99889812
#> [49,] 0.99600753
#> [50,] 0.99775637
#> [51,] 0.98336897
#> [52,] 0.99974126
#> [53,] 0.54136471
#> [54,] 0.99264691
#> [55,] 0.99978732
#> [56,] 0.99969805
#> [57,] 0.97989975
#> [58,] 0.76049786
#> [59,] 0.76838942
#> [60,] 0.99663569
#> [61,] 0.99956113
#> [62,] 0.99262608
#> [63,] 0.99898344
#> [64,] 0.97011922
#> [65,] 0.98000019
#> [66,] 0.99906340
#> [67,] 0.61388953
#> [68,] 0.42845272
#> [69,] 0.58235109
#> [70,] 0.17787084
#> [71,] 0.94924514
#> [72,] 0.97601335
#> [73,] 0.85540157
#> [74,] 0.94279957
#> [75,] 0.99995642
#> [76,] 0.99414270
#> [77,] 0.98713214
#> [78,] 0.96555134
#> [79,] 0.91473442
#> [80,] 0.99305563
#> [81,] 0.93998815
#> [82,] 0.95567028
#> [83,] 0.91668182
#> [84,] 0.32032820
#> [85,] 0.99951421
#> [86,] 0.96518709
#> [87,] 0.98121623
#> [88,] 0.99856677
#> [89,] 0.98085392
#> [90,] 0.96604918
#> [91,] 0.97775515
#> [92,] 0.98816123
#> [93,] 0.99997147
#> [94,] 0.99872526
#> [95,] 0.98359881
#> [96,] 0.99666474
#> [97,] 0.99958109
#> [98,] 0.99597047
#> [99,] 0.99811515
#> [100,] 0.99815056
#> [101,] 0.99491783
#> [102,] 0.98643041
#> [103,] 0.95900408
#> [104,] 0.97619264
#> [105,] 0.99995984
#> [106,] 0.64362195
#> [107,] 0.99574357
#> [108,] 0.99987474
#> [109,] 0.96875728
#> [110,] 0.99937556
#> [111,] 0.99679332
#> [112,] 0.99731787
#> [113,] 0.76999700
#> [114,] 0.99909478
#> [115,] 0.99929260
#> [116,] 0.91688338
#> [117,] 0.99965931
#> [118,] 0.97775223
#> [119,] 0.94278448
#> [120,] 0.92666775
#> [121,] 0.99297383
#> [122,] 0.95244134
#> [123,] 0.95963912
#> [124,] 0.99632934
#> [125,] 0.99898392
#> [126,] 0.99807155
#> [127,] 0.94932098
#> [128,] 0.95111277
#> [129,] 0.61171076
#> [130,] 0.99790983
#> [131,] 0.99723203
#> [132,] 0.99812305
#> [133,] 0.98093352
#> [134,] 0.99450681
#> [135,] 0.95048557
#> [136,] 0.99701031
#> [137,] 0.98412315
#> [138,] 0.99918571
#> [139,] 0.96697211
#> [140,] 0.98225582
#> [141,] 0.78693206
#> [142,] 0.99811540
#> [143,] 0.98417046
#> [144,] 0.99974259
#> [145,] 0.97705355
#> [146,] 0.99981629
#> [147,] 0.97537563
#> [148,] 0.98749056
#> [149,] 0.89751945
#> [150,] 0.77991172
#> [151,] 0.99870850
#> [152,] 0.96519822
#> [153,] 0.98314147
#> [154,] 0.99994703
#> [155,] 0.79334085
#> [156,] 0.99050589
#> [157,] 0.94017980
#> [158,] 0.92064246
#> [159,] 0.97133130
#> [160,] 0.96550175
#> [161,] 0.99942323
#> [162,] 0.99106654
#> [163,] 0.85042749
#> [164,] 0.99844548
#> [165,] 0.98560762
#> [166,] 0.95655732
#> [167,] 0.85308287
#> [168,] 0.86856762
#> [169,] 0.98852334
#> [170,] 0.99513051
#> [171,] 0.97395070
#> [172,] 0.76870274
#> [173,] 0.97592998
#> [174,] 0.83532760
#> [175,] 0.99795539
#> [176,] 0.98678196
#> [177,] 0.99766038
#> [178,] 0.98433235
#> [179,] 0.98785907
#> [180,] 0.99921375
#> [181,] 0.99231339
#> [182,] 0.99988160
#> [183,] 0.90385970
#> [184,] 0.99922867
#> [185,] 0.99969456
#> [186,] 0.99931265
#> [187,] 0.99710261
#> [188,] 0.95600929
#> [189,] 0.99995475
#> [190,] 0.99675496
#> [191,] 0.96734902
#> [192,] 0.99918515
#> [193,] 0.99914631
#> [194,] 0.99825279
#> [195,] 0.99709456
#> [196,] 0.99960886
#> [197,] 0.98998941
#> [198,] 0.94352077
#> [199,] 0.99650393
#> [200,] 0.99578906
#> [201,] 0.99678527
#> [202,] 0.97418221
#> [203,] 0.99970727
#> [204,] 0.99957919
#> [205,] 0.93482878
#> [206,] 0.76034766
#> [207,] 0.99512727
#> [208,] 0.83108808
#> [209,] 0.97475777
#> [210,] 0.99885394
#> [211,] 0.96940475
#> [212,] 0.50633332
#> [213,] 0.97468437
#> [214,] 0.74178011
#> [215,] 0.93023632
#> [216,] 0.99639896
#> [217,] 0.84276190
#> [218,] 0.73760967
#> [219,] 0.94958557
#> [220,] 0.97246948
#> [221,] 0.99254430
#> [222,] 0.99987922
#> [223,] 0.99404677
#> [224,] 0.97222457
#> [225,] 0.99753704
#> [226,] 0.98601106
#> [227,] 0.99830249
#> [228,] 0.30401943
#> [229,] 0.92915199
#> [230,] 0.92882947
#> [231,] 0.99945105
#> [232,] 0.92208940
#> [233,] 0.95633399
#> [234,] 0.83717869
#> [235,] 0.99755945
#> [236,] 0.98745110
#> [237,] 0.78198311
#> [238,] 0.21784407
#> [239,] 0.92960626
#> [240,] 0.99317548
#> [241,] 0.98434815
#> [242,] 0.99868666
#> [243,] 0.99988135
#> [244,] 0.99978976
#> [245,] 0.99936589
#> [246,] 0.99985987
#> [247,] 0.66806612
#> [248,] 0.99807737
#> [249,] 0.76559395
#> [250,] 0.99851426
#> [251,] 0.99754203
#> [252,] 0.88907728
#> [253,] 0.99792427
#> [254,] 0.96840606
#> [255,] 0.89526065
#> [256,] 0.99360293
#> [257,] 0.99688451
#> [258,] 0.99880777
#> [259,] 0.99974118
#> [260,] 0.99666081
#> [261,] 0.99845657
#> [262,] 0.09618411
#> [263,] 0.22931346
#> [264,] 0.95812667
#> [265,] 0.99912091
#> [266,] 0.99578815
#> [267,] 0.99362551
#> [268,] 0.97764002
#> [269,] 0.99693501
#> [270,] 0.94507123
#> [271,] 0.99822979
#> [272,] 0.85636571
#> [273,] 0.99942969
#> [274,] 0.91371961
#> [275,] 0.96774398
#> [276,] 0.97233105
#> [277,] 0.98993314
#> [278,] 0.88569875
#> [279,] 0.99530879
#> [280,] 0.99009183
#> [281,] 0.99778638
#> [282,] 0.99717528
#> [283,] 0.99934641
#> [284,] 0.99954991
#> [285,] 0.21972814
#> [286,] 0.99896707
#> [287,] 0.96313421
#> [288,] 0.90622200
#> [289,] 0.99528009
#> [290,] 0.96172928
#> [291,] 0.17269413
#> [292,] 0.97054428
#> [293,] 0.99880073
#> [294,] 0.99999626
#> [295,] 0.94741665
#> [296,] 0.72187687
#> [297,] 0.98762390
#> [298,] 0.99995701
#> [299,] 0.99708484
#> [300,] 0.96248305
#> [301,] 0.98689566
#> [302,] 0.98587360
#> [303,] 0.86565631
#> [304,] 0.99966012
#> [305,] 0.99940706
#> [306,] 0.99871854
#> [307,] 0.99954578
#> [308,] 0.99836199
#> [309,] 0.91849776
#> [310,] 0.73476504
#> [311,] 0.99406814
#> [312,] 0.92795013
#> [313,] 0.67537222
#> [314,] 0.99151402
#> [315,] 0.99113571
#> [316,] 0.95920725
#> [317,] 0.99296582
#> [318,] 0.99319628
#> [319,] 0.98438150
#> [320,] 0.92271889
#> [321,] 0.96593515
#> [322,] 0.99976780
#> [323,] 0.86503618
#> [324,] 0.98315742
#> [325,] 0.99598690
#> [326,] 0.69953989
#> [327,] 0.92173317
#> [328,] 0.97251600
#> [329,] 0.99287675
#> [330,] 0.97909391
#> [331,] 0.77404907
#> [332,] 0.91890130
#> [333,] 0.97930669
#> [334,] 0.99502326
#> [335,] 0.89671826
#> [336,] 0.99818825
#> [337,] 0.97811442
#> [338,] 0.97606178
#> [339,] 0.98466123
#> [340,] 0.95461697
#> [341,] 0.99830894
#> [342,] 0.99970804
#> [343,] 0.97847242
#> [344,] 0.99330472
#> [345,] 0.99833108
#> [346,] 0.99832307
#> [347,] 0.83594783
#> [348,] 0.90259346
#> [349,] 0.88736396
#> [350,] 0.99549423