Labo-Lacourse / stepmix

A Python package following the scikit-learn API for model-based clustering and generalized mixture modeling (latent class/profile analysis) of continuous and categorical data. StepMix handles missing values through Full Information Maximum Likelihood (FIML) and provides multiple stepwise Expectation-Maximization (EM) estimation methods.
https://stepmix.readthedocs.io/en/latest/index.html
MIT License
59 stars 4 forks source link

Wong number of parameters in categorical model #34

Closed sachaMorin closed 1 year ago

sachaMorin commented 1 year ago
from stepmix.stepmix import StepMix
import numpy as np

data = np.random.choice(a=[0, 1, 2],

                        size=200).reshape(-1, 1)

example_model = StepMix(n_components=3, measurement='categorical', random_state=42, verbose=0, max_iter=5000, n_init=1)

example_model.fit(data)

print(example_model.n_parameters)

Results in 2 parameters while 2 + 3 * 2 = 8 parameters are expected.

sachaMorin commented 1 year ago

Possible related to #8

sachaMorin commented 1 year ago

Line 155 in categorical.py should be replaced with

        n_free_parameters_per_class = self.get_n_features() * (self.n_outcomes - 1)