Created
December 18, 2018 12:39
-
-
Save mylamour/1e930a10c1a9ab4e6f9206d813819d10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from hmmlearn import hmm | |
from sklearn.datasets import load_iris,load_diabetes | |
from sklearn.metrics import accuracy_score | |
from sklearn.model_selection import train_test_split | |
CLASSES = 4 | |
ITERATIONS = 100000 | |
iris = load_iris() | |
X = iris.data | |
y = iris.target | |
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0) | |
m1 = hmm.GaussianHMM(n_components=CLASSES, covariance_type="full", n_iter=ITERATIONS) | |
m1.fit(X) | |
y_pred = m1.predict(X) | |
print(accuracy_score(y,y_pred)) | |
print("modele stand prob ", m1.startprob_) | |
m2 = hmm.GMMHMM(n_components=CLASSES, covariance_type="full", n_iter=ITERATIONS) | |
m2.fit(X) | |
y_pred = m2.predict(X) | |
print(accuracy_score(y,y_pred)) | |
print("modele stand prob ", m2.startprob_) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment