Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove whitespace at end of line #445

Merged
merged 1 commit into from May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -42,19 +42,19 @@ To run the tests, you also must have `nose` installed.

### User Installation

pomegranate is now pip installable! Install using
pomegranate is now pip installable! Install using

```
pip install pomegranate
```

Pomegranate can also be installed with conda, using
Pomegranate can also be installed with conda, using

```
conda install pomegranate
```
```

Wheels have been built for Windows versions for quick installations without the need for a C++ compiler.
Wheels have been built for Windows versions for quick installations without the need for a C++ compiler.

**NOTE: If you are on OSX and python 2.7 you may encounter an error using pip on versions above 0.7.3. Please install those versions from GitHub or use 0.7.3.**

Expand All @@ -74,7 +74,7 @@ python setup.py install

Lastly, you can also download the zip and manually move the files into your site-packages folder (or your PYTHON_PATH, if you've changed it).

To build from source on Windows machines, you may need to download a C++ compiler. For Python 2 this minimal version of Visual Studio 2008 works well: https://www.microsoft.com/en-us/download/details.aspx?id=44266. For Python 3 this version of the Visual Studio Build Tools has been reported to work: http://go.microsoft.com/fwlink/?LinkId=691126.
To build from source on Windows machines, you may need to download a C++ compiler. For Python 2 this minimal version of Visual Studio 2008 works well: https://www.microsoft.com/en-us/download/details.aspx?id=44266. For Python 3 this version of the Visual Studio Build Tools has been reported to work: http://go.microsoft.com/fwlink/?LinkId=691126.

If those do no work, it has been suggested that https://wiki.python.org/moin/WindowsCompilers may provide more information. Note that your compiler version must fit your python version. Run python --version to tell which python version you use. Don't forget to select the appropriate Windows version API you'd like to use. If you get an error message "ValueError: Unknown MS Compiler version 1900" remove your Python's Lib/distutils/distutil.cfg and retry. See http://stackoverflow.com/questions/34135280/valueerror-unknown-ms-compiler-version-1900 for details.

Expand All @@ -85,7 +85,7 @@ pip uninstall pomegranate
pip install pomegranate --no-cache-dir
```

If that doesn't work for you, you may need to downgrade your version of numpy to 1.11.3 and try the above again.
If that doesn't work for you, you may need to downgrade your version of numpy to 1.11.3 and try the above again.

Some users on Macs have seen the following error when downloading: `MarkovChain.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00`. This can be fixed by removing the `.so` files from the pomegranate installation or by building pomegranate from source.

Expand All @@ -99,7 +99,7 @@ Install dependencies and pomegranate via pip3:

```
$ sudo dnf install -y python3-virtualenv python3-scipy python3-numpy python3-networkx python3-Cython
$ sudo pip3 install --no-cache-dir pomegranate
$ sudo pip3 install --no-cache-dir pomegranate
```

**Installing inside a virtualenv**
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/benchmark_distributions.py
Expand Up @@ -6,7 +6,7 @@
log probability and training calculations.
"""

from pomegranate import *
from pomegranate import *
import random
import numpy
import time
Expand Down Expand Up @@ -37,7 +37,7 @@ def bench_from_sample( distribution, sample, n=1000 ):

def benchmark_distribution_log_probabilities():
"""Run log probability benchmarks."""

distributions = [ UniformDistribution( 0, 17 ),
NormalDistribution( 7, 1 ),
LogNormalDistribution( 7, 1 ),
Expand All @@ -48,7 +48,7 @@ def benchmark_distribution_log_probabilities():
TriangleKernelDensity([0, 1, 4, 3, 2, 0.5, 2, 1, 2]),
MixtureDistribution( [UniformDistribution( 5, 2 ),
NormalDistribution( 7, 1 ),
NormalDistribution( 3, 0.5 )] )
NormalDistribution( 3, 0.5 )] )
]

for distribution in distributions:
Expand All @@ -64,12 +64,12 @@ def benchmark_distribution_log_probabilities():
NormalDistribution( 0.5, 0.01) ])

print_benchmark( distribution, bench_log_probability( distribution, symbol=(5,4,3,2,1) ) )

mu = np.random.randn(4)
cov = np.random.randn(4, 4) / 10
cov = np.abs( cov.dot( cov.T ) ) + np.eye( 4 )
distribution = MultivariateGaussianDistribution( mu, cov )

print_benchmark( distribution, bench_log_probability( distribution, n=100000, symbol=(1,2,3,4) ) )

def benchmark_distribution_train():
Expand All @@ -85,7 +85,7 @@ def benchmark_distribution_train():
TriangleKernelDensity([0, 1, 4, 3, 2, 0.5, 2, 1, 2]),
MixtureDistribution( [UniformDistribution( 5, 2 ),
NormalDistribution( 7, 1 ),
NormalDistribution( 3, 0.5 )] )
NormalDistribution( 3, 0.5 )] )
]

sample = np.random.randn(10000)
Expand Down Expand Up @@ -122,4 +122,4 @@ def benchmark_distribution_train():
benchmark_distribution_log_probabilities()
print
print "TRAINING (N=1,000 ITERATIONS, BATCHES=10,000 ITEMS)"
benchmark_distribution_train()
benchmark_distribution_train()
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -19,7 +19,7 @@
#import mock
#MOCK_MODULES = ['numpy', 'scipy', 'joblib', 'networkx', 'cython']
#for mod_name in MOCK_MODULES:
# sys.modules[mod_name] = mock.Mock()
# sys.modules[mod_name] = mock.Mock()

subprocess.call('pip install numpydoc', shell=True)

Expand Down
8 changes: 4 additions & 4 deletions pomegranate/BayesClassifier.pyx
Expand Up @@ -114,15 +114,15 @@ cdef class BayesClassifier(BayesModel):
return nb

@classmethod
def from_samples(self, distributions, X, y, weights=None,
inertia=0.0, pseudocount=0.0, stop_threshold=0.1, max_iterations=1e8,
def from_samples(self, distributions, X, y, weights=None,
inertia=0.0, pseudocount=0.0, stop_threshold=0.1, max_iterations=1e8,
callbacks=[], return_history=False, verbose=False, n_jobs=1):
"""Create a Bayes classifier directly from the given dataset.

This will initialize the distributions using maximum likelihood estimates
derived by partitioning the dataset using the label vector. If any labels
are missing, the model will be trained using EM in a semi-supervised
setting.
setting.

A homogeneous model can be defined by passing in a single distribution
callable as the first parameter and specifying the number of components,
Expand Down Expand Up @@ -218,7 +218,7 @@ cdef class BayesClassifier(BayesModel):
distributions = [distribution.blank() for distribution in distributions]

model = BayesClassifier(distributions)
_, history = model.fit(X, y, weights=weights, inertia=inertia, pseudocount=pseudocount,
_, history = model.fit(X, y, weights=weights, inertia=inertia, pseudocount=pseudocount,
stop_threshold=stop_threshold, max_iterations=max_iterations,
callbacks=callbacks, return_history=True, verbose=verbose, n_jobs=n_jobs)

Expand Down