Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.classification;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -28,11 +30,12 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;

public class JavaDecisionTreeClassifierSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -62,18 +65,15 @@ public void runDT() {
model.depth();
model.toDebugString();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model3.save(sc.sc(), path);
model.save(path);
DecisionTreeClassificationModel sameModel =
DecisionTreeClassificationModel.load(sc.sc(), path);
TreeTests.checkEqual(model3, sameModel);
DecisionTreeClassificationModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.classification;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -28,11 +30,12 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;

public class JavaGBTClassifierSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -67,17 +70,14 @@ public void runDT() {
model.trees();
model.treeWeights();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model3.save(sc.sc(), path);
GBTClassificationModel sameModel = GBTClassificationModel.load(sc.sc(), path);
TreeTests.checkEqual(model3, sameModel);
model.save(path);
GBTClassificationModel sameModel = GBTClassificationModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.classification;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -30,11 +32,12 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;

public class JavaRandomForestClassifierSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -86,18 +89,15 @@ public void runDT() {
model.treeWeights();
Vector importances = model.featureImportances();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model3.save(sc.sc(), path);
model.save(path);
RandomForestClassificationModel sameModel =
RandomForestClassificationModel.load(sc.sc(), path);
TreeTests.checkEqual(model3, sameModel);
RandomForestClassificationModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.regression;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -29,12 +31,13 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;


public class JavaDecisionTreeRegressorSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -64,17 +67,14 @@ public void runDT() {
model.depth();
model.toDebugString();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model2.save(sc.sc(), path);
DecisionTreeRegressionModel sameModel = DecisionTreeRegressionModel.load(sc.sc(), path);
TreeTests.checkEqual(model2, sameModel);
model.save(path);
DecisionTreeRegressionModel sameModel = DecisionTreeRegressionModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.regression;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -29,12 +31,13 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;


public class JavaGBTRegressorSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -68,17 +71,14 @@ public void runDT() {
model.trees();
model.treeWeights();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model2.save(sc.sc(), path);
GBTRegressionModel sameModel = GBTRegressionModel.load(sc.sc(), path);
TreeTests.checkEqual(model2, sameModel);
model.save(path);
GBTRegressionModel sameModel = GBTRegressionModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.ml.regression;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -31,12 +33,13 @@
import org.apache.spark.ml.tree.impl.TreeTests;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.util.Utils;


public class JavaRandomForestRegressorSuite extends SharedSparkSession {

@Test
public void runDT() {
public void runDT() throws IOException {
int nPoints = 20;
double A = 2.0;
double B = -1.5;
Expand Down Expand Up @@ -88,17 +91,14 @@ public void runDT() {
model.treeWeights();
Vector importances = model.featureImportances();

/*
// TODO: Add test once save/load are implemented. SPARK-6725
File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = tempDir.toURI().toString();
String path = new File(tempDir, "model").getPath();
try {
model2.save(sc.sc(), path);
RandomForestRegressionModel sameModel = RandomForestRegressionModel.load(sc.sc(), path);
TreeTests.checkEqual(model2, sameModel);
model.save(path);
RandomForestRegressionModel sameModel = RandomForestRegressionModel.load(path);
TreeTests.checkEqual(model, sameModel);
} finally {
Utils.deleteRecursively(tempDir);
}
*/
}
}