#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot def segment(pt1, pt2): num = 100 # return [[x * ((i * 1.0) / num) + y * ((num - i * 1.0) / num) for i in range(num)] for (x, y) in zip(pt1, pt2)] return [[ x * ((i * 1.0) / num) + y * ((num - i * 1.0) / num) for (x, y) in zip(pt1, pt2) ] for i in range(num)] plot(segment([3.5, 3], [0.5, 1]), 4, 1) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot S = { 2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j, 3.25 + 1j } plot({1 + 2j + z for z in S}, 4) #プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot S = { 2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j, 3.25 + 1j } plot({z * 1j / 2.0 for z in S}, 4) #プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys,os from math import e, pi sys.path.append(os.pardir) from modules.plotting import plot n = 20 w = e ** ((2 * pi * 1j) / 20) list = { w ** i for i in range(n) } plot(list, 4) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot from modules import image data = image.file2image('./images/img01.png') height = len(data) width = len(data[0]) pts = { x + (height - y) * 1j for y, array in enumerate(data) for x, cell in enumerate(array) if cell[0] < 120 } pts = {c * 1j for c in pts} plot(pts, height, 1) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot S = { 2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j, 3.25 + 1j } plot({z * 1j / 2.0 + (2 - 1j) for z in S}, 4) #プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot def scalar_vector_mult(alpha, v): return [alpha * v[i] for i in range(len(v))] L = [[2, 2], [3, 2], [1.75, 1], [2, 1], [2.25, 1], [2.5, 1], [2.75, 1], [3, 1], [3.25, 1]] plot([scalar_vector_mult(-0.5, scalar_vector_mult(0.5, v)) for v in L], 4) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot S = { 2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j, 3.25 + 1j } plot({z / 2.0 for z in S}, 4) #プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
help='level of confidence') return parser.parse_args() if __name__ == "__main__": args = parse_args() dataset_name = args.dataset print(f'Experiment for {dataset_name} starts') df = download_data(dataset_name) df = df.dropna() X = df.values[:, 1:] # zero is taget print(f'dataframe shape: {X.shape}') plot_objects = [] for method in [ 'uniform', 'predictive_length', 'bottom_up', 'bayesian_dpp' ]: #, 'bayesian_dpp_sdp']: obj_to_plot = do_experiment(X, method=method, bootsrtap_size=args.bootsrt_size, alpha=args.alpha) plot_objects.append(obj_to_plot) plot(plot_objects, x_label='Subset size (multiple of d)', y_label='A-optimality', title=f'dataset="{dataset_name}"', d=X.shape[1], ytop=DATASET_TO_TOP[dataset_name], save_path=f'{dataset_name}.png')
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot S = { 2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j, 3.25 + 1j } plot(S, 4) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os sys.path.append(os.pardir) from modules.plotting import plot L = [[2, 2], [3, 2], [1.75, 1], [2, 1], [2.25, 1], [2.5, 1], [2.75, 1], [3, 1], [3.25, 1]] plot(L, 4) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()
k=k, Sigma=Sigma, opt_type=optimality)) plot_prop = {'label': optimality} object_to_plot = get_object_to_plot( X=k_linspace, Y=upper_estimation_bottom_up, plot_prop=plot_prop) to_plot.append(object_to_plot) plot( to_plot, x_label='k', y_label=f'upper estimation', title=f'Upper estimation: dataset="{dataset_name}" & {method}', save_path= f'upper_estimation/{method}/{dataset_name}; method is {method}.png' ) elif method == 'bayessian_dpp': to_plot = [] for optimality in opt_types: upper_estimation_dpp = [] optimalty_func = _get_optimalty(optimality) for ix in tqdm(range(len(k_linspace))): k = k_linspace[ix] p = k / num_samples * np.ones(num_samples)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys,os sys.path.append(os.pardir) from modules.plotting import plot def add2(v, w): return [ x+y for (x, y) in zip(v,w) ] L = [[2, 2], [3, 2], [1.75, 1], [2, 1], [2.25, 1], [2.5, 1], [2.75, 1], [3, 1], [3.25, 1]] plot([add2(v, [1,2]) for v in L], 4) # プロセス終了時にファイルが削除されるため入力待ちに row_input() if sys.version_info < (3, 0, 0) else input()