Hi, I tried to develop a RandomForest model for my data in PySpark as follows:
rf_model = RandomForest.trainClassifier(train_idf, 2, {}, numTrees=15, seed=144) print "RF: Num trees = %d, Num nodes = %d\n" %(rf_model.numTrees(), rf_model.totalNumNodes()) pred_label = test_idf.map(lambda p: (float(rf_model.predict(p.features)), p.label)) print pred_label.take(5) ##--------> exception I am getting the following error at the highlighted statement. Exception: It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transforamtion. SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063. I have used the same set of statements for linear models (LogisticRegresssion and SVM) in PySpark and was able to get the predictions abd print them. I am not sure why I am getting the above exception. I am not using the SparkContenxt directly in any of the above statements. I would appreciate your help. thanks -- View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/RandomForest-in-Pyspark-version-1-4-1-tp24103.html Sent from the Apache Spark User List mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@spark.apache.org For additional commands, e-mail: user-h...@spark.apache.org