Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 511ab20

Browse files
committed
model: tensorflow: dnnc: Updated docstring with examples
Signed-off-by: John Andersen <[email protected]>
1 parent ede4145 commit 511ab20

File tree

1 file changed

+32
-71
lines changed
  • model/tensorflow/dffml_model_tensorflow

1 file changed

+32
-71
lines changed

model/tensorflow/dffml_model_tensorflow/dnnc.py

Lines changed: 32 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -328,59 +328,34 @@ class DNNClassifierModel(Model):
328328
"""
329329
Implemented using Tensorflow's DNNClassifier.
330330
331-
.. code-block:: console
332-
333-
$ wget http://download.tensorflow.org/data/iris_training.csv
334-
$ wget http://download.tensorflow.org/data/iris_test.csv
335-
$ head iris_training.csv
336-
$ sed -i 's/.*setosa,versicolor,virginica/SepalLength,SepalWidth,PetalLength,PetalWidth,classification/g' *.csv
337-
$ head iris_training.csv
338-
$ dffml train \\
339-
-model tfdnnc \\
340-
-model-epochs 3000 \\
341-
-model-steps 20000 \\
342-
-model-predict classification:int:1 \\
343-
-model-classifications 0 1 2 \\
344-
-model-clstype int \\
345-
-sources iris=csv \\
346-
-source-filename iris_training.csv \\
347-
-model-features \\
348-
SepalLength:float:1 \\
349-
SepalWidth:float:1 \\
350-
PetalLength:float:1 \\
351-
PetalWidth:float:1 \\
352-
-log debug
353-
... lots of output ...
354-
$ dffml accuracy \\
355-
-model tfdnnc \\
356-
-model-predict classification:int:1 \\
357-
-model-classifications 0 1 2 \\
358-
-model-clstype int \\
359-
-sources iris=csv \\
360-
-source-filename iris_test.csv \\
361-
-model-features \\
362-
SepalLength:float:1 \\
363-
SepalWidth:float:1 \\
364-
PetalLength:float:1 \\
365-
PetalWidth:float:1 \\
366-
-log critical
331+
First we create the training and testing datasets
332+
333+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/train_data.sh
334+
335+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/test_data.sh
336+
337+
Train the model
338+
339+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/train.sh
340+
341+
Assess the accuracy
342+
343+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/accuracy.sh
344+
345+
Output
346+
347+
.. code-block::
348+
367349
0.99996233782
368-
$ dffml predict all \\
369-
-model tfdnnc \\
370-
-model-predict classification:int:1 \\
371-
-model-classifications 0 1 2 \\
372-
-model-clstype int \\
373-
-sources iris=csv \\
374-
-source-filename iris_test.csv \\
375-
-model-features \\
376-
SepalLength:float:1 \\
377-
SepalWidth:float:1 \\
378-
PetalLength:float:1 \\
379-
PetalWidth:float:1 \\
380-
-caching \\
381-
-log critical \\
382-
> results.json
383-
$ head -n 33 results.json
350+
351+
Make a prediction
352+
353+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/predict.sh
354+
355+
Output
356+
357+
.. code-block:: json
358+
384359
[
385360
{
386361
"extra": {},
@@ -401,25 +376,11 @@ class DNNClassifierModel(Model):
401376
},
402377
"key": "0"
403378
},
404-
{
405-
"extra": {},
406-
"features": {
407-
"PetalLength": 5.4,
408-
"PetalWidth": 2.1,
409-
"SepalLength": 6.9,
410-
"SepalWidth": 3.1,
411-
"classification": 2
412-
},
413-
"last_updated": "2019-07-31T02:00:12Z",
414-
"prediction": {
415-
"classification":
416-
{
417-
"confidence": 0.9999984502792358,
418-
"value": 2
419-
}
420-
},
421-
"key": "1"
422-
},
379+
]
380+
381+
Example usage of Tensorflow DNNClassifier model using python API
382+
383+
.. literalinclude:: /../model/tensorflow/examples/tfdnnc/tfdnnc.py
423384
424385
"""
425386

0 commit comments

Comments
 (0)