Skip to content

Instantly share code, notes, and snippets.

@Skanda319
Created April 22, 2019 00:23
Show Gist options
  • Save Skanda319/71b04f60b4d1fbcb8e323e65e045657b to your computer and use it in GitHub Desktop.
Save Skanda319/71b04f60b4d1fbcb8e323e65e045657b to your computer and use it in GitHub Desktop.
X_train = train[["date", "return", "range", "close"]].set_index("date")
X_test = test[["date", "return", "range", "close"]].set_index("date")
model = mix.GaussianMixture(n_components=3,
covariance_type="full",
n_init=100,
random_state=7).fit(X_train)
# Predict the optimal sequence of internal hidden state
hidden_states = model.predict(X_test)
print("Means and vars of each hidden state")
for i in range(model.n_components):
print("{0}th hidden state".format(i))
print("mean = ", model.means_[i])
print("var = ", np.diag(model.covariances_[i]))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment