Skip to content

Commit

Permalink
trim trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ddbourgin committed Apr 11, 2020
1 parent d9fecd5 commit 9877898
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 94 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/a--bug-performance-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ labels: bugfix

**Describe the expected behavior**

**Code to reproduce the issue**
**Code to reproduce the issue**
<!-- Provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

**Other info / logs**
<!-- Include any logs or source code that would be helpful to diagnose the problem.
**Other info / logs**
<!-- Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files should be attached. -->
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sphinx:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats:
formats:
- htmlzip

# Optionally set the version of Python and requirements required to build your docs
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Thank you for contributing to numpy-ml!
2. For pull requests, please make sure all commits are [*atomic*](https://en.wikipedia.org/wiki/Atomic_commit) (i.e., one feature per commit)
3. If you're submitting a new model / feature / module, **please include proper documentation and unit tests.**
- See the `test.py` file in one of the existing modules for examples of unit tests.
- Documentation is loosely based on the [NumPy docstring style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html). When in doubt, refer to existing examples
- Documentation is loosely based on the [NumPy docstring style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html). When in doubt, refer to existing examples
4. Please format your code using the [black](https://github.com/python/black) defaults. You can use this [online formatter](https://black.now.sh/).

### Specific guidelines
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# numpy-ml
Ever wish you had an inefficient but somewhat legible collection of machine
learning algorithms implemented exclusively in numpy? No?
learning algorithms implemented exclusively in numpy? No?

## Documentation
To see all of the available models, take a look at the [project documentation](https://numpy-ml.readthedocs.io/) or see [here](https://github.com/ddbourgin/numpy-ml/blob/master/numpy_ml/README.md).
Expand All @@ -14,4 +14,4 @@ library](https://docs.python.org/3/library/) and [NumPy](https://www.numpy.org/)
[SciPy library](https://scipy.github.io/devdocs/) is also permitted under special
circumstances ;)

See full contributing guidelines [here](./CONTRIBUTING.md).
See full contributing guidelines [here](./CONTRIBUTING.md).
10 changes: 5 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Welcome to numpy-ml
===================
`numpy-ml`_ is a growing collection of machine learning models, algorithms, and
tools written exclusively in `NumPy`_ and the Python `standard library`_.
tools written exclusively in `NumPy`_ and the Python `standard library`_.

The purpose of the project is to provide reference implementations of common
machine learning components for rapid prototyping and experimentation. With
Expand All @@ -15,7 +15,7 @@ that in mind, don't just read the docs -- read the source!

We're working to expand our coverage. During this time there are likely to
be typos, bugs, and poorly-worded sections. If you encounter any of the
above, please file an `issue`_ or submit a `pull request`_!
above, please file an `issue`_ or submit a `pull request`_!

.. _issue: https://github.com/ddbourgin/numpy-ml/issues
.. _pull request: https://github.com/ddbourgin/numpy-ml/pulls
Expand Down Expand Up @@ -49,8 +49,8 @@ that in mind, don't just read the docs -- read the source!
numpy_ml.utils

##########
Disclaimer
##########
Disclaimer
##########

This software is provided as-is: there are no guarantees that it fits your
purposes or that it is bug-free. Use it at your own risk!
16 changes: 8 additions & 8 deletions docs/numpy_ml.gmm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ unsupervised clustering.
A GMM assumes that:

1. The observed data are generated from a `mixture distribution`_, `P`,
made up of `K` mixture components.
made up of `K` mixture components.

2. Each mixture component is a multivariate Gaussian with its own mean
:math:`\mu`, covariance matrix, :math:`\Sigma`, and mixture weight,
Expand All @@ -35,15 +35,15 @@ The parameters of a GMM model are:
\Sigma_k, \pi_k \}`.

Under a GMM, the joint probability of a sequence of cluster assignments `Z` and an observed
dataset :math:`X = \{x_1, \ldots, x_N \}`, is:
dataset :math:`X = \{x_1, \ldots, x_N \}`, is:

.. math::
p(Z, X \mid \theta) =
\prod_{i=1}^N p(z_i, x_i \mid \theta) =
\prod_{i=1}^N \prod_{k=1}^K
p(Z, X \mid \theta) =
\prod_{i=1}^N p(z_i, x_i \mid \theta) =
\prod_{i=1}^N \prod_{k=1}^K
[\mathcal{N}(x_i \mid \mu_k, \Sigma_k) \pi_k ]^{\mathbb{1}_{[z_{i} = k]}}
where
where

- :math:`\theta` is the set of GMM parameters: :math:`\theta = \{ \mu_1,
\Sigma_1, \pi_i, \ldots, \mu_k, \Sigma_k, \pi_k \}`.
Expand All @@ -56,7 +56,7 @@ where
and 0 otherwise.

As with other latent-variable models, we use the `expectation-maximization (EM)
algorithm`_ to learn the GMM parameters.
algorithm`_ to learn the GMM parameters.

.. _expectation-maximization (EM) algorithm : https://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm

Expand All @@ -65,7 +65,7 @@ algorithm`_ to learn the GMM parameters.
- :class:`~numpy_ml.gmm.GMM`

**References**

.. [1] Bilmes, J. A. (1998). "A gentle tutorial of the EM algorithm and its
application to parameter estimation for Gaussian mixture and hidden
Markov models" *International Computer Science Institute, 4(510)*
Expand Down
12 changes: 6 additions & 6 deletions docs/numpy_ml.lda.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
###########################
Latent Dirichlet allocation
Latent Dirichlet allocation
###########################

`Latent Dirichlet allocation`_ (LDA, commonly known as a topic model) is a
generative model for `bags of words`_.
generative model for `bags of words`_.

.. _`Latent Dirichlet allocation` : https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation
.. _bags of words : https://en.wikipedia.org/wiki/Bag-of-words_model
Expand Down Expand Up @@ -47,7 +47,7 @@ The smoothed/fully-Bayesian LDA model [2]_ adds an additional `Dirichlet`_ prior

To generate a document with the smoothed LDA model, we:

1. Sample the parameters for the distribution over topics,
1. Sample the parameters for the distribution over topics,
:math:`\theta \sim \text{Dir}(\alpha)`.

2. Sample a topic, :math:`z \sim \text{Cat}(\theta)`.
Expand All @@ -63,11 +63,11 @@ The joint distribution over words, topics, :math:`\theta`, and :math:`\phi`
under the smoothed LDA model is:

.. math::
P(w, z, \phi, \theta \mid \alpha, \beta) = \left( \prod_{t=1}^T \text{Dir}(\phi^{(t)}; \beta) \right) \prod_{d=1}^D \text{Dir}(\theta^{(d)}; \alpha) \prod_{n=1}^{N_d} P(z_n \mid \theta^{(d)}) P(w_n \mid \phi^{(z_n)})
P(w, z, \phi, \theta \mid \alpha, \beta) = \left( \prod_{t=1}^T \text{Dir}(\phi^{(t)}; \beta) \right) \prod_{d=1}^D \text{Dir}(\theta^{(d)}; \alpha) \prod_{n=1}^{N_d} P(z_n \mid \theta^{(d)}) P(w_n \mid \phi^{(z_n)})
The parameters of the LDA model can be learned using `variational expectation
maximization`_ or Markov chain Monte Carlo (e.g., `collapsed Gibbs sampling`_).
maximization`_ or Markov chain Monte Carlo (e.g., `collapsed Gibbs sampling`_).

.. _`variational expectation maximization`: https://en.wikipedia.org/wiki/Variational_Bayesian_methods
.. _`collapsed Gibbs sampling`: https://en.wikipedia.org/wiki/Gibbs_sampling#Collapsed_Gibbs_sampler
Expand Down
4 changes: 2 additions & 2 deletions docs/numpy_ml.linear_models.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Linear models
Linear models
#############

The linear models module contains several popular instances of the generalized linear model (GLM).
Expand Down Expand Up @@ -230,7 +230,7 @@ We can also compute a closed-form solution for the posterior predictive distribu
.. math::
y^* \mid X^*, X, Y \sim \mathcal{N}(X^* \mu_b, \ X^* \text{cov}_b X^{* \top} + I)
**Models**

- :class:`~numpy_ml.linear_models.BayesianLinearRegressionUnknownVariance`
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.initializers.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Initializers
Initializers
=============

``ActivationInitializer``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.layers.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Layers
Layers
======

``LayerBase``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.losses.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Loss functions
Loss functions
==============

``CrossEntropy``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.models.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Full networks
Full networks
==============

``WGAN_GP``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.schedulers.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Learning rate schedulers
Learning rate schedulers
=========================

``ConstantScheduler``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.utils.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Utilities
Utilities
==========

``minibatch``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.neural_nets.wrappers.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Wrappers
Wrappers
=========

``WrapperBase``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.ngram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ denote the `(j - i)`-gram :math:`(w_{i}, w_{i+1}, \ldots, w_{j})`.
<h3>Laplace Smoothing</h3>

`Laplace smoothing`_ is the assumption that each `n`-gram in a corpus occurs
exactly one more time than it actually does.
exactly one more time than it actually does.

.. math::
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.nonparametric.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Nonparametric models
Nonparametric models
####################

.. raw:: html
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.preprocessing.dsp.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Digital signal processing
Digital signal processing
#########################

``DCT``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.preprocessing.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Preprocessing
Preprocessing
#############

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.rl_models.agents.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Agents
Agents
======

``CrossEntropyAgent``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.rl_models.rl_utils.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Utilities
Utilities
=========

.. automodule:: numpy_ml.rl_models.rl_utils
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.rl_models.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Reinforcement learning
Reinforcement learning
######################

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.trees.losses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Losses (``trees.losses``)
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
:show-inheritance:
18 changes: 9 additions & 9 deletions docs/numpy_ml.trees.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Tree-based models
Tree-based models
#################
.. raw:: html

Expand Down Expand Up @@ -35,24 +35,24 @@ in an inhomogeneity or "impurity" metric, :math:`\mathcal{L}`. One popular
metric is the **information entropy**:

.. math::
-\sum_j P_n(\omega_j) \log P_n(\omega_j)
where :math:`P_n(\omega_j)` is the fraction of data points at split `n` that are
associated with category :math:`\omega_j`. Another useful metric is the **Gini
impurity**:

.. math::
\sum_{i \neq j} P_n(\omega_i) P_n(\omega_j) = 1 - \sum_{j} P_n(\omega_j)^2
For a binary tree (where each node has only two children), the reduction in
impurity after a particular split is

.. math::
\Delta \mathcal{L} = \mathcal{L}(\text{Parent}) -
P_{left} \mathcal{L}(\text{Left child}) -
\Delta \mathcal{L} = \mathcal{L}(\text{Parent}) -
P_{left} \mathcal{L}(\text{Left child}) -
(1 - P_{left})\mathcal{L}(\text{Right child})
where :math:`\mathcal{L}(x)` is the impurity of the dataset at node `x`,
Expand Down Expand Up @@ -88,7 +88,7 @@ aggregating. For this approach, each of the `n` learners is a different
decision tree. In addition to training each decision tree on a different
bootstrapped dataset, random forests employ a `random subspace`_ approach [5]_:
each decision tree is trained on a subsample (without replacement) of the full
collection of dataset features.
collection of dataset features.

.. _`Bootstrap aggregating`: https://en.wikipedia.org/wiki/Bootstrap_aggregating
.. _`random forest`: https://en.wikipedia.org/wiki/Random_forest
Expand All @@ -102,7 +102,7 @@ collection of dataset features.
**References**

.. [2] Breiman, L. (1994). "Bagging predictors". *Technical Report 421.
Statistics Department, UC Berkeley*.
Statistics Department, UC Berkeley*.
.. [3] Ho, T. K. (1995). "Random decision forests". *Proceedings of the Third
International Conference on Document Analysis and Recognition, 1*: 278-282.
.. [4] Breiman, L. (2001). "Random forests". *Machine Learning. 45(1)*: 5-32.
Expand Down Expand Up @@ -152,7 +152,7 @@ weak learners.
**References**

.. [6] Breiman, L. (1997). "Arcing the edge". *Technical Report 486.
Statistics Department, UC Berkeley*.
Statistics Department, UC Berkeley*.
.. [7] Friedman, J. H. (1999). "Greedy function approximation: A gradient
boosting machine". *IMS 1999 Reitz Lecture*.
.. [8] Mason, L., Baxter, J., Bartlett, P. L., Frean, M. (1999). "Boosting
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.utils.data_structures.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Data structures
Data structures
================

``BallTree``
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.utils.distance_metrics.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Distance metrics
Distance metrics
================

Common distance functions.
Expand Down
4 changes: 2 additions & 2 deletions docs/numpy_ml.utils.kernels.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Kernels
Kernels
=======

A collection of common kernel / similarity functions. All kernels are
continuous, bounded, and symmetric real functions which integrate to 1.
continuous, bounded, and symmetric real functions which integrate to 1.

``LinearKernel``
----------------
Expand Down
2 changes: 1 addition & 1 deletion docs/numpy_ml.utils.testing.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Testing
Testing
-------
Common helper functions for testing the ML algorithms in the rest of the repo.

Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
numpy
scipy
scipy

# all this is for the dang tests
matplotlib
matplotlib
seaborn
pandas
sklearn
Expand Down
Loading

0 comments on commit 9877898

Please sign in to comment.