def main(): """ Doc """ data = load_data() humanppi_G = nx.Graph(data.humanppi, name="HumanPPI") write_to_hdf5(humanppi_G) return 0
def main(): data = load_data() hgraph = nx.Graph(data.humanppi) fgraph = nx.Graph(data.functions) # plot_degree(hgraph) # plot_cp_degree(hgraph) #plot_fn_degree(hgraph, fgraph) plot_fn_cp_weight(hgraph, fgraph)
def main(): data = load_data() if args.edges == 0: ppiGraph = nx.Graph(data.humanppi, name="HumanPPI") else: ppiGraph = nx.Graph(data.humanppi[0:args.edges], name="HumanPPI") draw_kwargs = dict(node_size=5, font_size=6, with_labels=False, linewidths=0.1, width=0.2) layout_kw = dict(iterations=args.iterations) img_title = 'Nodes: %i Edges: %i Iterations: %i Runtime: %s' if args.iterations is None: # Number of iters will be set to 10, check the get_iterations method. iters = get_iterations() for iteration in iters: start_time = time.time() fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot(111) nx.draw(ppiGraph, pos=nx.spring_layout( ppiGraph, iterations=iteration), **draw_kwargs) run_time = time.time() - start_time runtime_str = str(round(run_time, 2)) + ' seconds' print("Iterations: %i Runt-time: %s" % (iteration, runtime_str)) subs = (len(ppiGraph), args.edges, iteration, runtime_str) ax.set_title(img_title % subs) filepath = 'report/graphs' + '/' + \ zeros(iteration, padlength=4) + '.png' plt.savefig(filepath, bbox_inches='tight') print("Done! Saved at : " + filepath) fig.clf() plt.close() else: start_time = time.time() fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot(111) nx.draw(ppiGraph, pos=nx.spring_layout( ppiGraph, **layout_kw), **draw_kwargs) runtime = time.time() - start_time runtime_str = str(round(runtime, 2)) + ' seconds' subs = (len(ppiGraph), args.edges, args.iterations, runtime_str) ax.set_title(img_title % subs) filepath = 'report/graphs' + '/' + \ zeros(args.iterations, padlength=4) + '.png' plt.savefig(filepath, bbox_inches='tight') print("Done! Saved at " + filepath) fig.clf() plt.close()
def main(): if (len(sys.argv) != 3): print('Usage: $ python %s in.pickle outmax' % sys.argv[0]) quit() data_file = sys.argv[1] outmax = int(sys.argv[2]) all_dataset = misc.load_data(data_file) html_dataset = {} c_dataset = {} for doc in all_dataset: if re.match(r'.+\.(c|h)$', doc): c_dataset[doc] = all_dataset[doc] elif re.match(r'.+\.(html)$', doc): html_dataset[doc] = all_dataset[doc] pp = pprint.PrettyPrinter(indent=4) for doc,val in sorted(html_dataset.items(), key=lambda x:(x[0])[::-1], reverse=True): neighbor = get_neighbor_c(html_dataset[doc], c_dataset, outmax) print '--%s--' % doc pp.pprint(neighbor) print ''
start = datetime.now() clf = linear_model.LogisticRegression() clf.fit(X, y) score = np.mean(clf.predict(T) == valid) return score, datetime.now() - start if __name__ == '__main__': import sys, misc # don't bother me with warnings import warnings; warnings.simplefilter('ignore') np.seterr(all='ignore') print __doc__ + '\n' if not len(sys.argv) == 2: print misc.USAGE % __file__ sys.exit(-1) else: dataset = sys.argv[1] print 'Loading data ...' data = misc.load_data(dataset) print 'Done, %s samples with %s features loaded into ' \ 'memory' % data[0].shape res_skl = misc.bench(bench_skl, data) print 'MLPy: mean %.2f, std %.2f\n' % ( np.mean(res_skl), np.std(res_skl))
import misc # don't bother me with warnings import warnings warnings.simplefilter('ignore') np.seterr(all='ignore') print __doc__ + '\n' if not len(sys.argv) == 2: print misc.USAGE % __file__ sys.exit(-1) else: dataset = sys.argv[1] print 'Loading data ...' data = misc.load_data(dataset) # set sigma to something useful from milk.unsupervised import pdist sigma = np.median(pdist(data[0])) print 'Done, %s samples with %s features loaded into ' \ 'memory' % data[0].shape score, res_shogun = misc.bench(bench_shogun, data) print 'Shogun: mean %.2f, std %.2f' % ( np.mean(res_shogun), np.std(res_shogun)) print 'Score: %.2f\n' % score score, res_mdp = misc.bench(bench_mdp, data) print 'MDP: mean %.2f, std %.2f' % (
model.add(BatchNormalization((256,))) model.add(Dropout(0.5)) model.add(Dense(256, n_classes, init='glorot_uniform')) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer="adam") return model model_name = 'dump_keras_ensemble.0.5.0.5.0.5' n_models = 20 print("Loading data...") X, labels = load_data(paths.train_file, train=True) y = preprocess_labels(labels) X_test, ids = load_data(paths.test_file, train=False) X = preprocess_data(X) X_test = preprocess_data(X_test) n_classes = y.shape[1] n_dims = X.shape[1] print("Training %d models..." % n_models) proba = 0 models = range(1, n_models+1) for i in models: print("\n-------------- Model %d --------------\n" % i) model = model_factory(n_classes, n_dims)
"""PCA benchmarks""" import numpy as np from datetime import datetime # # .. Load dataset .. # from misc import load_data, bench print 'Loading data ...' X, y, T = load_data() print 'Done, %s samples with %s features loaded into ' \ 'memory' % X.shape n_components = 9 def bench_skl(): # # .. scikits.learn .. # from scikits.learn import pca as skl_pca start = datetime.now() clf = skl_pca.RandomizedPCA(n_components=n_components) clf.fit(X) return datetime.now() - start def bench_pybrain(): # # .. pybrain ..
def main(): data = load_data() if args.edges == 0: ppiGraph = nx.Graph(data.humanppi, name="HumanPPI") else: ppiGraph = nx.Graph(data.humanppi[0:args.edges], name="HumanPPI") draw_kwargs = dict(node_size=5, font_size=6, with_labels=False, linewidths=0.1, width=0.2) layout_kw = dict(iterations=args.iterations) img_title = 'Nodes: %i Edges: %i Iterations: %i Runtime: %s' if args.iterations == None: iters = get_iterations() for iteration in iters: starttime = time.time() fig = plt.figure(figsize=(10,10)) ax = fig.add_subplot(111) nx.draw(ppiGraph, pos=nx.spring_layout(ppiGraph, iterations=iteration ), **draw_kwargs ) runtime = time.time() - starttime runtime_str = str(round(runtime, 2))+' seconds' print "Iterations: %i Run-time: %s "%(iteration, runtime_str) subs = (len(ppiGraph), args.edges, iteration, runtime_str) ax.set_title(img_title%subs) filepath = 'graphs'+'/'+zeros(iteration, padlength=4)+'.png' plt.savefig(filepath, bbox_inches='tight') print 'Written to: '+filepath fig.clf() plt.close() else: starttime = time.time() fig = plt.figure(figsize=(10,10)) ax = fig.add_subplot(111) nx.draw(ppiGraph, pos=nx.spring_layout(ppiGraph, **layout_kw ), **draw_kwargs ) runtime = time.time() - starttime runtime_str = str(round(runtime, 2))+' seconds' subs = (len(ppiGraph), args.edges, args.iterations, runtime_str) ax.set_title(img_title%subs) filepath = 'graphs'+'/'+zeros(args.iterations, padlength=4)+'.png' plt.savefig(filepath, bbox_inches='tight') print 'Written to: '+filepath fig.clf() plt.close()
misc.msg_log[len(misc.msg_log) - config.logsize:] = [] for i in self.client_roster: if i != except_jid and self.client_roster[i]['to'] and self.client_roster[i]['subscription'] == 'both' and self.client_roster[i].resources: misc.check_time(self, misc.data['quiet'], i) if misc.check_time(self, misc.data['stop'], i) and (i not in misc.data['block'] or except_jid not in misc.data['block'][i]): try: self.send_message(mto=i, mbody=body, mtype='chat') except Exception: pass if __name__ == '__main__': signal.signal(signal.SIGTERM, lambda signal, frame: sys.exit()) # handle SIGTERM, graceful exit misc.restarting = False misc.quiting = False misc.load_data() logging.basicConfig(level=config.loglevel) for i in ('stop', 'quiet', 'block'): if i not in misc.data: misc.data[i] = {} if config.store_log: if 'msg_log' in misc.data: misc.msg_log = misc.data['msg_log'] else: misc.data['msg_log'] = misc.msg_log if 'cmd_log' in misc.data: misc.cmd_log = misc.data['cmd_log'] else: misc.data['cmd_log'] = misc.cmd_log