def nmf_tsne(data, k, n_runs=<NUM_LIT:10>, init='<STR_LIT>', **params):
clusters = []<EOL>nmf = NMF(k)<EOL>tsne = TSNE(<NUM_LIT:2>)<EOL>km = KMeans(k)<EOL>for i in range(n_runs):<EOL><INDENT>w = nmf.fit_transform(data)<EOL>h = nmf.components_<EOL>tsne_wh = tsne.fit_transform(w.dot(h).T)<EOL>clust = km.fit_predict(tsne_wh)<EOL>clusters.append(clust)<EOL><DEDENT>clusterings = np.vstack(clusters)<EOL>consensus = CE.cluster_ensembles(clusterings, verbose=False, N_clusters_max=k)<EOL>nmf_new = NMF(k, init='<STR_LIT>')<EOL>init_w, init_h = nmf_init(data, consensus, k, init)<EOL>W = nmf_new.fit_transform(data, W=init_w, H=init_h)<EOL>H = nmf_new.components_<EOL>return W, H<EOL>
runs tsne-consensus-NMF

1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W and H from the resulting NMF run