Skip to content

Commit 7142d23

Browse files
committed
Updated usage to include imports and prints
1 parent 2eeca44 commit 7142d23

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,50 @@ Example usage:
2222
Simple linear classification.
2323

2424
```Python
25+
import skflow
26+
from sklearn import datasets, metrics
27+
2528
iris = datasets.load_iris()
2629
classifier = skflow.TensorFlowLinearClassifier(n_classes=3)
2730
classifier.fit(iris.data, iris.target)
28-
score = accuracy_score(classifier.predict(iris.data), iris.target)
31+
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
32+
print "Accuracy: ", score
2933
```
3034

3135
### Deep Neural Network
3236

3337
Example of 3 layer network with 10, 20 and 10 hidden units respectively:
3438

3539
```Python
40+
import skflow
41+
from sklearn import datasets, metrics
42+
43+
iris = datasets.load_iris()
3644
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
3745
classifier.fit(iris.data, iris.target)
3846
score = accuracy_score(classifier.predict(iris.data), iris.target)
47+
print "Accuracy: ", score
3948
```
4049

4150
### Custom model
4251

43-
This example how to pass custom model to the TensorFlowEstimator
52+
This is example of how to pass custom model to the TensorFlowEstimator
4453

4554
```Python
55+
import skflow
56+
from sklearn import datasets, metrics
57+
58+
iris = datasets.load_iris()
59+
4660
def my_model(X, y):
4761
"""This is DNN with 10, 20, 10 hidden layers, and dropout of 0.5 probability."""
48-
layers = skflow.ops.dnn(X, [10, 20, 10], keep_proba=0.5)
49-
return skflow.logistic_classifier(layers, y)
62+
layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.5)
63+
return skflow.ops.logistic_classifier(layers, y)
5064

5165
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
5266
classifier.fit(iris.data, iris.target)
5367
score = accuracy_score(classifier.predict(iris.data), iris.target)
68+
print "Accuracy: ", score
5469
```
5570

5671
## Coming soon

0 commit comments

Comments
 (0)