Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用glmnet逻辑回归获得0和1之间的概率 考虑下面的例子 rm(list=ls(all=T)) 图书馆(ISLR) 图书馆(glmnet) 击球手=不适用。忽略(击球手) #二元proble-Logistic回归 打者$1000,1,0) 击球手$Salary表(击球手$Salary) # 0 1 # 233 30 #cls_R_Logistic Regression_Glmnet - Fatal编程技术网

如何使用glmnet逻辑回归获得0和1之间的概率 考虑下面的例子 rm(list=ls(all=T)) 图书馆(ISLR) 图书馆(glmnet) 击球手=不适用。忽略(击球手) #二元proble-Logistic回归 打者$1000,1,0) 击球手$Salary表(击球手$Salary) # 0 1 # 233 30 #cls

如何使用glmnet逻辑回归获得0和1之间的概率 考虑下面的例子 rm(list=ls(all=T)) 图书馆(ISLR) 图书馆(glmnet) 击球手=不适用。忽略(击球手) #二元proble-Logistic回归 打者$1000,1,0) 击球手$Salary表(击球手$Salary) # 0 1 # 233 30 #cls,r,logistic-regression,glmnet,R,Logistic Regression,Glmnet,在predict调用中,您需要type=“response”参数集。根据文件,它返回拟合概率 pred = predict(fit, s='lambda.min', newx=x_test, type="response") 另外,如果您只是需要分类标签,您可以使用添加s='lambda.min'在我的情况下似乎不起作用,添加s=0.01确实起作用。 pred = predict(fit, s='lambda.min', newx=x_test, type="response")

在predict调用中,您需要
type=“response”
参数集。根据文件,它返回拟合概率

pred = predict(fit, s='lambda.min', newx=x_test, type="response")

另外,如果您只是需要分类标签,您可以使用添加
s='lambda.min'
在我的情况下似乎不起作用,添加
s=0.01
确实起作用。
pred = predict(fit, s='lambda.min', newx=x_test, type="response")