predictionio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From take...@apache.org
Subject [1/4] incubator-predictionio-template-attribute-based-classifier git commit: Fix use of case class
Date Thu, 12 Oct 2017 02:00:30 GMT
Repository: incubator-predictionio-template-attribute-based-classifier
Updated Branches:
  refs/heads/master bfe284ad4 -> 569deb091


Fix use of case class

Closes #11


Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/commit/3ad98d63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/tree/3ad98d63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/diff/3ad98d63

Branch: refs/heads/master
Commit: 3ad98d63e465253633b9d0e99088a011eae2e0df
Parents: 903f9ee
Author: Naoki Takezoe <takezoe@apache.org>
Authored: Sun Jul 16 01:50:49 2017 +0900
Committer: Naoki Takezoe <takezoe@apache.org>
Committed: Sun Jul 16 01:50:49 2017 +0900

----------------------------------------------------------------------
 src/main/scala/DataSource.scala          |  2 +-
 src/main/scala/Engine.scala              | 22 +++++++++++-----------
 src/main/scala/Evaluation.scala          |  2 +-
 src/main/scala/NaiveBayesAlgorithm.scala |  2 +-
 src/main/scala/PrecisionEvaluation.scala |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/blob/3ad98d63/src/main/scala/DataSource.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/DataSource.scala b/src/main/scala/DataSource.scala
index 96d245e..f981e9e 100644
--- a/src/main/scala/DataSource.scala
+++ b/src/main/scala/DataSource.scala
@@ -102,7 +102,7 @@ class DataSource(val dsp: DataSourceParams)
         new TrainingData(trainingPoints),
         new EmptyEvaluationInfo(),
         testingPoints.map {
-          p => (new Query(p.features(0), p.features(1), p.features(2)), new ActualResult(p.label))
+          p => (Query(p.features(0), p.features(1), p.features(2)), ActualResult(p.label))
         }
       )
     }

http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/blob/3ad98d63/src/main/scala/Engine.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/Engine.scala b/src/main/scala/Engine.scala
index 72c2515..3549f94 100644
--- a/src/main/scala/Engine.scala
+++ b/src/main/scala/Engine.scala
@@ -3,19 +3,19 @@ package org.example.classification
 import org.apache.predictionio.controller.EngineFactory
 import org.apache.predictionio.controller.Engine
 
-class Query(
-  val attr0 : Double,
-  val attr1 : Double,
-  val attr2 : Double
-) extends Serializable
+case class Query(
+  attr0 : Double,
+  attr1 : Double,
+  attr2 : Double
+)
 
-class PredictedResult(
-  val label: Double
-) extends Serializable
+case class PredictedResult(
+  label: Double
+)
 
-class ActualResult(
-  val label: Double
-) extends Serializable
+case class ActualResult(
+  label: Double
+)
 
 object ClassificationEngine extends EngineFactory {
   def apply() = {

http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/blob/3ad98d63/src/main/scala/Evaluation.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/Evaluation.scala b/src/main/scala/Evaluation.scala
index 9916f03..d17e39e 100644
--- a/src/main/scala/Evaluation.scala
+++ b/src/main/scala/Evaluation.scala
@@ -14,7 +14,7 @@ case class Accuracy()
 
 object AccuracyEvaluation extends Evaluation {
   // Define Engine and Metric used in Evaluation
-  engineMetric = (ClassificationEngine(), new Accuracy())
+  engineMetric = (ClassificationEngine(), Accuracy())
 }
 
 object EngineParamsList extends EngineParamsGenerator {

http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/blob/3ad98d63/src/main/scala/NaiveBayesAlgorithm.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/NaiveBayesAlgorithm.scala b/src/main/scala/NaiveBayesAlgorithm.scala
index 5723bc1..603a652 100644
--- a/src/main/scala/NaiveBayesAlgorithm.scala
+++ b/src/main/scala/NaiveBayesAlgorithm.scala
@@ -34,7 +34,7 @@ class NaiveBayesAlgorithm(val ap: AlgorithmParams)
     val label = model.predict(Vectors.dense(
       Array(query.attr0, query.attr1, query.attr2)
     ))
-    new PredictedResult(label)
+    PredictedResult(label)
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-attribute-based-classifier/blob/3ad98d63/src/main/scala/PrecisionEvaluation.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/PrecisionEvaluation.scala b/src/main/scala/PrecisionEvaluation.scala
index 71d391a..d0914f1 100644
--- a/src/main/scala/PrecisionEvaluation.scala
+++ b/src/main/scala/PrecisionEvaluation.scala
@@ -23,5 +23,5 @@ case class Precision(label: Double)
 }
 
 object PrecisionEvaluation extends Evaluation {
-  engineMetric = (ClassificationEngine(), new Precision(label = 1.0))
+  engineMetric = (ClassificationEngine(), Precision(label = 1.0))
 }


Mime
View raw message