def train_gmm(data,n_compenents=3,n_steps=50, plot_intermediate_steps_flag=True): """ Training step of the GMM model Parameters ---------- data : array-like, shape (n_samples,) The data. n_components : int The number of clusters n_steps: int number of iterations to run """ #intilize model parameters at the start means,variances,pi = random_init(n_compenents) for step in range(n_steps): #perform E step weights = step_expectation(data,n_compenents,means,variances) #perform M step variances,means,pi = step_maximization(X, weights, means, variances, n_compenents, pi) plot_pdf(means,variances)