ó
‡ˆ\c           @   s(  d  Z  d d l Z d d l j Z d d l m Z d d l Z d d l	 m
 Z
 m Z d d l m Z m Z m Z m Z d d l m Z d d l m Z d d	 l m Z m Z m Z d d
 l m Z d d l m Z d d l m Z m Z m  Z  e j! e j" ƒ j# Z$ d „  Z% d e
 e f d „  ƒ  YZ& d S(   s6  

=============================================================
Online Latent Dirichlet Allocation with variational inference
=============================================================

This implementation is modified from Matthew D. Hoffman's onlineldavb code
Link: https://github.com/blei-lab/onlineldavb
iÿÿÿÿN(   t   gammalni   (   t   BaseEstimatort   TransformerMixin(   t   check_random_statet   check_arrayt   gen_batchest   gen_even_slices(   t	   logsumexp(   t   check_non_negative(   t   Parallelt   delayedt   effective_n_jobs(   t   xrange(   t   NotFittedErrori   (   t   mean_changet   _dirichlet_expectation_1dt   _dirichlet_expectation_2dc         C   so  t  j |  ƒ } |  j \ } }	 | j d }
 | rO | j d d | |
 f ƒ } n t j | |
 f ƒ } t j t | ƒ ƒ } | r‘ t j | j ƒ n d } | r» |  j
 } |  j } |  j } n  x§t | ƒ D]™} | r	| | | | | d !} | | | | | d !} n3 t j |  | d d … f ƒ d } |  | | f } | | d d … f } | | d d … f j ƒ  } | d d … | f } xy t d | ƒ D]h } | } t j | | ƒ t } | t j | | | j ƒ } t | | | ƒ t | | ƒ | k  r”Pq”q”W| | | d d … f <| rÈ t j | | ƒ t } | d d … | f c t j | | | ƒ 7<qÈ qÈ W| | f S(   s¬  E-step: update document-topic distribution.

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

    exp_topic_word_distr : dense matrix, shape=(n_topics, n_features)
        Exponential value of expectation of log topic word distribution.
        In the literature, this is `exp(E[log(beta)])`.

    doc_topic_prior : float
        Prior of document topic distribution `theta`.

    max_iters : int
        Max number of iterations for updating document topic distribution in
        the E-step.

    mean_change_tol : float
        Stopping tolerance for updating document topic distribution in E-setp.

    cal_sstats : boolean
        Parameter that indicate to calculate sufficient statistics or not.
        Set `cal_sstats` to `True` when we need to run M-step.

    random_state : RandomState instance or None
        Parameter that indicate how to initialize document topic distribution.
        Set `random_state` to None will initialize document topic distribution
        to a constant number.

    Returns
    -------
    (doc_topic_distr, suff_stats) :
        `doc_topic_distr` is unnormalized topic distribution for each document.
        In the literature, this is `gamma`. we can calculate `E[log(theta)]`
        from it.
        `suff_stats` is expected sufficient statistics for the M-step.
            When `cal_sstats == False`, this will be None.

    i    g      Y@g{®Gáz„?i   N(   t   spt   issparset   shapet   gammat   npt   onest   expR   t   zerost   Nonet   datat   indicest   indptrR   t   nonzerot   copyt   dott   EPSt   TR   R   t   outer(   t   Xt   exp_topic_word_distrt   doc_topic_priort	   max_iterst   mean_change_tolt
   cal_sstatst   random_statet   is_sparse_xt	   n_samplest
   n_featurest   n_topicst   doc_topic_distrt   exp_doc_topict
   suff_statst   X_datat	   X_indicest   X_indptrt   idx_dt   idst   cntst   doc_topic_dt   exp_doc_topic_dt   exp_topic_word_dt   _t   last_dt   norm_phi(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _update_doc_distribution"   sF    +		#	3t   LatentDirichletAllocationc           B   sÚ   e  Z d  Z d d d d d d d d d d d d	 d
 d d d d d „ Z d „  Z d „  Z d d „ Z d d „ Z d „  Z	 d d „ Z
 d d „ Z d „  Z d „  Z d „  Z d d „ Z d e d „ Z d e d „ Z RS(   s…  Latent Dirichlet Allocation with online variational Bayes algorithm

    .. versionadded:: 0.17

    Read more in the :ref:`User Guide <LatentDirichletAllocation>`.

    Parameters
    ----------
    n_components : 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_components`.
        In [1]_, 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_components`.
        In [1]_, this is called `eta`.

    learning_method : 'batch' | 'online', default='batch'
        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.

        .. versionchanged:: 0.20
            The default learning method is now ``"batch"``.

    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.

    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 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.

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

    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 or None, optional (default=None)
        The number of jobs to use in the E-step.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

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

    random_state : int, RandomState instance or None, optional (default=None)
        If int, random_state is the seed used by the random number generator;
        If RandomState instance, random_state is the random number generator;
        If None, the random number generator is the RandomState instance used
        by `np.random`.

    n_topics : int, optional (default=None)
        This parameter has been renamed to n_components and will
        be removed in version 0.21.
        .. deprecated:: 0.19

    Attributes
    ----------
    components_ : array, [n_components, n_features]
        Variational parameters for topic word distribution. Since the complete
        conditional for topic word distribution is a Dirichlet,
        ``components_[i, j]`` can be viewed as pseudocount that represents the
        number of times word `j` was assigned to topic `i`.
        It can also be viewed as distribution over the words for each topic
        after normalization:
        ``model.components_ / model.components_.sum(axis=1)[:, np.newaxis]``.

    n_batch_iter_ : int
        Number of iterations of the EM step.

    n_iter_ : int
        Number of passes over the dataset.

    Examples
    --------
    >>> from sklearn.decomposition import LatentDirichletAllocation
    >>> from sklearn.datasets import make_multilabel_classification
    >>> # This produces a feature matrix of token counts, similar to what
    >>> # CountVectorizer would produce on text.
    >>> X, _ = make_multilabel_classification(random_state=0)
    >>> lda = LatentDirichletAllocation(n_components=5,
    ...     random_state=0)
    >>> lda.fit(X) # doctest: +ELLIPSIS
    LatentDirichletAllocation(...)
    >>> # get topics for some given samples:
    >>> lda.transform(X[-2:])
    array([[0.00360392, 0.25499205, 0.0036211 , 0.64236448, 0.09541846],
           [0.15297572, 0.00362644, 0.44412786, 0.39568399, 0.003586  ]])

    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:
        https://github.com/blei-lab/onlineldavb

    i
   t   batchgffffffæ?g      $@i€   iÿÿÿÿg    €„.Agš™™™™™¹?gü©ñÒMbP?id   i    c         C   s   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ |
 |  _	 | |  _
 | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   n_componentsR%   t   topic_word_priort   learning_methodt   learning_decayt   learning_offsett   max_itert
   batch_sizet   evaluate_everyt   total_samplest   perp_tolR'   t   max_doc_update_itert   n_jobst   verboseR)   R-   (   t   selfR@   R%   RA   RB   RC   RD   RE   RF   RG   RH   RI   R'   RJ   RK   RL   R)   R-   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   __init__  s"    																c         C   sÒ   |  j  d	 k	 r. |  j  |  _ t j d t ƒ n |  j |  _ |  j d k r_ t d |  j ƒ ‚ n  |  j d k r„ t d |  j ƒ ‚ n  |  j	 d k  r© t d |  j	 ƒ ‚ n  |  j
 d
 k rÎ t d |  j
 ƒ ‚ n  d	 S(   s   Check model parameters.sU   n_topics has been renamed to n_components in version 0.19 and will be removed in 0.21i    s$   Invalid 'n_components' parameter: %rs%   Invalid 'total_samples' parameter: %rs'   Invalid 'learning_offset' parameter: %rR?   t   onlines'   Invalid 'learning_method' parameter: %rN(   R?   RO   (   R-   R   t   _n_componentst   warningst   warnt   DeprecationWarningR@   t
   ValueErrorRH   RD   RB   (   RM   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _check_params4  s"    	
c         C   sÓ   t  |  j ƒ |  _ d |  _ d |  _ |  j d k rF d |  j |  _ n |  j |  _ |  j	 d k rt d |  j |  _
 n |  j	 |  _
 d } d | } |  j j | | |  j | f ƒ |  _ t j t |  j ƒ ƒ |  _ d S(   s   Initialize latent variables.i   i    g      ð?g      Y@N(   R   R)   t   random_state_t   n_batch_iter_t   n_iter_R%   R   RP   t   doc_topic_prior_RA   t   topic_word_prior_R   t   components_R   R   R   t   exp_dirichlet_component_(   RM   R,   t
   init_gammat   init_var(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _init_latent_varsN  s    		
	c            s  | r ˆ j  n d ‰ t ˆ j ƒ } | d k rX t d | d t d ˆ j d ƒ ƒ } n  | ‡  ‡ ‡ ‡ f d †  t ˆ  j d | ƒ Dƒ ƒ } t	 | Œ  \ } } t
 j | ƒ }	 ˆ rô t
 j ˆ j j ƒ }
 x | D] } |
 | 7}
 qÐ W|
 ˆ j 9}
 n d }
 |	 |
 f S(   sí  E-step in EM update.

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

        cal_sstats : boolean
            Parameter that indicate whether to calculate sufficient statistics
            or not. Set ``cal_sstats`` to True when we need to run M-step.

        random_init : boolean
            Parameter that indicate whether to initialize document topic
            distribution randomly in the E-step. Set it to True in training
            steps.

        parallel : joblib.Parallel (optional)
            Pre-initialized instance of joblib.Parallel.

        Returns
        -------
        (doc_topic_distr, suff_stats) :
            `doc_topic_distr` is unnormalized topic distribution for each
            document. In the literature, this is called `gamma`.
            `suff_stats` is expected sufficient statistics for the M-step.
            When `cal_sstats == False`, it will be None.

        RK   RL   i    i   c      	   3   sO   |  ]E } t  t ƒ ˆ  | d  d  … f ˆ j ˆ j ˆ j ˆ j ˆ ˆ ƒ Vq d  S(   N(   R
   R=   R\   RY   RJ   R'   (   t   .0t	   idx_slice(   R#   R(   R)   RM   (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pys	   <genexpr>  s   N(   RV   R   R   RK   R	   t   maxRL   R   R   t   zipR   t   vstackR   R[   R\   (   RM   R#   R(   t   random_initt   parallelRK   t   resultst
   doc_topicst   sstats_listR.   R0   t   sstats(    (   R#   R(   R)   RM   s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _e_stepi  s"    c   	      C   sÖ   |  j  | d t d t d | ƒ\ } } | r@ |  j | |  _ nh t j |  j |  j |  j ƒ } t	 | ƒ | j
 d } |  j d | 9_ |  j | |  j | | 7_ t j t |  j ƒ ƒ |  _ |  j d 7_ d S(   sù  EM update for 1 iteration.

        update `_component` by batch VB or online VB.

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

        total_samples : integer
            Total number of documents. It is only used when
            batch_update is `False`.

        batch_update : boolean
            Parameter that controls updating method.
            `True` for batch learning, `False` for online learning.

        parallel : joblib.Parallel
            Pre-initialized instance of joblib.Parallel

        Returns
        -------
        doc_topic_distr : array, shape=(n_samples, n_components)
            Unnormalized document topic distribution.
        R(   Re   Rf   i    i   N(   Rk   t   TrueRZ   R[   R   t   powerRD   RW   RC   t   floatR   R   R   R\   (	   RM   R#   RH   t   batch_updateRf   R:   R0   t   weightt	   doc_ratio(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _em_step¨  s    c         C   s#   t  | d d ƒ} t | | ƒ | S(   s¦   check X format

        check X format and make sure no negative value in X.

        Parameters
        ----------
        X :  array-like or sparse matrix

        t   accept_sparset   csr(   R   R   (   RM   R#   t   whom(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _check_non_neg_arrayÚ  s    
c   	      C   s  |  j  ƒ  |  j | d ƒ } | j \ } } |  j } t |  d ƒ sS |  j | ƒ n  | |  j j d k rŒ t d | |  j j d f ƒ ‚ n  t |  j	 ƒ } t
 d | d t d |  j d ƒ ƒ S } xI t | | ƒ D]8 } |  j | | d d … f d	 |  j d
 t d | ƒqÓ WWd QX|  S(   sý   Online VB with Mini-Batch update.

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

        y : Ignored

        Returns
        -------
        self
        s%   LatentDirichletAllocation.partial_fitR[   i   sU   The provided data has %d dimensions while the model was trained with feature size %d.RK   RL   i    NRH   Ro   Rf   (   RU   Rv   R   RF   t   hasattrR_   R[   RT   R   RK   R	   Rb   RL   R   Rr   RH   t   False(	   RM   R#   t   yR+   R,   RF   RK   Rf   Ra   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   partial_fitè  s(    
				c         C   sN  |  j  ƒ  |  j | d ƒ } | j \ } } |  j } |  j } |  j } |  j } |  j | ƒ d }	 t	 |  j
 ƒ }
 t d |
 d t d |  j d ƒ ƒ p} xft | ƒ D]X} | d k rxh t | | ƒ D]5 } |  j | | d d … f d | d	 t d
 | ƒqÈ Wn |  j | d | d	 t d
 | ƒ| d k rÐ| d | d k rÐ|  j | d t d t d
 | ƒ\ } } |  j | | d t ƒ} |  j r¤d | d | | f GHn  |	 rÇt |	 | ƒ |  j k  rÇPn  | }	 n |  j rïd | d | f GHn  |  j d 7_ q¦ WWd QX|  j | d t d t d
 | ƒ\ } } |  j | | d t ƒ|  _ |  S(   s~  Learn model for the data X with variational Bayes method.

        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.

        y : Ignored

        Returns
        -------
        self
        s   LatentDirichletAllocation.fitRK   RL   i    i   RO   NRH   Ro   Rf   R(   Re   t   sub_samplings/   iteration: %d of max_iter: %d, perplexity: %.4fs   iteration: %d of max_iter: %d(   RU   Rv   R   RE   RG   RB   RF   R_   R   R   RK   R	   Rb   RL   R   R   Rr   Rx   Rl   Rk   t   _perplexity_precomp_distrt   absRI   RX   t   bound_(   RM   R#   Ry   R+   R,   RE   RG   RB   RF   t
   last_boundRK   Rf   t   iRa   t   doc_topics_distrR:   t   bound(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   fit  sP    
				" 				c         C   s   t  |  d ƒ s t d ƒ ‚ n  |  j | d ƒ } | j \ } } | |  j j d k rx t d | |  j j d f ƒ ‚ n  |  j | d t d t ƒ\ } } | S(   sN  Transform data X according to fitted model.

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

        Returns
        -------
        doc_topic_distr : shape=(n_samples, n_components)
            Document topic distribution for X.
        R[   s<   no 'components_' attribute in model. Please fit model first.s#   LatentDirichletAllocation.transformi   sU   The provided data has %d dimensions while the model was trained with feature size %d.R(   Re   (   Rw   R   Rv   R   R[   RT   Rk   Rx   (   RM   R#   R+   R,   R.   R:   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _unnormalized_transformX  s    c         C   s<   |  j  | ƒ } | | j d d ƒ d d … t j f :} | S(   s©  Transform data X according to the fitted model.

           .. versionchanged:: 0.18
              *doc_topic_distr* is now normalized

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

        Returns
        -------
        doc_topic_distr : shape=(n_samples, n_components)
            Document topic distribution for X.
        t   axisi   N(   R„   t   sumR   t   newaxis(   RM   R#   R.   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt	   transformw  s    )c         C   sÐ  d „  } t  j | ƒ } | j \ } } |  j j d } d }	 t | ƒ }
 t |  j ƒ } |  j } |  j } | rŽ | j } | j } | j	 } n  xÝ t
 d | ƒ D]Ì } | rß | | | | | d !} | | | | | d !} n3 t j | | d d … f ƒ d } | | | f } |
 | d d … t j f | d d … | f } t | d d ƒ} |	 t j | | ƒ 7}	 qž W|	 | | | |
 |  j ƒ 7}	 | r°t |  j ƒ | } |	 | 9}	 n  |	 | | |  j | | ƒ 7}	 |	 S(   s  Estimate the variational bound.

        Estimate the variational bound over "all documents" using only the
        documents passed in as X. Since log-likelihood of each word cannot
        be computed directly, we use this bound to estimate it.

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

        doc_topic_distr : array, shape=(n_samples, n_components)
            Document topic distribution. In the literature, this is called
            gamma.

        sub_sampling : boolean, optional, (default=False)
            Compensate for subsampling of documents.
            It is used in calculate bound in online learning.

        Returns
        -------
        score : float

        c         S   sq   t  j |  | | ƒ } | t  j t | ƒ t |  ƒ ƒ 7} | t  j t |  | ƒ t t  j | d ƒ ƒ ƒ 7} | S(   Ni   (   R   R†   R    (   t   priort   distrt   dirichlet_distrt   sizet   score(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _loglikelihood¥  s    #3i   i    NR…   (   R   R   R   R[   R   RY   RZ   R   R   R   R   R   R   R‡   R   R   RP   Rn   RH   (   RM   R#   R.   R{   RŽ   R*   R+   R@   R,   R   t   dirichlet_doc_topict   dirichlet_component_R%   RA   R1   R2   R3   R4   R5   R6   t   tempR<   Rq   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   _approx_bound‹  s>    					#c         C   s=   |  j  | d ƒ } |  j | ƒ } |  j | | d t ƒ} | S(   s?  Calculate approximate log-likelihood as score.

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

        y : Ignored

        Returns
        -------
        score : float
            Use approximate bound as score.
        s   LatentDirichletAllocation.scoreR{   (   Rv   R„   R’   Rx   (   RM   R#   Ry   R.   R   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyR   ×  s    c   
      C   s  t  |  d ƒ s t d ƒ ‚ n  |  j | d ƒ } | d k rN |  j | ƒ } nO | j \ } } | | j d k r t d ƒ ‚ n  | |  j k r t d ƒ ‚ n  | j d } |  j | | | ƒ } | rå | j	 ƒ  t
 |  j ƒ | } n | j	 ƒ  } | | }	 t j d |	 ƒ S(	   sR  Calculate approximate perplexity for data X with ability to accept
        precomputed doc_topic_distr

        Perplexity is defined as exp(-1. * log-likelihood per word)

        Parameters
        ----------
        X : array-like or sparse matrix, [n_samples, n_features]
            Document word matrix.

        doc_topic_distr : None or array, shape=(n_samples, n_components)
            Document topic distribution.
            If it is None, it will be generated by applying transform on X.

        Returns
        -------
        score : float
            Perplexity score.
        R[   s<   no 'components_' attribute in model. Please fit model first.s$   LatentDirichletAllocation.perplexityi    s8   Number of samples in X and doc_topic_distr do not match.s    Number of topics does not match.g      ð¿N(   Rw   R   Rv   R   R„   R   RT   RP   R’   R†   Rn   RH   R   R   (
   RM   R#   R.   R{   R+   R@   t   current_samplesR‚   t   word_cntt   perword_bound(    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyR|   ì  s$    		 
t
   deprecatedc         C   s2   | d k r t  j d t ƒ n  |  j | d | ƒS(   s,  Calculate approximate perplexity for data X.

        Perplexity is defined as exp(-1. * log-likelihood per word)

        .. versionchanged:: 0.19
           *doc_topic_distr* argument has been deprecated and is ignored
           because user no longer has access to unnormalized distribution

        Parameters
        ----------
        X : array-like or sparse matrix, [n_samples, n_features]
            Document word matrix.

        doc_topic_distr : None or array, shape=(n_samples, n_components)
            Document topic distribution.
            This argument is deprecated and is currently being ignored.

            .. deprecated:: 0.19

        sub_sampling : bool
            Do sub-sampling or not.

        Returns
        -------
        score : float
            Perplexity score.
        R–   s|   Argument 'doc_topic_distr' is deprecated and is being ignored as of 0.19. Support for this argument will be removed in 0.21.R{   (   RQ   RR   RS   R|   (   RM   R#   R.   R{   (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt
   perplexity  s    	
N(   t   __name__t
   __module__t   __doc__R   RN   RU   R_   Rk   Rr   Rv   Rz   Rƒ   R„   Rˆ   R’   R   Rx   R|   R—   (    (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyR>   ‰   s*   ‘					?2	)G			L1('   Rš   t   numpyR   t   scipy.sparset   sparseR   t   scipy.specialR    RQ   t   baseR   R   t   utilsR   R   R   R   t   utils.fixesR   t   utils.validationR   t   utils._joblibR	   R
   R   t   externals.six.movesR   t
   exceptionsR   t   _online_ldaR   R   R   t   finfoRn   t   epsR    R=   R>   (    (    (    s?   lib/python2.7/site-packages/sklearn/decomposition/online_lda.pyt   <module>	   s   "	g