R の回帰にglmentパッケージを使用しcv.fit<-cv.glmnet(x,y,...)
ていcvfit$lambda.min
ます。MSE
しかし、そのラムダに対応する(平均二乗誤差)も取得したいと思います。誰かがそれを手に入れるのを手伝ってくれますか?
13007 次
2 に答える
9
から?cv.glmnet
:
# ...
# Value:
#
# an object of class ‘"cv.glmnet"’ is returned, which is a list with
# the ingredients of the cross-validation fit.
#
# lambda: the values of ‘lambda’ used in the fits.
#
# cvm: The mean cross-validated error - a vector of length
# ‘length(lambda)’.
# ...
したがって、あなたの場合、交差検証された平均二乗誤差は にcv.fit$cvm
あり、対応するラムダ値は にありcv.fit$lambda
ます。
最小 MSE を見つけるにはwhich
、次のように使用できます。
i <- which(cv.fit$lambda == cv.fit$lambda.min)
mse.min <- cv.fit$cvm[i]
またはそれより短い
mse.min <- cv.fit$cvm[cv.fit$lambda == cv.fit$lambda.min]
于 2014-06-03T20:51:59.267 に答える
4
損失関数「mse」で glmnet を実行している場合、最小ラムダは最小 MSE を表します。したがって、次の方法で簡単に見つけることができます。
mse.min <- min(cv.fit$cvm)
于 2014-12-02T04:35:53.053 に答える