Package mdp :: Package nodes :: Class LatentDirichletAllocationScikitsLearnNode
[hide private]
[frames] | no frames]

Class LatentDirichletAllocationScikitsLearnNode



Latent Dirichlet Allocation with online variational Bayes algorithm

This node has been automatically generated by wrapping the ``sklearn.decomposition.online_lda.LatentDirichletAllocation`` class
from the ``sklearn`` library.  The wrapped instance can be accessed
through the ``scikits_alg`` attribute.

.. versionadded:: 0.17

**Parameters**

n_topics : int, optional (default=10)
    Number of topics.

doc_topic_prior : float, optional (default=None)
    Prior of document topic distribution `theta`. If the value is None,
    defaults to `1 / n_topics`.
    In the literature, this is called `alpha`.

topic_word_prior : float, optional (default=None)
    Prior of topic word distribution `beta`. If the value is None, defaults
    to `1 / n_topics`.
    In the literature, this is called `eta`.

learning_method : 'batch' | 'online', default='online'
    Method used to update `_component`. Only used in `fit` method.
    In general, if the data size is large, the online update will be much
    faster than the batch update.
    Valid options::


        'batch': Batch variational Bayes method. Use all training data in
            each EM update.
            Old `components_` will be overwritten in each iteration.
        'online': Online variational Bayes method. In each EM update, use
            mini-batch of training data to update the ``components_``
            variable incrementally. The learning rate is controlled by the
            ``learning_decay`` and the ``learning_offset`` parameters.

learning_decay : float, optional (default=0.7)
    It is a parameter that control learning rate in the online learning
    method. The value should be set between (0.5, 1.0] to guarantee
    asymptotic convergence. When the value is 0.0 and batch_size is
    ``n_samples``, the update method is same as batch learning. In the
    literature, this is called kappa.

learning_offset : float, optional (default=10.)
    A (positive) parameter that downweights early iterations in online
    learning.  It should be greater than 1.0. In the literature, this is
    called tau_0.

max_iter : integer, optional (default=10)
    The maximum number of iterations.

total_samples : int, optional (default=1e6)
    Total number of documents. Only used in the `partial_fit` method.

batch_size : int, optional (default=128)
    Number of documents to use in each EM iteration. Only used in online
    learning.

evaluate_every : int optional (default=0)
    How often to evaluate perplexity. Only used in `fit` method.
    set it to 0 or and negative number to not evalute perplexity in
    training at all. Evaluating perplexity can help you check convergence
    in training process, but it will also increase total training time.
    Evaluating perplexity in every iteration might increase training time
    up to two-fold.

perp_tol : float, optional (default=1e-1)
    Perplexity tolerance in batch learning. Only used when
    ``evaluate_every`` is greater than 0.

mean_change_tol : float, optional (default=1e-3)
    Stopping tolerance for updating document topic distribution in E-step.

max_doc_update_iter : int (default=100)
    Max number of iterations for updating document topic distribution in
    the E-step.

n_jobs : int, optional (default=1)
    The number of jobs to use in the E-step. If -1, all CPUs are used. For
    ``n_jobs`` below -1, (n_cpus + 1 + n_jobs) are used.

verbose : int, optional (default=0)
    Verbosity level.

random_state : int or RandomState instance or None, optional (default=None)
    Pseudo-random number generator seed control.

**Attributes**

``components_`` : array, [n_topics, n_features]
    Topic word distribution. ``components_[i, j]`` represents word j in
    topic `i`. In the literature, this is called lambda.

``n_batch_iter_`` : int
    Number of iterations of the EM step.

``n_iter_`` : int
    Number of passes over the dataset.

**References**

[1] "Online Learning for Latent Dirichlet Allocation", Matthew D. Hoffman,
    David M. Blei, Francis Bach, 2010

[2] "Stochastic Variational Inference", Matthew D. Hoffman, David M. Blei,
    Chong Wang, John Paisley, 2013

[3] Matthew D. Hoffman's onlineldavb code. Link:

    - http://www.cs.princeton.edu/~mdhoffma/code/onlineldavb.tar

Instance Methods [hide private]
 
__init__(self, input_dim=None, output_dim=None, dtype=None, **kwargs)
Latent Dirichlet Allocation with online variational Bayes algorithm
 
