Skip to content

Commit 2bd7fc1

Browse files
committed
remove older commits
0 parents  commit 2bd7fc1

File tree

81 files changed

+661773
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+661773
-0
lines changed

.Rhistory

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
q()
2+
q()
3+
library(mclust)
4+
library(mclust)
5+
library(mclust, lib.loc="C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mclust")
6+
.libPaths()
7+
help(.libPaths)
8+
help(.libPaths)
9+
.libPaths()
10+
.libPaths()
11+
.libPaths("C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mclust")
12+
.libPaths("C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mclust")
13+
.libPaths
14+
.libPaths()
15+
library(mclust)
16+
install.packages(C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mclust_5.4.2)
17+
install.packages("C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mclust_5.4.2")
18+
install.packages("C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mclust_5.4.2")
19+
.libPaths()
20+
install.packages("C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mclust_5.4.2.tar.gz")
21+
install.packages("C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mclust_5.4.2.tar.gz")
22+
install.packages("C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mclust_5.4.2.tar")
23+
pwd
24+
library("mclust", lib.loc="C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mclust_5.4.2.tar.gz")
25+
.libPaths
26+
.libPaths()
27+
library()
28+
search()
29+
library("mclust")
30+
install.packages("mclust")
31+
library("mclust")
32+
plot(BIC)
33+
plot(BIC)
34+
library("mclust")
35+
source('~/Labs/Labs/jovo/link/cluster_init.R')
36+
source('~/Labs/Labs/jovo/link/cluster_init.R')
37+
source('~/Labs/Labs/jovo/link/cluster_init.R')
38+
View(diabetes)
39+
View(diabetes)
40+
source('~/Labs/Labs/jovo/link/cluster_init.R')
41+
source('~/Labs/Labs/jovo/link/cluster_init.R')
42+
source('~/Labs/Labs/jovo/link/cluster_init.R')
43+
View(latent)
44+
source('~/Labs/Labs/jovo/link/cluster_init.R')
45+
source('~/Labs/Labs/jovo/link/cluster_init.R')
46+
View(latent)
47+
View(X)
48+
source('~/Labs/Labs/jovo/link/cluster_init.R')
49+
source('~/Labs/Labs/jovo/link/cluster_init.R')
50+
source('~/Labs/Labs/jovo/link/cluster_init.R')
51+
source('~/Labs/Labs/jovo/link/cluster_init.R')
52+
source('~/Labs/Labs/jovo/link/cluster_init.R')
53+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
54+
install.packages("mbstructure")
55+
install.packages("C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mbstructure", type="source")
56+
install.packages("C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mbstructure", type="source")
57+
require(devtools)
58+
library(devtools)
59+
install.packages("devtools")
60+
require(devtools)
61+
devtools::install_github("youngser/mbstructure")
62+
devtools::install_github("youngser/mbstructure")
63+
library(mbstructure)
64+
devtools::install_github("youngser/mbstructure")
65+
devtools::install(pkg="C:\Users\Thomas Athey\Documents\Labs\Labs\jovo\mbstructure")
66+
devtools::install(pkg="C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mbstructure")
67+
help("Defunct")
68+
devtools::install_local(path="C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mbstructure")
69+
devtools::githubinstall("youngser/mbstructure")
70+
githubinstall("youngser/mbstructure")
71+
install_github("youngser/mbstructure")
72+
list.files()
73+
install_github("youngser/mbstructure")
74+
devtools::install_local(path="C:/Users/Thomas Athey/Documents/Labs/Labs/jovo/mbstructure")
75+
devtools::githubinstall("youngser/mbstructure")
76+
?install_github
77+
library(devtools)
78+
?install_github
79+
devtools::install_github("youngser/mbstructure")
80+
sessionInfo()
81+
help("Defunct")
82+
setInternet2(use=TRUE)
83+
setInternet2(NA
84+
)
85+
setInternet2(NA)
86+
list.files()
87+
rm(list=ls(all=TRUE))
88+
save.image()
89+
list.files()
90+
devtools::install_github("youngser/mbstructure")
91+
install.packages("remotes")
92+
install.packages("remotes")
93+
library(remotes)
94+
remotes::install_github("youngser/mbstructure")
95+
help
96+
R.Version()
97+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
98+
source('~/Labs/Labs/jovo/link/cluster_init.R')
99+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
100+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
101+
source('~/Labs/Labs/jovo/link/cluster_init.R')
102+
source('~/Labs/Labs/jovo/link/cluster_init.R')
103+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
104+
source('~/Labs/Labs/jovo/link/cluster_init.R')
105+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
106+
source('~/Labs/Labs/jovo/link/cluster_init.R')
107+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
108+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
109+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
110+
View(mc)
111+
View(vdf.right)
112+
View(g)
113+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
114+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
115+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
116+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
117+
require(remotes)
118+
remotes::install_github("youngser/mbstructure")
119+
source('~/Labs/Labs/jovo/link/cluster_init.R')
120+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
121+
source('~/Labs/Labs/jovo/link/cluster_init.R')
122+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
123+
source('~/Labs/Labs/jovo/link/cluster_init.R')
124+
0
125+
source('~/Labs/Labs/jovo/link/cluster_init.R')
126+
source('~/Labs/Labs/jovo/link/cluster_init.R')
127+
source('~/Labs/Labs/jovo/link/cluster_init.R')
128+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
129+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
130+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
131+
summary(mc)
132+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
133+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
134+
source('~/Labs/Labs/jovo/link/cluster_init.R')
135+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
136+
system("python Labs/Labs/jovo/mclust_python/drosophila/clust.py")
137+
system("python Labs/Labs/jovo/mclust_python/drosophila/clust.py")
138+
source('~/Labs/Labs/jovo/link/cluster_init.R')
139+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
140+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
141+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
142+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
143+
View(Xhat)
144+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
145+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
146+
source('~/Labs/Labs/jovo/mbstructure/demo/sec3.R')
147+
View(Xhat)
148+
vdf.type
149+
vdf[[2]]
150+
vdf$type
151+
as.character(vdf$type)
152+
as.numeric(vdf$type)
153+
write.csv(as.numeric(vdf$type),file='classes.csv')
154+
source('~/Labs/Labs/jovo/clustering/pyclust/brute_cluster_experiments_mclust.R')
155+
source('~/Labs/Labs/jovo/clustering/pyclust/brute_cluster_experiments_mclust.R')
156+
source('~/Labs/Labs/jovo/clustering/pyclust/brute_cluster_experiments_mclust.R')
157+
source('~/Labs/Labs/jovo/clustering/pyclust/brute_cluster_experiments_mclust.R')

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.formatting.provider": "black",
3+
"python.pythonPath": "C:\\Users\\Thomas Athey\\Miniconda3\\python.exe"
4+
}

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# pyclust
2+
This repo reproduces the results in "Pyclust: Automatic Gaussian Mixture Modeling in Python"
3+
4+
5+
Directory:
6+
subset_experiments
7+
8+
These scripts/files reproduce figures 1 and 2
9+
10+
The csv files that start with "idxs_" are the random subsets of the datasets that were used in the experiments.
11+
12+
All other csv files and images can be reproduced with the scripts
13+
14+
First, run pyclust_subset_experiments.py, mclust_subset_experiments.r, and graspyclust_subset_experiments.py. \
15+
These will generate csv files with the results of each method.
16+
17+
Then, run compare_experiments.py to plot the results.
18+
19+
20+
21+
complete_experiments
22+
23+
There is a script for each clustering algorithm. \
24+
Each script reproduces the respective results for Table 2, the Appendix, \
25+
and in the case of the Drosophila data, Figure 3
26+
27+
28+
figure_4
29+
30+
These scripts reproduce figure 4
31+
32+
The data directory contains the synthetic data used for this experiment (created by make_data.py)
33+
34+
The experiments can be reproduced by running pyclust_runtime.py, graspyclust_runtime.py, and mclust_runtime.r. \
35+
These scripts save the runtime data then show_runtimes.py plots them.
11.6 KB
Binary file not shown.
Binary file not shown.
2.72 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
826 Bytes
Binary file not shown.

