Intelij
3 |
<span style="font-weight: 400;"> </span><span style="font-weight: 400;">// Split the data into training and test sets (30% held out for testing).</span> |
Eclipse
3 |
Dataset<Row>[] splits = dataset.randomSplit(new double[] { 0.7, 0.3 }); |
Dark Temrinal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
private void applyClassifier(Dataset<Row> dataset) { // Split the data into training and test sets (30% held out for testing). Dataset<Row>[] splits = dataset.randomSplit(new double[] { 0.7, 0.3 }); Dataset<Row> trainingData = splits[0]; Dataset<Row> testData = splits[1]; // Train a DecisionTree model. DecisionTreeClassifier dt = new DecisionTreeClassifier().setLabelCol("indexedLabel") .setFeaturesCol("indexedFeatures"); // Chain indexers and tree in a Pipeline. Pipeline pipeline = new Pipeline().setStages(new PipelineStage[] { dt }); System.out.println("Start Training"); // Train model. This also runs the indexers. PipelineModel model = pipeline.fit(trainingData); // Select (prediction, true label) and compute test error. MulticlassClassificationEvaluator evaluator = new MulticlassClassificationEvaluator() .setLabelCol("indexedLabel").setPredictionCol("prediction").setMetricName("accuracy"); // Make predictions. Dataset<Row> predictions = model.transform(testData); double accuracy = evaluator.evaluate(predictions); System.out.println("Test Error = " + (1.0 - accuracy)); double metrics = evaluator.evaluate(predictions); System.out.println("Accuracy" + ": " + String.valueOf(metrics)); } |
public class HelloWorld {
public static void main (String[] args)
{
// Ausgabe Hello World!
System.out.println("Hello World!");
}
}
Obsidian:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
private void applyClassifier(Dataset<Row> dataset) { // Split the data into training and test sets (30% held out for testing). Dataset<Row>[] splits = dataset.randomSplit(new double[] { 0.7, 0.3 }); Dataset<Row> trainingData = splits[0]; Dataset<Row> testData = splits[1]; // Train a DecisionTree model. DecisionTreeClassifier dt = new DecisionTreeClassifier().setLabelCol("indexedLabel") .setFeaturesCol("indexedFeatures"); // Chain indexers and tree in a Pipeline. Pipeline pipeline = new Pipeline().setStages(new PipelineStage[] { dt }); System.out.println("Start Training"); // Train model. This also runs the indexers. PipelineModel model = pipeline.fit(trainingData); // Select (prediction, true label) and compute test error. MulticlassClassificationEvaluator evaluator = new MulticlassClassificationEvaluator() .setLabelCol("indexedLabel").setPredictionCol("prediction").setMetricName("accuracy"); // Make predictions. Dataset<Row> predictions = model.transform(testData); double accuracy = evaluator.evaluate(predictions); System.out.println("Test Error = " + (1.0 - accuracy)); double metrics = evaluator.evaluate(predictions); System.out.println("Accuracy" + ": " + String.valueOf(metrics)); } |
Arduino Ide:
3 |
Dataset<Row>[] splits = dataset.randomSplit(new double[] { 0.7, 0.3 }); |
3 |
private void applyClassifier(Dataset<Row> dataset) { |