本文实例为大家分享了基于Spark实现随机森林的具体代码,供大家参考,具体内容如下
public class RandomForestClassficationTest extends TestCase implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 7802523720751354318L;
class PredictResult implements Serializable{
/**
*
*/
private static final long serialVersionUID = -168308887976477219L;
double label;
double prediction;
public PredictResult(double label,double prediction){
this.label = label;
this.prediction = prediction;
}
@Override
public String toString(){
return this.label + " : " + this.prediction ;
}
}
public void test_randomForest() throws JAXBException{
SparkConf sparkConf = new SparkConf();
spa