DirichletMultinomialMixture
noloox.mixture.DirichletMultinomialMixture
Bases: BaseEstimator, ClusterMixin, DensityMixin
Implementation of the Dirichlet Multinomial Mixture Model with Gibbs Sampling solver
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_components |
int
|
Number of mixture components in the model. |
required |
n_iter |
int
|
Number of iterations during fitting. If you find your results are unsatisfactory, increase this number. |
50
|
alpha |
float
|
Willingness of a document joining an empty cluster. |
0.1
|
beta |
float
|
Willingness to join clusters, where the terms in the document are not present. |
0.1
|
random_state |
Optional[int]
|
Random seed to use for reproducibility. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
components_ |
array of shape (n_components, n_vocab)
|
Describes all components of the topic distribution. Contains the amount each word has been assigned to each component during fitting. |
n_features_in_ |
int
|
Number of total vocabulary items seen during fitting. |
Source code in noloox/mixture/dmm.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
fit_predict(X, y=None)
Fits the model using Gibbs Sampling. Detailed description of the algorithm in Yin and Wang (2014).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
BOW matrix of corpus. |
required | |
y |
Ignored, exists for sklearn compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
DirichletMultinomialMixture
|
The fitted model. |
Source code in noloox/mixture/dmm.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
fit_transform(X, y=None)
Fits the model, then transforms the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
Document-term matrix. |
required | |
y |
Ignored, sklearn compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
array of shape (n_samples, n_components)
|
Probabilities for each document belonging to each cluster. |
Source code in noloox/mixture/dmm.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
get_params(deep=False)
Get parameters for this estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deep |
bool
|
Ignored, exists for sklearn compatibility. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Parameter names mapped to their values. |
Note
Exists for sklearn compatibility.
Source code in noloox/mixture/dmm.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
predict(X)
Predicts cluster labels for a set of documents. Mainly exists for compatibility with density estimators in sklearn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
Document-term matrix. |
required |
Returns:
| Type | Description |
|---|---|
array of shape (n_samples,)
|
Cluster label for each document. |
Raises:
| Type | Description |
|---|---|
NotFittedException
|
If the model is not fitted, an exception will be raised |
Source code in noloox/mixture/dmm.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
predict_proba(X)
Predicts probabilities for each document belonging to each component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
Document-term matrix. |
required |
Returns:
| Type | Description |
|---|---|
array of shape (n_samples, n_components)
|
Probabilities for each document belonging to each cluster. |
Raises:
| Type | Description |
|---|---|
NotFittedException
|
If the model is not fitted, an exception will be raised |
Source code in noloox/mixture/dmm.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
transform(X)
Alias for predict_proba().
Source code in noloox/mixture/dmm.py
176 177 178 | |