Repository: incubator-systemml Updated Branches: refs/heads/master 542de374e -> 1f6d55e9e
[SYSTEMML-890] Fix Python Tests to Run on Python 2 & 3 Closes #230. Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/1f6d55e9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/1f6d55e9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/1f6d55e9 Branch: refs/heads/master Commit: 1f6d55e9ec6ad0e432e26a608b30e07471191ab0 Parents: 542de37 Author: Mike Dusenberry <[email protected]> Authored: Fri Sep 2 13:32:04 2016 -0700 Committer: Mike Dusenberry <[email protected]> Committed: Fri Sep 2 13:32:04 2016 -0700 ---------------------------------------------------------------------- src/main/python/tests/test_mllearn.py | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/1f6d55e9/src/main/python/tests/test_mllearn.py ---------------------------------------------------------------------- diff --git a/src/main/python/tests/test_mllearn.py b/src/main/python/tests/test_mllearn.py index 27b9813..9cc6443 100644 --- a/src/main/python/tests/test_mllearn.py +++ b/src/main/python/tests/test_mllearn.py @@ -8,9 +8,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,7 +20,7 @@ # #------------------------------------------------------------- from sklearn import datasets, neighbors -from systemml.mllearn import LogisticRegression, LinearRegression, SVM, NaiveBayes +from systemml.mllearn import LogisticRegression, LinearRegression, SVM, NaiveBayes from pyspark.sql import SQLContext from pyspark.context import SparkContext import unittest @@ -50,7 +50,7 @@ class TestMLLearn(unittest.TestCase): logistic = LogisticRegression(sqlCtx) score = logistic.fit(X_train, y_train).score(X_test, y_test) self.failUnless(score > 0.9) - + def testLogisticSK2(self): digits = datasets.load_digits() X_digits = digits.data @@ -67,18 +67,18 @@ class TestMLLearn(unittest.TestCase): def testLogisticMLPipeline1(self): training = sqlCtx.createDataFrame([ - (0L, "a b c d e spark", 1.0), - (1L, "b d", 2.0), - (2L, "spark f g h", 1.0), - (3L, "hadoop mapreduce", 2.0), - (4L, "b spark who", 1.0), - (5L, "g d a y", 2.0), - (6L, "spark fly", 1.0), - (7L, "was mapreduce", 2.0), - (8L, "e spark program", 1.0), - (9L, "a e c l", 2.0), - (10L, "spark compile", 1.0), - (11L, "hadoop software", 2.0) + (0, "a b c d e spark", 1.0), + (1, "b d", 2.0), + (2, "spark f g h", 1.0), + (3, "hadoop mapreduce", 2.0), + (4, "b spark who", 1.0), + (5, "g d a y", 2.0), + (6, "spark fly", 1.0), + (7, "was mapreduce", 2.0), + (8, "e spark program", 1.0), + (9, "a e c l", 2.0), + (10, "spark compile", 1.0), + (11, "hadoop software", 2.0) ], ["id", "text", "label"]) tokenizer = Tokenizer(inputCol="text", outputCol="words") hashingTF = HashingTF(inputCol="words", outputCol="features", numFeatures=20) @@ -86,10 +86,10 @@ class TestMLLearn(unittest.TestCase): pipeline = Pipeline(stages=[tokenizer, hashingTF, lr]) model = pipeline.fit(training) test = sqlCtx.createDataFrame([ - (12L, "spark i j k", 1.0), - (13L, "l m n", 2.0), - (14L, "mapreduce spark", 1.0), - (15L, "apache hadoop", 2.0)], ["id", "text", "label"]) + (12, "spark i j k", 1.0), + (13, "l m n", 2.0), + (14, "mapreduce spark", 1.0), + (15, "apache hadoop", 2.0)], ["id", "text", "label"]) result = model.transform(test) predictionAndLabels = result.select("prediction", "label") evaluator = MulticlassClassificationEvaluator() @@ -172,7 +172,7 @@ class TestMLLearn(unittest.TestCase): pred = nb.predict(vectors_test) score = metrics.f1_score(newsgroups_test.target, pred, average='weighted') self.failUnless(score > 0.8) - + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()
