Skip to content

Commit

Permalink
Added Example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwlouse committed Jun 24, 2015
1 parent 3870891 commit e95b40f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ Sacred achieves this through the following main mechanisms:
- **Automatic seeding** helps controlling the randomness in your experiments,
such that the results remain reproducible.

Example
-------
+------------------------------------------------+--------------------------------------------+
| **Script to train an SVM on the Iris Dataset** | **The same Script as a Sacred Experiment** |
+------------------------------------------------+--------------------------------------------+
| .. code:: python | .. code:: python |
| | |
| from numpy.random import permutation | from numpy.random import permutation |
| from sklearn import svm, datasets | from sklearn import svm, datasets |
| | from sacred import Experiment |
| | ex = Experiment('iris_rbf_svm') |
| | |
| | @ex.config |
| | def cfg(): |
| C = 1.0 | C = 1.0 |
| gamma = 0.7 | gamma = 0.7 |
| | |
| | @ex.automain |
| | def run(C, gamma): |
| iris = datasets.load_iris() | iris = datasets.load_iris() |
| perm = permutation(iris.target.size) | per = permutation(iris.target.size) |
| iris.data = iris.data[perm] | iris.data = iris.data[per] |
| iris.target = iris.target[perm] | iris.target = iris.target[per] |
| clf = svm.SVC(C, 'rbf', gamma=gamma) | clf = svm.SVC(C, 'rbf', gamma=gamma) |
| clf.fit(iris.data[:90], | clf.fit(iris.data[:90], |
| iris.target[:90]) | iris.target[:90]) |
| print(clf.score(iris.data[90:], | return clf.score(iris.data[90:], |
| iris.target[90:])) | iris.target[90:]) |
+------------------------------------------------+--------------------------------------------+

Documentation
-------------
Expand Down

0 comments on commit e95b40f

Please sign in to comment.