@@ -230,11 +230,6 @@ class LatentDirichletAllocation(BaseEstimator, TransformerMixin):
230230 If None, the random number generator is the RandomState instance used
231231 by `np.random`.
232232
233- n_topics : int, optional (default=None)
234- This parameter has been renamed to n_components and will
235- be removed in version 0.21.
236- .. deprecated:: 0.19
237-
238233 Attributes
239234 ----------
240235 components_ : array, [n_components, n_features]
@@ -286,7 +281,7 @@ def __init__(self, n_components=10, doc_topic_prior=None,
286281 learning_decay = .7 , learning_offset = 10. , max_iter = 10 ,
287282 batch_size = 128 , evaluate_every = - 1 , total_samples = 1e6 ,
288283 perp_tol = 1e-1 , mean_change_tol = 1e-3 , max_doc_update_iter = 100 ,
289- n_jobs = None , verbose = 0 , random_state = None , n_topics = None ):
284+ n_jobs = None , verbose = 0 , random_state = None ):
290285 self .n_components = n_components
291286 self .doc_topic_prior = doc_topic_prior
292287 self .topic_word_prior = topic_word_prior
@@ -303,21 +298,12 @@ def __init__(self, n_components=10, doc_topic_prior=None,
303298 self .n_jobs = n_jobs
304299 self .verbose = verbose
305300 self .random_state = random_state
306- self .n_topics = n_topics
307301
308302 def _check_params (self ):
309303 """Check model parameters."""
310- if self .n_topics is not None :
311- self ._n_components = self .n_topics
312- warnings .warn ("n_topics has been renamed to n_components in "
313- "version 0.19 and will be removed in 0.21" ,
314- DeprecationWarning )
315- else :
316- self ._n_components = self .n_components
317-
318- if self ._n_components <= 0 :
304+ if self .n_components <= 0 :
319305 raise ValueError ("Invalid 'n_components' parameter: %r"
320- % self ._n_components )
306+ % self .n_components )
321307
322308 if self .total_samples <= 0 :
323309 raise ValueError ("Invalid 'total_samples' parameter: %r"
@@ -339,20 +325,20 @@ def _init_latent_vars(self, n_features):
339325 self .n_iter_ = 0
340326
341327 if self .doc_topic_prior is None :
342- self .doc_topic_prior_ = 1. / self ._n_components
328+ self .doc_topic_prior_ = 1. / self .n_components
343329 else :
344330 self .doc_topic_prior_ = self .doc_topic_prior
345331
346332 if self .topic_word_prior is None :
347- self .topic_word_prior_ = 1. / self ._n_components
333+ self .topic_word_prior_ = 1. / self .n_components
348334 else :
349335 self .topic_word_prior_ = self .topic_word_prior
350336
351337 init_gamma = 100.
352338 init_var = 1. / init_gamma
353339 # In the literature, this is called `lambda`
354340 self .components_ = self .random_state_ .gamma (
355- init_gamma , init_var , (self ._n_components , n_features ))
341+ init_gamma , init_var , (self .n_components , n_features ))
356342
357343 # In the literature, this is `exp(E[log(beta)])`
358344 self .exp_dirichlet_component_ = np .exp (
@@ -711,7 +697,7 @@ def _loglikelihood(prior, distr, dirichlet_distr, size):
711697
712698 # compute E[log p(theta | alpha) - log q(theta | gamma)]
713699 score += _loglikelihood (doc_topic_prior , doc_topic_distr ,
714- dirichlet_doc_topic , self ._n_components )
700+ dirichlet_doc_topic , self .n_components )
715701
716702 # Compensate for the subsampling of the population of documents
717703 if sub_sampling :
@@ -781,7 +767,7 @@ def _perplexity_precomp_distr(self, X, doc_topic_distr=None,
781767 raise ValueError ("Number of samples in X and doc_topic_distr"
782768 " do not match." )
783769
784- if n_components != self ._n_components :
770+ if n_components != self .n_components :
785771 raise ValueError ("Number of topics does not match." )
786772
787773 current_samples = X .shape [0 ]
@@ -795,7 +781,7 @@ def _perplexity_precomp_distr(self, X, doc_topic_distr=None,
795781
796782 return np .exp (- 1.0 * perword_bound )
797783
798- def perplexity (self , X , doc_topic_distr = 'deprecated' , sub_sampling = False ):
784+ def perplexity (self , X , sub_sampling = False ):
799785 """Calculate approximate perplexity for data X.
800786
801787 Perplexity is defined as exp(-1. * log-likelihood per word)
@@ -823,10 +809,4 @@ def perplexity(self, X, doc_topic_distr='deprecated', sub_sampling=False):
823809 score : float
824810 Perplexity score.
825811 """
826- if doc_topic_distr != 'deprecated' :
827- warnings .warn ("Argument 'doc_topic_distr' is deprecated and is "
828- "being ignored as of 0.19. Support for this "
829- "argument will be removed in 0.21." ,
830- DeprecationWarning )
831-
832812 return self ._perplexity_precomp_distr (X , sub_sampling = sub_sampling )
0 commit comments