Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Predictionio random forest

Shulou Source: shulou.com Published: 2022-06-03 04:42:39 11月14日 Update

In fact, predictionio also supports random forest algorithm. Unfortunately, there is no official example. I briefly wrote a point. You can also refer to this address:

Https://github.com/runapal5/PredictionIO-DefectPrediction/blob/master/engine.json

Public class RandomForestAlgorithm extends P2LJavaAlgorithm {/ * / private static final long serialVersionUID = 1L; private final RandomForestAlgorithmParams ap; public RandomForestAlgorithm (RandomForestAlgorithmParams ap) {this.ap = ap;} @ Override public RandomForestModel train (SparkContext sc, PreparedData preparedData) {String datapath = "/ root/whk/company.txt"; JavaRDD treedata = MLUtils.loadLibSVMFile (sc, datapath). ToJavaRDD (); Map categoricalFeaturesInfo = new HashMap () Return RandomForest.trainClassifier (treedata, ap.getNumClasses (), categoricalFeaturesInfo, ap.getNumTrees (), ap.getFeatureSubsetStrategy (), ap.getImpurity (), ap.getMaxDepth (), ap.getMaxBins (), 12345);} @ Override public PredictedResult predict (RandomForestModel model, final Query query) {double [] b = {12Power0}; model.predict (Vectors.dense (b)) Return null;}}

Tags: Forest example address official algorithm reference support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS Docker Microsoft Linux