Skip to content
Snippets Groups Projects
Commit 0b720f7f authored by Artur Costa Pazo's avatar Artur Costa Pazo
Browse files

Fix error on OC-SVM documentation example code on py 3.x caused by reused variables.

parent 4607ce8d
No related branches found
No related tags found
No related merge requests found
...@@ -161,8 +161,8 @@ On the other hand, the package allows you to train a One Class Support Vector Ma ...@@ -161,8 +161,8 @@ On the other hand, the package allows you to train a One Class Support Vector Ma
:options: +NORMALIZE_WHITESPACE :options: +NORMALIZE_WHITESPACE
>>> oc_pos = 0.4 * numpy.random.randn(100, 2).astype(numpy.float64) >>> oc_pos = 0.4 * numpy.random.randn(100, 2).astype(numpy.float64)
>>> data = [oc_pos] >>> oc_data = [oc_pos]
>>> print(data) # doctest: +SKIP >>> print(oc_data) # doctest: +SKIP
As the above example, an SVM [1]_ for one class problem can be trained easily using the As the above example, an SVM [1]_ for one class problem can be trained easily using the
...@@ -171,20 +171,20 @@ As the above example, an SVM [1]_ for one class problem can be trained easily us ...@@ -171,20 +171,20 @@ As the above example, an SVM [1]_ for one class problem can be trained easily us
.. doctest:: .. doctest::
:options: +NORMALIZE_WHITESPACE :options: +NORMALIZE_WHITESPACE
>>> trainer = bob.learn.libsvm.Trainer(machine_type='ONE_CLASS') >>> oc_trainer = bob.learn.libsvm.Trainer(machine_type='ONE_CLASS')
>>> machine = trainer.train(data) >>> oc_machine = oc_trainer.train(oc_data)
Then, as explained before, a :py:class:`bob.learn.libsvm.Machine` can be used for classify the new entries. Then, as explained before, a :py:class:`bob.learn.libsvm.Machine` can be used for classify the new entries.
.. doctest:: .. doctest::
:options: +NORMALIZE_WHITESPACE :options: +NORMALIZE_WHITESPACE
>>> test = 0.4 * numpy.random.randn(20, 2).astype(numpy.float64) >>> oc_test = 0.4 * numpy.random.randn(20, 2).astype(numpy.float64)
>>> outliers = numpy.random.uniform(low=-4, high=4, size=(20, 2)).astype(numpy.float64) >>> oc_outliers = numpy.random.uniform(low=-4, high=4, size=(20, 2)).astype(numpy.float64)
>>> predicted_label_test = machine(test) >>> predicted_label_oc_test = oc_machine(oc_test)
>>> predicted_label_outliers = machine(outliers) >>> predicted_label_oc_outliers = oc_machine(oc_outliers)
>>> print(predicted_label_test) # doctest: +SKIP >>> print(predicted_label_oc_test) # doctest: +SKIP
>>> print(predicted_label_outliers) # doctest: +SKIP >>> print(predicted_label_oc_outliers) # doctest: +SKIP
Acknowledgements Acknowledgements
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment