You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@systemml.apache.org by "Deron Eriksson (JIRA)" <ji...@apache.org> on 2017/08/17 20:16:00 UTC

[jira] [Commented] (SYSTEMML-1849) Can't obtain scores from l2-svm-predict.dml using JMLC

    [ https://issues.apache.org/jira/browse/SYSTEMML-1849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16131223#comment-16131223 ] 

Deron Eriksson commented on SYSTEMML-1849:
------------------------------------------

cc [~mboehm7]

> Can't obtain scores from l2-svm-predict.dml using JMLC
> ------------------------------------------------------
>
>                 Key: SYSTEMML-1849
>                 URL: https://issues.apache.org/jira/browse/SYSTEMML-1849
>             Project: SystemML
>          Issue Type: Bug
>          Components: Compiler, Runtime
>            Reporter: Deron Eriksson
>
> Attempting to obtain the {{scores}} variable in {{l2-svm-predict.dml}} using JMLC gives:
> {code}
> Exception in thread "main" org.apache.sysml.api.DMLException: Non-existent output variable: scores
> 	at org.apache.sysml.api.jmlc.ResultVariables.getMatrixBlock(ResultVariables.java:88)
> 	at org.apache.sysml.api.jmlc.ResultVariables.getMatrix(ResultVariables.java:74)
> {code}
> This appears to be introduced by https://github.com/apache/systemml/commit/4b81d0dda6583f0ae96eaa7aa5832005ae5fa8a9
> Example code:
> {code}
> 	public static void jmlcL2SVM() throws Exception {
> 		Connection conn = new Connection();
> 		String dml = conn.readScript("scripts/algorithms/l2-svm.dml");
> 		PreparedScript l2svm = conn.prepareScript(dml, new String[] { "X", "Y", "fmt", "Log" },
> 				new String[] { "w", "debug_str" }, false);
> 		double[][] trainData = new double[150][3];
> 		for (int i = 0; i < 150; i++) {
> 			int one = ThreadLocalRandom.current().nextInt(0, 101);
> 			int two = ThreadLocalRandom.current().nextInt(0, 101);
> 			int three = ThreadLocalRandom.current().nextInt(0, 101);
> 			double[] row = new double[] { one, two, three };
> 			trainData[i] = row;
> 		}
> 		l2svm.setMatrix("X", trainData);
> 		log.debug(displayMatrix(trainData));
> 		double[][] trainLabels = new double[150][1];
> 		for (int i = 0; i < 150; i++) {
> 			int one = ThreadLocalRandom.current().nextInt(1, 3);
> 			double[] row = new double[] { one };
> 			trainLabels[i] = row;
> 		}
> 		l2svm.setMatrix("Y", trainLabels);
> 		log.debug(displayMatrix(trainLabels));
> 		l2svm.setScalar("fmt", "csv");
> 		l2svm.setScalar("Log", "temp/l2-svm-log.csv");
> 		ResultVariables l2svmResults = l2svm.executeScript();
> 		double[][] model = l2svmResults.getMatrix("w");
> 		log.debug("MODEL:");
> 		log.debug(displayMatrix(model));
> 		String debugString = l2svmResults.getString("debug_str");
> 		log.debug("DEBUG STRING:");
> 		log.debug(debugString);
> 		String s = conn.readScript("scripts/algorithms/l2-svm-predict.dml");
> 		Map<String, String> m = new HashMap<String, String>();
> 		m.put("$Y", "\"temp/haberman.test.labels.csv\"");
> 		m.put("$confusion", "\"temp/l2-svm-confusion.csv\"");
> 		PreparedScript l2svmPredict = conn.prepareScript(s, m, new String[] { "X", "y", "w", "fmt" },
> 				new String[] { "scores", "confusion_mat" }, false);
> 		double[][] testData = new double[150][3];
> 		for (int i = 0; i < 150; i++) {
> 			int one = ThreadLocalRandom.current().nextInt(0, 101);
> 			int two = ThreadLocalRandom.current().nextInt(0, 101);
> 			int three = ThreadLocalRandom.current().nextInt(0, 101);
> 			double[] row = new double[] { one, two, three };
> 			testData[i] = row;
> 		}
> 		l2svmPredict.setMatrix("X", testData);
> 		double[][] testLabels = new double[150][1];
> 		for (int i = 0; i < 150; i++) {
> 			int one = ThreadLocalRandom.current().nextInt(1, 3);
> 			double[] row = new double[] { one };
> 			testLabels[i] = row;
> 		}
> 		l2svmPredict.setMatrix("y", testLabels);
> 		l2svmPredict.setMatrix("w", model);
> 		l2svmPredict.setScalar("fmt", "csv");
> 		ResultVariables l2svmPredictResults = l2svmPredict.executeScript();
> 		double[][] scores = l2svmPredictResults.getMatrix("scores");
> 		log.debug("SCORES:");
> 		log.debug(displayMatrix(scores));
> 		double[][] confusionMatrix = l2svmPredictResults.getMatrix("confusion_mat");
> 		log.debug("CONFUSION MATRIX:");
> 		log.debug(displayMatrix(confusionMatrix));
> 		conn.close();
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)