今回はcaretパッケージの調査です。 機械学習、予測全般のモデル作成とかモデルの評価が入っているパッケージのようです。 多くの関数があるので、調査したものから並べていきます。 varImp 予測モデルを作ったときの、変数の重要度を計算する。 次のプログラムでは、花びらの長さなどの4変数を用いて、あやめの種類をk-近傍法で予測した場合に、どの変数が重要なのかを種類別に計算したもの。 #------irisデータで変数の重要度を計算 data(iris) TrainData <- iris[,1:4] TrainClasses <- iris[,5] knnFit <- train(TrainData, TrainClasses, "knn") knnImp <- varImp(knnFit) dotPlot(knnImp) 最後のdotplotで図を描いてくれるのですが、見づらいので自作プ