machine learning - How to increase the accuracy of neural network model in spark? -
import org.apache.spark.ml.classification.multilayerperceptronclassifier import org.apache.spark.ml.evaluation.multiclassclassificationevaluator import org.apache.spark.mllib.util.mlutils import org.apache.spark.sql.row // load training data val data = mlutils.loadlibsvmfile(sc,"/home/.../neural.txt").todf() val splits = data.randomsplit(array(0.6, 0.4), seed = 1234l) val train = splits(0) val test = splits(1) val layers = array[int](4, 5, 4, 4) val trainer = new multilayerperceptronclassifier().setlayers(layers).setblocksize(128).setseed(1234l).setmaxiter(100) val model = trainer.fit(train) // compute precision on test set val result = model.transform(test) val predictionandlabels = result.select("prediction", "label") val evaluator = new multiclassclassificationevaluator().setmetricname("precision") println("precision:" + evaluator.evaluate(predictionandlabels))
i using multilayerperceptronclassifier build neural network in spark. getting 62.5% of accuracy. parameters should change accuracy?
as people has said , question broad , cant answered without more detail advice(independently of models/altorithms used or tools , libraries implementing them) be:
- use cross validation set , perform cross validation different network architectures.
- plot "learning curves"
- identify if having high bias or high variance
- see if can or need apply feature scaling and/or normalization.
- do "error analysis"(manually verify examples failed , evaluate or categorize them see if can find pattern)
not neccesarily in order, identify if have underfitting, overfitting, if need more training data, add or remove features, add regularization, etc. in summary , perform machine learning debugging.
hope helps, can find more deep details in andrew ngs series of videos, starting this: https://www.youtube.com/watch?v=qiflzaa32h0
Comments
Post a Comment