PySpark を使用してトレーニングしたランダム フォレスト オブジェクトの機能の重要度を抽出しようとしています。ただし、ドキュメントのどこにもこれを行う例は見当たりませんし、RandomForestModel のメソッドでもありません。
RandomForestModel
PySpark のリグレッサーまたは分類子から機能の重要度を抽出するにはどうすればよいですか?
ドキュメントで提供されているサンプル コードを次に示します。ただし、機能の重要性については言及されていません。
from pyspark.mllib.tree import RandomForest
from pyspark.mllib.util import MLUtils
# Load and parse the data file into an RDD of LabeledPoint.
data = MLUtils.loadLibSVMFile(sc, 'data/mllib/sample_libsvm_data.txt')
# Split the data into training and test sets (30% held out for testing)
(trainingData, testData) = data.randomSplit([0.7, 0.3])
# Train a RandomForest model.
# Empty categoricalFeaturesInfo indicates all features are continuous.
# Note: Use larger numTrees in practice.
# Setting featureSubsetStrategy="auto" lets the algorithm choose.
model = RandomForest.trainClassifier(trainingData, numClasses=2, categoricalFeaturesInfo={},
numTrees=3, featureSubsetStrategy="auto",
impurity='gini', maxDepth=4, maxBins=32)
利用可能な属性が表示されませんmodel.__featureImportances_
-- どこで確認できますか?