__pycache__/make_gmix.cpython-37.pyc

1007 Bytes
Binary file not shown.

brute_cluster_graspyclust.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
from graspy.cluster import GaussianCluster
2+
import numpy as np
3+
import time
4+
import pandas as pd
5+
import matplotlib.pyplot as plt
6+
import csv
7+
import random
8+
9+
def brute_graspy_cluster(Ns, x, covariance_types,ks, c_true, savefigs=None,graphList=None):
10+
if graphList != None and 'all_bics' in graphList:
11+
_, ((ax0,ax1),(ax2,ax3)) = plt.subplots(2,2,sharey='row',sharex='col',figsize=(10,10))
12+
titles = ['full','tied','diag','spherical']
13+
best_bic = -np.inf
14+
for N in Ns:
15+
bics = np.zeros([len(ks),len(covariance_types),N])
16+
aris = np.zeros([len(ks),len(covariance_types),N])
17+
for i in np.arange(N):
18+
graspy_gmm = GaussianCluster(min_components=ks[0],max_components=ks[len(ks)-1],covariance_type=covariance_types,random_state=i)
19+
c_hat,ari = graspy_gmm.fit_predict(x,y=c_true)
20+
bic_values = -graspy_gmm.bic_.values
21+
ari_values = graspy_gmm.ari_.values
22+
bics[:,:,i] = bic_values
23+
aris[:,:,i] = ari_values
24+
bic = bic_values.max()
25+
26+
if bic > best_bic:
27+
idx = np.argmax(bic_values)
28+
idxs = np.unravel_index(idx,bic_values.shape)
29+
best_ari_bic = ari
30+
best_bic = bic
31+
best_k_bic = ks[idxs[0]]
32+
best_cov_bic = titles[3-idxs[1]]
33+
best_c_hat_bic = c_hat
34+
35+
max_bics = np.amax(bics, axis=2)
36+
title = 'N='+str(N)
37+
if graphList != None and 'all_bics' in graphList:
38+
ax0.plot(np.arange(1,len(ks)+1),max_bics[:,3])
39+
ax1.plot(np.arange(1,len(ks)+1),max_bics[:,2],label=title)
40+
ax2.plot(np.arange(1,len(ks)+1),max_bics[:,1])
41+
ax3.plot(np.arange(1,len(ks)+1),max_bics[:,0])
42+
43+
if graphList != None and 'best_bic' in graphList:
44+
#Plot with best BIC*********************************
45+
if c_true is None:
46+
best_ari_bic_str = 'NA'
47+
else:
48+
best_ari_bic_str = '%1.3f'%best_ari_bic
49+
50+
fig_bestbic = plt.figure(figsize=(8,8))
51+
ax_bestbic = fig_bestbic.add_subplot(1,1,1)
52+
#ptcolors = [colors[i] for i in best_c_hat_bic]
53+
ax_bestbic.scatter(x[:,0],x[:,1],c=best_c_hat_bic)
54+
#mncolors = [colors[i] for i in np.arange(best_k_bic)]
55+
mncolors = [i for i in np.arange(best_k_bic)]
56+
ax_bestbic.set_title("py(agg-gmm) BIC %3.0f from "%best_bic +
57+
str(best_cov_bic) + " k=" + str(best_k_bic) +
58+
' ari=' + best_ari_bic_str)# + "iter=" + str(best_iter_bic))
59+
ax_bestbic.set_xlabel("First feature")
60+
ax_bestbic.set_ylabel("Second feature")
61+
if savefigs is not None:
62+
plt.savefig(savefigs+'_python_bestbic.jpg')
63+
64+
if graphList != None and 'all_bics' in graphList:
65+
#plot of all BICS*******************************
66+
titles = ['full','tied','diag','spherical']
67+
#ax0.set_title(titles[0],fontsize=20,fontweight='bold')
68+
#ax0.set_ylabel('BIC',fontsize=20)
69+
ax0.locator_params(axis='y',tight=True,nbins=4)
70+
ax0.set_yticklabels(ax0.get_yticks(),fontsize=14)
71+
72+
#ax1.set_title(titles[1],fontsize=20,fontweight='bold')
73+
legend = ax1.legend(loc='best',title='Number of\nRuns',fontsize=12)
74+
plt.setp(legend.get_title(),fontsize=14)
75+
76+
#ax2.set_title(titles[2],fontsize=20,fontweight='bold')
77+
#ax2.set_xlabel('Number of components',fontsize=20)
78+
ax2.set_xticks(np.arange(0,21,4))
79+
ax2.set_xticklabels(ax2.get_xticks(),fontsize=14)
80+
#ax2.set_ylabel('BIC',fontsize=20)
81+
ax2.locator_params(axis='y',tight=True,nbins=4)
82+
ax2.set_yticklabels(ax2.get_yticks(),fontsize=14)
83+
84+
85+
#ax3.set_title(titles[3],fontsize=20,fontweight='bold')
86+
#ax3.set_xlabel('Number of components',fontsize=20)
87+
ax3.set_xticks(np.arange(0,21,4))
88+
ax3.set_xticklabels(ax3.get_xticks(),fontsize=14)
89+
90+
91+
if savefigs is not None:
92+
plt.savefig('.\\figures\\25_6_19_paperv2\\'+savefigs+'_graspy_bicplot2.jpg')
93+
plt.show()
94+
95+
return best_c_hat_bic, best_cov_bic, best_k_bic, best_ari_bic,best_bic

0 commit comments

Comments
 (0)