Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vrasneur committed Nov 4, 2017
1 parent 76148d9 commit 35bbbf4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The binding supports Python 2.6, 2.7 and Python 3. It requires [Cython](http://c
[Numpy](http://www.numpy.org/) is also a dependency, but is optional.

`pyfasttext` has been tested successfully on Linux and Mac OS X.
It does not currently compile on Windows because the `cysignals` module does not support this platform.
*Warning*: `pyfasttext` does not currently compile on Windows because the `cysignals` module does not support this platform.

Table of Contents
=================
Expand Down Expand Up @@ -66,7 +66,9 @@ Table of Contents

## Installation

To compile `pyfasttext`, make sure you have a compiler with C++11 support.
To compile `pyfasttext`, make sure you have the following compiler:
* GCC (`g++`) with C++11 support.
* LLVM (`clang++`) with (at least) partial C++17 support.

### Simplest way to install pyfasttext: use pip

Expand Down
47 changes: 28 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Yet another Python binding for
| `Numpy <http://www.numpy.org/>`__ is also a dependency, but is
optional.
``pyfasttext`` has been tested successfully on Linux and Mac OS X.
| ``pyfasttext`` has been tested successfully on Linux and Mac OS X.
| *Warning*: ``pyfasttext`` does not currently compile on Windows
because the ``cysignals`` module does not support this platform.
Table of Contents
=================
Expand Down Expand Up @@ -108,8 +110,9 @@ Table of Contents
Installation
------------

To compile ``pyfasttext``, make sure you have a compiler with C++11
support.
To compile ``pyfasttext``, make sure you have the following compiler: \*
GCC (``g++``) with C++11 support. \* LLVM (``clang++``) with (at least)
partial C++17 support.

Simplest way to install pyfasttext: use pip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -395,22 +398,25 @@ If you have a list of strings (or an iterable object), use this:

.. code:: python
>>> model.predict_proba(['first sentence', 'second sentence'], k=2)
>>> model.predict_proba(['first sentence\n', 'second sentence\n'], k=2)
[[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]]
If your test data is stored inside a file, use this:
If you want to test a single string, use this:

.. code:: python
>>> model.predict_proba_file('/path/to/test.txt', k=2)
[[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]]
>>> model.predict_proba_single('first sentence\n', k=2)
[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)]
If you want to test a single string, use this:
**WARNING**: In order to get the same probabilities as the ``fastText``
binary, you have to add a newline (``\n``) at the end of each string.

If your test data is stored inside a file, use this:

.. code:: python
>>> model.predict_proba_single('first sentence', k=2)
[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)]
>>> model.predict_proba_file('/path/to/test.txt', k=2)
[[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]]
Normalized probabilities

Expand All @@ -426,9 +432,9 @@ parameter in all the methods that output probabilities

.. code:: python
>>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified', k=None))
>>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified\n', k=None))
0.9785203068801335
>>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified', k=None, normalized=True))
>>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified\n', k=None, normalized=True))
0.9999999999999898
Labels only
Expand All @@ -438,22 +444,25 @@ If you have a list of strings (or an iterable object), use this:

.. code:: python
>>> model.predict(['first sentence', 'second sentence'], k=2)
>>> model.predict(['first sentence\n', 'second sentence\n'], k=2)
[['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']]
If your test data is stored inside a file, use this:
If you want to test a single string, use this:

.. code:: python
>>> model.predict_file('/path/to/test.txt', k=2)
[['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']]
>>> model.predict_single('first sentence\n', k=2)
['LABEL1', 'LABEL3']
If you want to test a single string, use this:
**WARNING**: In order to get the same probabilities as the ``fastText``
binary, you have to add a newline (``\n``) at the end of each string.

If your test data is stored inside a file, use this:

.. code:: python
>>> model.predict_single('first sentence', k=2)
['LABEL1', 'LABEL3']
>>> model.predict_file('/path/to/test.txt', k=2)
[['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']]
Quantization
^^^^^^^^^^^^
Expand Down

0 comments on commit 35bbbf4

Please sign in to comment.