_execute(self, x)
 
_get_supported_dtypes(self)
Return the list of dtypes supported by this node. The types can be specified in any format allowed by numpy.dtype.
 
_stop_training(self, **kwargs)
Concatenate the collected data in a single array.
 
execute(self, x)
Transform data X according to the fitted model.
 
stop_training(self, **kwargs)
Learn model for the data X with variational Bayes method.

Inherited from unreachable.newobject: __long__, __native__, __nonzero__, __unicode__, next

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

    Inherited from Cumulator
 
_train(self, *args)
Collect all input data in a list.
 
train(self, *args)
Collect all input data in a list.
    Inherited from Node
 
__add__(self, other)
 
__call__(self, x, *args, **kwargs)
Calling an instance of Node is equivalent to calling its execute method.
 
__repr__(self)
repr(x)
 
__str__(self)
str(x)
 
_check_input(self, x)
 
_check_output(self, y)
 
_check_train_args(self, x, *args, **kwargs)
 
_get_train_seq(self)
 
_if_training_stop_training(self)
 
_inverse(self, x)
 
_pre_execution_checks(self, x)
This method contains all pre-execution checks.
 
_pre_inversion_checks(self, y)
This method contains all pre-inversion checks.
 
_refcast(self, x)
Helper function to cast arrays to the internal dtype.
 
_set_dtype(self, t)
 
_set_input_dim(self, n)
 
_set_output_dim(self, n)
 
copy(self, protocol=None)
Return a deep copy of the node.
 
get_current_train_phase(self)
Return the index of the current training phase.
 
get_dtype(self)
Return dtype.
 
get_input_dim(self)
Return input dimensions.
 
get_output_dim(self)
Return output dimensions.
 
get_remaining_train_phase(self)
Return the number of training phases still to accomplish.
 
get_supported_dtypes(self)
Return dtypes supported by the node as a list of dtype objects.
 
has_multiple_training_phases(self)
Return True if the node has multiple training phases.
 
inverse(self, y, *args, **kwargs)
Invert y.
 
is_training(self)
Return True if the node is in the training phase, False otherwise.
 
save(self, filename, protocol=-1)
Save a pickled serialization of the node to filename. If filename is None, return a string.
 
set_dtype(self, t)
Set internal structures' dtype.
 
set_input_dim(self, n)
Set input dimensions.
 
set_output_dim(self, n)
Set output dimensions.
Static Methods [hide private]
 
is_invertible()
Return True if the node can be inverted, False otherwise.
 
is_trainable()
Return True if the node can be trained, False otherwise.
Properties [hide private]

Inherited from object: __class__

    Inherited from Node
  _train_seq
List of tuples:
  dtype
dtype
  input_dim
Input dimensions
  output_dim
Output dimensions
  supported_dtypes
Supported dtypes
Method Details [hide private]

__init__(self, input_dim=None, output_dim=None, dtype=None, **kwargs)
(Constructor)

 

Latent Dirichlet Allocation with online variational Bayes algorithm

This node has been automatically generated by wrapping the ``sklearn.decomposition.online_lda.LatentDirichletAllocation`` class
from the ``sklearn`` library.  The wrapped instance can be accessed
through the ``scikits_alg`` attribute.

.. versionadded:: 0.17

**Parameters**

n_topics : int, optional (default=10)
    Number of topics.

doc_topic_prior : float, optional (default=None)
    Prior of document topic distribution `theta`. If the value is None,
    defaults to `1 / n_topics`.
    In the literature, this is called `alpha`.

topic_word_prior : float, optional (default=None)
    Prior of topic word distribution `beta`. If the value is None, defaults
    to `1 / n_topics`.
    In the literature, this is called `eta`.

learning_method : 'batch' | 'online', default='online'
    Method used to update `_component`. Only used in `fit` method.
    In general, if the data size is large, the online update will be much
    faster than the batch update.
    Valid options::


        'batch': Batch variational Bayes method. Use all training data in
            each EM update.
            Old `components_` will be overwritten in each iteration.
        'online': Online variational Bayes method. In each EM update, use
            mini-batch of training data to update the ``components_``
            variable incrementally. The learning rate is controlled by the
            ``learning_decay`` and the ``learning_offset`` parameters.

