Skip to content

Commit

Permalink
More tidying of pyMM.py
Browse files Browse the repository at this point in the history
  • Loading branch information
charlienash committed May 19, 2016
1 parent be63f3f commit 1a1b3f3
Show file tree
Hide file tree
Showing 9 changed files with 814 additions and 0 deletions.
Binary file added __pycache__/__init__.cpython-34.pyc
Binary file not shown.
Binary file added __pycache__/pyMM.cpython-34.pyc
Binary file not shown.
Binary file added __pycache__/util.cpython-34.pyc
Binary file not shown.
Empty file added examples/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions gmm_overfit_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""
Created on Mon May 2 11:18:41 2016
@author: charlie
"""

import numpy as np
from models.pyMix import GMM, MPPCA, MFA
from sklearn.cross_validation import KFold

dat_path = '/tmp/virus3.dat'
data = np.loadtxt(dat_path)

# normalize data
X = (data - data.mean(axis=0)) / data.std(axis=0)


# Get cv splits
k = 10
n_examples = X.shape[0]
kf = KFold(n_examples, k)

# Fit model evaluate with cross-validation
n_components = 1
val_score = 0
for train, test in kf:
gmm = GMM(n_components=n_components)
gmm.fit(X[train], init_method='kmeans')
print('Val score: {}'.format(gmm.score(X[test])))
val_score += gmm.score(X[test])
mean_val_score = val_score / k

2 changes: 2 additions & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

Binary file added models/__pycache__/__init__.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/pyMix.cpython-34.pyc
Binary file not shown.
Loading

0 comments on commit 1a1b3f3

Please sign in to comment.