You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Rachana Srivastava <Ra...@markmonitor.com> on 2016/01/14 00:29:33 UTC
Random Forest FeatureImportance throwing NullPointerException
I have a Random forest model for which I am trying to get the featureImportance vector.
Map<Object,Object> categoricalFeaturesParam = new HashMap<>();
scala.collection.immutable.Map<Object,Object> categoricalFeatures = (scala.collection.immutable.Map<Object,Object>)
scala.collection.immutable.Map$.MODULE$.apply(JavaConversions.mapAsScalaMap(categoricalFeaturesParam).toSeq());
int numberOfClasses =2;
RandomForestClassifier rfc = new RandomForestClassifier();
RandomForestClassificationModel rfm = RandomForestClassificationModel.fromOld(model, rfc, categoricalFeatures, numberOfClasses);
System.out.println(rfm.featureImportances());
When I run above code I found featureImportance as null. Do I need to set anything in specific to get the feature importance for the random forest model.
Thanks,
Rachana