learning_decay : float, optional (default=0.7)
    It is a parameter that control learning rate in the online learning
    method. The value should be set between (0.5, 1.0] to guarantee
    asymptotic convergence. When the value is 0.0 and batch_size is
    ``n_samples``, the update method is same as batch learning. In the
    literature, this is called kappa.

learning_offset : float, optional (default=10.)
    A (positive) parameter that downweights early iterations in online
    learning.  It should be greater than 1.0. In the literature, this is
    called tau_0.

max_iter : integer, optional (default=10)
    The maximum number of iterations.

total_samples : int, optional (default=1e6)
    Total number of documents. Only used in the `partial_fit` method.

batch_size : int, optional (default=128)
    Number of documents to use in each EM iteration. Only used in online
    learning.

evaluate_every : int optional (default=0)
    How often to evaluate perplexity. Only used in `fit` method.
    set it to 0 or and negative number to not evalute perplexity in
    training at all. Evaluating perplexity can help you check convergence
    in training process, but it will also increase total training time.
    Evaluating perplexity in every iteration might increase training time
    up to two-fold.

perp_tol : float, optional (default=1e-1)
    Perplexity tolerance in batch learning. Only used when
    ``evaluate_every`` is greater than 0.

mean_change_tol : float, optional (default=1e-3)
    Stopping tolerance for updating document topic distribution in E-step.

max_doc_update_iter : int (default=100)
    Max number of iterations for updating document topic distribution in
    the E-step.

n_jobs : int, optional (default=1)
    The number of jobs to use in the E-step. If -1, all CPUs are used. For
    ``n_jobs`` below -1, (n_cpus + 1 + n_jobs) are used.

verbose : int, optional (default=0)
    Verbosity level.

random_state : int or RandomState instance or None, optional (default=None)
    Pseudo-random number generator seed control.

**Attributes**

``components_`` : array, [n_topics, n_features]
    Topic word distribution. ``components_[i, j]`` represents word j in
    topic `i`. In the literature, this is called lambda.

``n_batch_iter_`` : int
    Number of iterations of the EM step.

``n_iter_`` : int
    Number of passes over the dataset.

**References**

[1] "Online Learning for Latent Dirichlet Allocation", Matthew D. Hoffman,
    David M. Blei, Francis Bach, 2010

[2] "Stochastic Variational Inference", Matthew D. Hoffman, David M. Blei,
    Chong Wang, John Paisley, 2013

[3] Matthew D. Hoffman's onlineldavb code. Link:

    - http://www.cs.princeton.edu/~mdhoffma/code/onlineldavb.tar

Overrides: object.__init__

_execute(self, x)

 
Overrides: Node._execute

_get_supported_dtypes(self)

 
Return the list of dtypes supported by this node. The types can be specified in any format allowed by numpy.dtype.
Overrides: Node._get_supported_dtypes

_stop_training(self, **kwargs)

 
Concatenate the collected data in a single array.
Overrides: Node._stop_training

execute(self, x)

 

Transform data X according to the fitted model.

This node has been automatically generated by wrapping the sklearn.decomposition.online_lda.LatentDirichletAllocation class from the sklearn library. The wrapped instance can be accessed through the scikits_alg attribute.

Parameters

X : array-like or sparse matrix, shape=(n_samples, n_features)
Document word matrix.

Returns

doc_topic_distr : shape=(n_samples, n_topics)
Document topic distribution for X.
Overrides: Node.execute

is_invertible()
Static Method

 
Return True if the node can be inverted, False otherwise.
Overrides: Node.is_invertible
(inherited documentation)

is_trainable()
Static Method

 
Return True if the node can be trained, False otherwise.
Overrides: Node.is_trainable

stop_training(self, **kwargs)

 

Learn model for the data X with variational Bayes method.

This node has been automatically generated by wrapping the sklearn.decomposition.online_lda.LatentDirichletAllocation class from the sklearn library. The wrapped instance can be accessed through the scikits_alg attribute.

When learning_method is 'online', use mini-batch update. Otherwise, use batch update.

Parameters

X : array-like or sparse matrix, shape=(n_samples, n_features)
Document word matrix.

Returns

self

Overrides: Node.stop_training