Repository: intel/dffml

Issue:
model: tensorlfow: dnnc: Make classification property predict
To maintain consistancy with the other models, we should rename the `classification` property to `predict` in `dnnc.py`

Reporter: @aghinsa


Discussion:
changes in https://github.com/aghinsa/dffml/commit/fd6c91b06aa41620cdd07eff7ce7f267d086eaf4,in pr https://github.com/intel/dffml/pull/274

Resolving patch:
diff --git a/examples/maintained/cgi-bin/api-ml.py b/examples/maintained/cgi-bin/api-ml.py
--- a/examples/maintained/cgi-bin/api-ml.py
+++ b/examples/maintained/cgi-bin/api-ml.py
@@ -50,7 +50,7 @@
         'dffml', 'predict', 'repo',
         '-keys', query['URL'],
         '-model', 'tfdnnc',
-        '-model-classification', 'maintained',
+        '-model-predict', 'maintained',
         '-model-classifications', '0', '1',
         '-sources', 'db=demoapp',
         '-model-features',
diff --git a/model/tensorflow/dffml_model_tensorflow/dnnc.py b/model/tensorflow/dffml_model_tensorflow/dnnc.py
--- a/model/tensorflow/dffml_model_tensorflow/dnnc.py
+++ b/model/tensorflow/dffml_model_tensorflow/dnnc.py
@@ -139,9 +139,7 @@ def model(self):
 
 @config
 class DNNClassifierModelConfig:
-    classification: Feature = field(
-        "Feature name holding classification value"
-    )
+    predict: Feature = field("Feature name holding predict value")
     classifications: List[str] = field("Options for value of classification")
     features: Features = field("Features to train on")
     clstype: Type = field("Data type of classifications values", default=str)
@@ -176,10 +174,6 @@ def __init__(self, parent) -> None:
         self.classifications = self._classifications(self.cids)
         self.model_dir_path = self._model_dir_path()
 
-    @property
-    def classification(self):
-        return self.parent.config.classification.NAME
-
     def _mkcids(self, classifications):
         """
         Create an index, possible classification mapping and sort the list of
@@ -238,14 +232,17 @@ async def training_input_fn(
         for repo in [
             repo
             async for repo in sources.with_features(
-                self.features + [self.classification]
+                self.features + [self.parent.config.predict.NAME]
             )
-            if repo.feature(self.classification) in self.classifications
+            if repo.feature(self.parent.config.predict.NAME)
+            in self.classifications
         ]:
             for feature, results in repo.features(self.features).items():
                 x_cols[feature].append(np.array(results))
             y_cols.append(
-                self.classifications[repo.feature(self.classification)]
+                self.classifications[
+                    repo.feature(self.parent.config.predict.NAME)
+                ]
             )
         if not y_cols:
             raise ValueError("No repos to train on")
@@ -282,14 +279,17 @@ async def accuracy_input_fn(
         for repo in [
             repo
             async for repo in sources.with_features(
-                self.features + [self.classification]
+                self.features + [self.parent.config.predict.NAME]
             )
-            if repo.feature(self.classification) in self.classifications
+            if repo.feature(self.parent.config.predict.NAME)
+            in self.classifications
         ]:
             for feature, results in repo.features(self.features).items():
                 x_cols[feature].append(np.array(results))
             y_cols.append(
-                self.classifications[repo.feature(self.classification)]
+                self.classifications[
+                    repo.feature(self.parent.config.predict.NAME)
+                ]
             )
         y_cols = np.array(y_cols)
         for feature in x_cols:
@@ -354,7 +354,7 @@ class DNNClassifierModel(Model):
             -model tfdnnc \\
             -model-epochs 3000 \\
             -model-steps 20000 \\
-            -model-classification classification:int:1 \\
+            -model-predict classification:int:1 \\
             -model-classifications 0 1 2 \\
             -model-clstype int \\
             -sources iris=csv \\
@@ -368,7 +368,7 @@ class DNNClassifierModel(Model):
         ... lots of output ...
         $ dffml accuracy \\
             -model tfdnnc \\
-            -model-classification classification:int:1 \\
+            -model-predict classification:int:1 \\
             -model-classifications 0 1 2 \\
             -model-clstype int \\
             -sources iris=csv \\
@@ -382,7 +382,7 @@ class DNNClassifierModel(Model):
         0.99996233782
         $ dffml predict all \\
             -model tfdnnc \\
-            -model-classification classification:int:1 \\
+            -model-predict classification:int:1 \\
             -model-classifications 0 1 2 \\
             -model-clstype int \\
             -sources iris=csv \\


Test patch:
diff --git a/model/tensorflow/tests/test_dnnc.py b/model/tensorflow/tests/test_dnnc.py
--- a/model/tensorflow/tests/test_dnnc.py
+++ b/model/tensorflow/tests/test_dnnc.py
@@ -56,7 +56,7 @@ def setUpClass(cls):
                 steps=1000,
                 epochs=30,
                 hidden=[10, 20, 10],
-                classification=DefFeature("string", str, 1),
+                predict=DefFeature("string", str, 1),
                 classifications=["a", "not a"],
                 clstype=str,
                 features=cls.features,
@@ -70,7 +70,7 @@ def tearDownClass(cls):
     async def test_config(self):
         config = self.model.__class__.config(
             parse_unknown(
-                "--model-classification",
+                "--model-predict",
                 "feature_name:int:1",
                 "--model-classifications",
                 "0",
@@ -91,7 +91,7 @@ async def test_config(self):
         self.assertEqual(config.steps, 3000)
         self.assertEqual(config.epochs, 30)
         self.assertEqual(config.hidden, [12, 40, 15])
-        self.assertEqual(config.classification.NAME, "feature_name")
+        self.assertEqual(config.predict.NAME, "feature_name")
         self.assertEqual(config.classifications, [0, 1, 2])
         self.assertEqual(config.clstype, int)