def analyzeResults(model, time, volume, growth, speciesCounts): if not os.path.exists(OUTPUT_DIRECTORY): os.makedirs(OUTPUT_DIRECTORY) submodel = model.getComponentById('Metabolism') analysis.plot( model = submodel, time = time, yDatas = {'Volume': volume}, fileName = os.path.join(OUTPUT_DIRECTORY, 'Volume.pdf') ) analysis.plot( model = submodel, time = time, yDatas = {'Growth': growth}, fileName = os.path.join(OUTPUT_DIRECTORY, 'Growth.pdf') ) analysis.plot( model = submodel, time = time, volume = volume, speciesCounts = speciesCounts, units = 'mM', selectedSpeciesCompartments = ['ATP[c]', 'CTP[c]', 'GTP[c]', 'UTP[c]'], fileName = os.path.join(OUTPUT_DIRECTORY, 'NTPs.pdf') ) analysis.plot( model = submodel, time = time, volume = volume, speciesCounts = speciesCounts, selectedSpeciesCompartments = ['ALA[c]', 'ARG[c]', 'ASN[c]', 'ASP[c]'], units = 'uM', fileName = os.path.join(OUTPUT_DIRECTORY, 'Amino acids.pdf') ) analysis.plot( model = submodel, time = time, volume = volume, speciesCounts = speciesCounts, units = 'molecules', selectedSpeciesCompartments = ['Adk-Protein[c]', 'Apt-Protein[c]', 'Cmk-Protein[c]'], fileName = os.path.join(OUTPUT_DIRECTORY, 'Proteins.pdf') )
filepath, 3, ["Fz", "Cx", "Cy", "Fz.1", "Cx.1", "Cy.1"], 36000, [4] ) # get length of signals n_cop = len(x_cop) # time signals for correlation t_corr_cop = np.arange(-n_cop / fs_cop, n_cop / fs_cop - 1 / fs_cop, 1 / fs_cop) # standardize the signals to between 0 - 1 x_cop_standard = an.standardize(x_cop) y_cop_standard = an.standardize(y_cop) #################### CoP X-axis analysis #################### an.plot(t_cop, x_cop, "time (s)", "CoP", "Raw Cx signal", None, None) vel_x_cop = an.deriv(t_cop, x_cop) acc_x_cop = an.deriv(t_cop[:-1], vel_x_cop) print( f"Average velocity of X CoP = {np.mean(sorted(vel_x_cop, reverse=True)[:10])}" ) print( f"Average acceleration of X CoP = {np.mean(sorted(acc_x_cop, reverse=True)[:10])}" ) an.plot(t_cop[:-1], vel_x_cop, "time (s)", "Velocity", "CoP X Velocity", None, None) an.plot( t_cop[:-2], acc_x_cop,
def analyzeResults(model, time, volume, extracellularVolume, speciesCounts): if not os.path.exists(OUTPUT_DIRECTORY): os.makedirs(OUTPUT_DIRECTORY) cellComp = model.getComponentById('c') totalRna = np.zeros(len(time)) totalProt = np.zeros(len(time)) for species in model.species: if species.type == 'RNA': totalRna += speciesCounts[species.index, cellComp.index, :] elif species.type == 'Protein': totalProt += speciesCounts[species.index, cellComp.index, :] analysis.plot( model = model, time = time, yDatas = {'RNA': totalRna}, fileName = os.path.join(OUTPUT_DIRECTORY, 'Total RNA.pdf') ) analysis.plot( model = model, time = time, yDatas = {'Protein': totalProt}, fileName = os.path.join(OUTPUT_DIRECTORY, 'Total protein.pdf') ) analysis.plot( model = model, time = time, volume = volume, speciesCounts = speciesCounts, units = 'molecules', selectedSpeciesCompartments = ['ATP[c]', 'CTP[c]', 'GTP[c]', 'UTP[c]'], fileName = os.path.join(OUTPUT_DIRECTORY, 'NTPs.pdf') ) analysis.plot( model = model, time = time, volume = volume, speciesCounts = speciesCounts, selectedSpeciesCompartments = ['AMP[c]', 'CMP[c]', 'GMP[c]', 'UMP[c]'], units = 'uM', fileName = os.path.join(OUTPUT_DIRECTORY, 'NMPs.pdf') ) analysis.plot( model = model, time = time, volume = volume, speciesCounts = speciesCounts, selectedSpeciesCompartments = ['ALA[c]', 'ARG[c]', 'ASN[c]', 'ASP[c]'], units = 'uM', fileName = os.path.join(OUTPUT_DIRECTORY, 'Amino acids.pdf') ) analysis.plot( model = model, time = time, speciesCounts = speciesCounts, units = 'molecules', selectedSpeciesCompartments = ['RnaPolymerase-Protein[c]', 'Adk-Protein[c]', 'Apt-Protein[c]', 'Cmk-Protein[c]'], fileName = os.path.join(OUTPUT_DIRECTORY, 'Proteins.pdf') )
def make_frames(filepath, frame_prefix, title): xranges = [] yranges = [] with h5py.File(filepath, 'r', libver='latest', swmr=True) as f: for i, step_key in enumerate(tqdm(sorted(f.keys())[::1])): step_entry = f[step_key] if len(step_entry.keys()) == 0: print('entry is empty') else: deep_features = step_entry['deep_features'] xranges.append( (min(deep_features[:, 0]), max(deep_features[:, 0]))) yranges.append( (min(deep_features[:, 1]), max(deep_features[:, 1]))) xranges = np.array(xranges) yranges = np.array(yranges) floor = 5e-2 xranges, yranges = smooth_ranges_2d(xranges, yranges, scale=1.25, floor=floor, window_length=51, polyorder=3) with h5py.File(filepath, 'r', libver='latest', swmr=True) as f: for i, (step_key, xrange, yrange) in enumerate( tqdm(list(zip(sorted(f.keys()), xranges, yranges))[::1])): step_entry = f[step_key] if len(step_entry.keys()) == 0: print('entry is empty') else: deep_features = step_entry['deep_features'] logits = step_entry['logits'] target_labels = step_entry['target_labels'] target_labels_output = list(target_labels) # plt.cla() display.clear_output(wait=True) ax = plot_deep_features(deep_features, target_labels, title=title, xlim=xrange, ylim=yrange) centroid = step_entry['centroid'] plt.scatter(centroid[0], centroid[1], c='black') learning_rate = np.array(step_entry['learning_rate']) _lambda = np.array(step_entry['lambda']) # accuracy = np.array(step_entry['accuracy']) logits = np.array(step_entry['logits']) target_labels = np.array(step_entry['target_labels']) sample_number = np.shape(target_labels)[0] accuracy = np.sum( np.equal(np.argmax(logits, axis=1), np.argmax(target_labels, axis=1))) / sample_number text( 'lambda: {}\nlearning rate: {}\naccuracy: {}'.format( str(_lambda), str(learning_rate), str(accuracy)), (0.95, 0.05), xrange, yrange) plot(save=True, frame_prefix=frame_prefix, frame_index=int(i))
# Output results results = 'CAESAR CIPHER:\n' + caesar + '\n\nVIGENERE CIPHER:\n' + vigenere if '-o' in sys.argv: # Write result to file i = sys.argv.index('-o') storage.write(sys.argv[i + 1], results) else: # Write result to console print(results) # Analise by counting the letter in the alphabet plain_letter_count = analysis.count_letters(message.lower()) caesar_letter_count = analysis.count_letters(caesar) vigenere_letter_count = analysis.count_letters(vigenere) # Show theoretical letter frequency analysis.theoretical() analysis.show(legend=False) # Show comparison between theoretical and actual letter frequency analysis.theoretical_vs_actual(plain_letter_count) analysis.show() # Show a matrix of letter frequency analysis.matrix(message, plain_letter_count) analysis.show(legend=False) # Show letter count analysis comparing original text, Caesar and Vigenère ciphers analysis.plot(plain_letter_count, 'Plain text') analysis.plot(caesar_letter_count, 'Caesar cipher') analysis.plot(vigenere_letter_count, 'Vigenère cipher') analysis.show()
default=256) # Specify frequency range parser.add_argument('-b', '--band', nargs=2, type=int, help="Specify the \ frequency band in Hz, for example \'--band 8 13\'", default=[8, 13]) # Specify the length of the signal in seconds parser.add_argument('-l', '--length', type=float, help="Specify the \ length of the signal to process, for example \'--length 1.5\' to only \ process the first one and a half seconds of the signal. If the specified \ length is longer than the length of the signal, the whole signal is used.") args = parser.parse_args() folders = args.folder band = args.band sample_rate = args.sample_rate length = args.length results = run_analysis(folders, band, sample_rate, length) KNN = create_knn_classifier(results) # Create an interactive plot plot(results, sample_rate, band, callback=on_click) exit(0)
def show_calibration(calibration): analysis.plot(calibration)
#from analysis.plot_general import plot #plots=plot(params) #data=plots.data #targets=get_data(data,'target',9,params.noise[0])[0] #lure=get_data(data,'lure',9,params.noise[0])[0] #hits=calc_rates(round_for_fit(targets,params.N_t),params.N_t) #fa=calc_rates(round_for_fit(lure,params.N_t),params.N_t) #sys.exit() if 'length' in params.effect: for nn in range(len(params.noise)): plot.list_length(params, -1, nn=nn, confounds='equal') elif 'strength' in params.effect: for nn in range(len(params.noise)): plot.list_strength(params, -1, nn=nn) elif 'decision' in params.effect or 'bias' in params.effect: for nn in range(len(params.noise)): plot.decision_noise(params, nn=nn, m=0) elif 'item' in params.effect: from analysis.plot_general import plot params.show_fig = [ 'roc_curves', 'distance_histograms_memory1', 'correct_retrieval', 'false_alarms' ] plots = plot(params) for nn in params.noise: # plots.false_alarms(nn,info='lure') # plots.roc_curves(nn) plots.distance_histograms(nn) # run_plots(params,params.effect)
import analysis from georgiatech import GeorgiaTech import pandas as pd gt_context = GeorgiaTech() df = pd.read_csv("dataset_small.csv") print() # Plot data df_sample = analysis.sample(df, 1000, ["route", "stop", "session", "approach"]) analysis.plot(df_sample, gt_context, "route", ("actualSecondsToArrival", "abserror"), 1) analysis.plot(df_sample, gt_context, "route", ("distance", "abserror"), 1) analysis.plot(df_sample, gt_context, "route", ("kmperhr", "abserror"), 1) analysis.plot(df_sample, gt_context, "route", ("minutesIntoDay", "abserror"), 1) analysis.plot(df_sample, gt_context, "route", ("layover", "actualSecondsToArrival"), 3) analysis.plot(df_sample, gt_context, "route", ("wind", "actualSecondsToArrival"), 3) analysis.plot(df_sample, gt_context, "route", ("pressure", "actualSecondsToArrival"), 3) analysis.plot(df_sample, gt_context, "route", ("humidity", "actualSecondsToArrival"), 3) analysis.plot(df_sample, gt_context, "route", ("visibility", "actualSecondsToArrival"), 3) analysis.plot(df_sample, gt_context, "route", ("secondsToArrival", "actualSecondsToArrival"), 2)
def set_up_plot(tmpdir): x = np.array([1, 2, 3]) y = np.array([6, 7, 10]) fig, ax = analysis.plot(x, y, "my_title", "my_x_axis_label", "my_y_axis_label", "plot.png") return (fig, ax)
def make_frames(filepath, frame_prefix, title): xranges = [] yranges = [] with h5py.File(filepath, 'r', libver='latest', swmr=True) as f: for i, step_key in enumerate(tqdm(sorted(f.keys())[::1])): step_entry = f[step_key] if len(step_entry.keys()) == 0: print('entry is empty') else: deep_features = step_entry['deep_features'] xranges.append((min(deep_features[:, 0]), max(deep_features[:, 0]))) yranges.append((min(deep_features[:, 1]), max(deep_features[:, 1]))) xranges = np.array(xranges) yranges = np.array(yranges) floor = 5e-2 xranges, yranges = smooth_ranges_2d(xranges, yranges, scale=1.25, floor=floor, window_length=51, polyorder=3) with h5py.File(filepath, 'r', libver='latest', swmr=True) as f: for i, (step_key, xrange, yrange) in enumerate(tqdm( list(zip(sorted(f.keys()), xranges, yranges))[::1])): step_entry = f[step_key] if len(step_entry.keys()) == 0: print('entry is empty') else: deep_features = step_entry['deep_features'] logits = step_entry['logits'] target_labels = step_entry['target_labels'] target_labels_output = list(target_labels) # plt.cla() display.clear_output(wait=True) ax = plot_deep_features( deep_features, target_labels, title=title, xlim=xrange, ylim=yrange ) centroid = step_entry['centroid'] plt.scatter(centroid[0], centroid[1], c='black') learning_rate = np.array(step_entry['learning_rate']) _lambda = np.array(step_entry['lambda']) # accuracy = np.array(step_entry['accuracy']) logits = np.array(step_entry['logits']) target_labels = np.array(step_entry['target_labels']) sample_number = np.shape(target_labels)[0] accuracy = np.sum( np.equal(np.argmax(logits, axis=1), np.argmax(target_labels, axis=1) ) ) / sample_number text('lambda: {}\nlearning rate: {}\naccuracy: {}'.format(str(_lambda), str(learning_rate), str(accuracy)), (0.95, 0.05), xrange, yrange) plot(save=True, frame_prefix=frame_prefix, frame_index=int(i))