コード例 #1
0
def mce_write_test(path):
    test.rm(test.tmp(path))
    test.call(test.build("mce_write"), [], [test.tmp(path)], test.tmp("stdout.txt"), [], {})
    test.call(test.build("mce_extract"), [], [test.tmp(path), "sample.xml"], test.tmp(path+".mce_write.mce_extract"), [], {})
    test.regr(test.docs(path+".mce_write.mce_extract"), test.tmp(path+".mce_write.mce_extract"), False)
    test.call(test.build("mce_extract"), [], [test.tmp(path), "--understands", "http://schemas.openxmlformats.org/Circles/v2", "sample.xml"], test.tmp(path+".mce_write.v2.mce_extract"), [], {})
    test.regr(test.docs(path+".mce_write.v2.mce_extract"), test.tmp(path+".mce_write.v2.mce_extract"), False)
コード例 #2
0
def opc_relation_test(path):
	test.call(test.build("opc_relation"), [], [test.docs(path)], test.tmp(path+".opc_relation"), [], {})
	test.regr(test.docs(path+".opc_relation"), test.tmp(path+".opc_relation"), True)
	test.call(test.build("opc_relation"), [], [test.docs(path), "rId1"], test.tmp(path+".opc_relation.rId1"), [], {})
	test.regr(test.docs(path+".opc_relation.rId1"), test.tmp(path+".opc_relation.rId1"), True)
	test.call(test.build("opc_relation"), [], [test.docs(path), "word/document.xml", "rId1"], test.tmp(path+".opc_relation.word-document.rId1"), [], {})
	test.regr(test.docs(path+".opc_relation.word-document.rId1"), test.tmp(path+".opc_relation.word-document.rId1"), True)
コード例 #3
0
def opc_generate_test(basepath, path):
	dest=os.path.join(os.path.split(path)[0], os.path.splitext(os.path.split(path)[1])[0]+".c")
	test.ensureDir(test.tmp(os.path.dirname(dest)))
	test.call(test.build("opc_dump"), [], [os.path.join(basepath, path)], test.tmp(path+"_1.opc_generate.opc_dump"), [], {})
	test.call(test.build("opc_generate"), [], [os.path.join(basepath, path), test.tmp(dest)], test.tmp("stdout.txt"), [], {})
	exe=test.compile(test.tmp(dest))
	test.call(exe, [], [test.tmp(path)], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_dump"), [], [test.tmp(path)], test.tmp(path+"_2.opc_generate.opc_dump"), [], {})
	test.regr(test.tmp(path+"_1.opc_generate.opc_dump"), test.tmp(path+"_2.opc_generate.opc_dump"), False)
コード例 #4
0
def opc_proc_test(path, args, cmd):
    test.rm(test.tmp(path))
    test.cp(test.docs(path), test.tmp(path))
    call_args=[test.tmp(path)]
    call_args.extend(args)
    out=path+".opc_proc."+cmd+".txt"
    test.call(test.build("opc_proc"), [], call_args, test.tmp(out), [], {})
    test.regr(test.docs(out), test.tmp(out), True)
コード例 #5
0
def mce_extract_test(path, part, namespaces, returncode):
	_part_="."+part.replace('.', '_')
	args=[test.docs(path), part]
	for namespace in namespaces:
		args.append("--understands"); args.append(namespace[1])
		_part_=_part_+"."+namespace[0]
	test.call(test.build("mce_extract"), [], args, test.tmp(path+_part_+".mce_extract"), [], {"return": returncode})
	test.regr(test.docs(path+_part_+".mce_extract"), test.tmp(path+_part_+".mce_extract"), True)
コード例 #6
0
def opc_zipwrite_test(path):
	test.rm(test.tmp(path))
	test.call(test.build("opc_zipwrite"), [], [test.tmp(path), "--import", "--delete", "--add", "--commit"], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_zipread"), [], ["--verify", test.tmp(path)], test.tmp(path+"_1.opc_zipread"), [], {})
	test.regr(test.docs(path+"_1.opc_zipread"), test.tmp(path+"_1.opc_zipread"), True)

	test.call(test.build("opc_zipwrite"), [], [test.tmp(path), "--import", "--commit"], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_zipread"), [], ["--verify", test.tmp(path)], test.tmp(path+"_2.opc_zipread"), [], {})
	test.regr(test.tmp(path+"_1.opc_zipread"), test.tmp(path+"_2.opc_zipread"), True)

	test.call(test.build("opc_zipwrite"), [], [test.tmp(path), "--import", "--trim"], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_zipread"), [], ["--verify", test.tmp(path)], test.tmp(path+"_3.opc_zipread"), [], {})
	test.regr(test.docs(path+"_3.opc_zipread"), test.tmp(path+"_3.opc_zipread"), True)

	test.call(test.build("opc_zipwrite"), [], [test.tmp(path), "--delete", "--commit"], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_zipread"), [], ["--verify", test.tmp(path)], test.tmp(path+"_4.opc_zipread"), [], {})
	test.regr(test.docs(path+"_4.opc_zipread"), test.tmp(path+"_4.opc_zipread"), True)

	test.call(test.build("opc_zipwrite"), [], [test.tmp(path), "--delete", "--trim"], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_zipread"), [], ["--verify", test.tmp(path)], test.tmp(path+"_5.opc_zipread"), [], {})
	test.regr(test.docs(path+"_5.opc_zipread"), test.tmp(path+"_5.opc_zipread"), True)
コード例 #7
0
def opc_trim_test(path):
	test.rm(test.tmp(path))
	test.cp(test.docs(path), test.tmp(path))
	test.call(test.build("opc_dump"), [], [test.docs(path)], test.tmp(path+"_1.opc_trim.opc_dump"), [], {})
	test.regr(test.docs(path+".opc_dump"), test.tmp(path+"_1.opc_trim.opc_dump"), True)
	test.call(test.build("opc_trim"), [], [test.tmp(path)], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_dump"), [], [test.docs(path)], test.tmp(path+"_2.opc_trim.opc_dump"), [], {})
	test.regr(test.tmp(path+"_1.opc_trim.opc_dump"), test.tmp(path+"_2.opc_trim.opc_dump"), True)
	test.call(test.build("opc_trim"), [], [test.tmp(path)], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_dump"), [], [test.docs(path)], test.tmp(path+"_3.opc_trim.opc_dump"), [], {})
	test.regr(test.tmp(path+"_2.opc_trim.opc_dump"), test.tmp(path+"_3.opc_trim.opc_dump"), True)
	test.call(test.build("opc_trim"), [], [test.tmp(path)], test.tmp("stdout.txt"), [], {})
	test.call(test.build("opc_dump"), [], [test.docs(path)], test.tmp(path+"_4.opc_trim.opc_dump"), [], {})
	test.regr(test.tmp(path+"_3.opc_trim.opc_dump"), test.tmp(path+"_4.opc_trim.opc_dump"), True)
コード例 #8
0
ファイル: model.py プロジェクト: pah8p/ML
def support_vector_machine(x, y, predict=False):

    x = x.reshape(len(x), 28 * 28)

    svc = regression.build('SVC',
                           C=0.1,
                           kernel='poly',
                           degree=2,
                           cache_size=500)
    svc.fit(x, y)
    print(svc.score(x, y))

    if predict:
        x_test = pandas.read_csv('test.csv')

        pred = pandas.DataFrame()
        pred['ImageId'] = list(range(1, 28000 + 1))
        pred['Label'] = svc.predict(x_test.to_numpy())
        pred.to_csv('predictions.csv', index=False)
コード例 #9
0
def opc_zipread_test(path):
	test.call(test.build("opc_zipread"), [], ["--verify", test.docs(path)], test.tmp(path+".opc_zipread"), [], {})
	test.regr(test.docs(path+".opc_zipread"), test.tmp(path+".opc_zipread"), True)
コード例 #10
0
def opc_zipextract_test(path):
	test.call(test.build("opc_zipextract"), [], [test.docs(path), "word/document.xml"], test.tmp(path+".opc_zipextract"), [], {})
	test.regr(test.docs(path+".opc_zipextract"), test.tmp(path+".opc_zipextract"), True)
コード例 #11
0
def opc_xml2_test(path):
	test.call(test.build("opc_xml2"), [], [test.docs(path)], test.tmp(path+".opc_xml2"), [], {})
	test.regr(test.docs(path+".opc_xml2"), test.tmp(path+".opc_xml2"), True)
コード例 #12
0
def opc_text_test(path):
	test.call(test.build("opc_text"), [], [test.docs(path)], test.tmp(path+".opc_text.html"), [], {})
	test.regr(test.docs(path+".opc_text.html"), test.tmp(path+".opc_text.html"), True)
コード例 #13
0
#])

x_train_np = x[:3000].to_numpy()
x_test_np = x[3000:].to_numpy()

#x_train.to_csv('x_train.csv', index=False)
#x_test.to_csv('x_test.csv', index=False)

#x_train_np = pandas.read_csv('x_train.csv').to_numpy()
#x_test_np = pandas.read_csv('x_test.csv').to_numpy()

#linear = regression.build('Linear')
#linear_cv = regression.cross_validate(linear, cleaner.x_train_np, y_np)
#print('LINEAR', linear_cv)

lasso = regression.build('Lasso', alpha=0.002)
#lasso_cv = regression.cross_validate(lasso, x_train_np, y_np)
#print('LASSO', lasso_cv)

elastic_net = regression.build('ElasticNet', alpha=0.002)
#elastic_net_cv = regression.cross_validate(elastic_net, x_train_np, y_np)
#print('ELASTIC NET', elastic_net_cv)

kernel_ridge = regression.build('KernelRidge')
#kernel_ridge_cv = regression.cross_validate(kernel_ridge, x_train_np, y_np)
#print('KERNEL RIDGE', kernel_ridge_cv)

gradient_boost = regression.build('GradientBoosting')
#gdcv = regression.cross_validate(gradient_boost, x_train_np, y_np)
#print('GRADIENT BOOST', gdcv)
コード例 #14
0
def opc_mem_test(path):
	test.call(test.build("opc_mem"), [], [test.docs(path)], test.tmp(path+".opc_mem"), [], {})
	test.regr(test.docs(path+".opc_dump"), test.tmp(path+".opc_mem"), True)
コード例 #15
0
def opc_extract_test(path, part):
	out_ext=".opc_extract."+part.replace("/", "-")
	test.call(test.build("opc_extract"), [], [test.docs(path), part], test.tmp(path)+out_ext, [], {})
	test.regr(test.docs(path)+out_ext, test.tmp(path)+out_ext, False)
コード例 #16
0
def mcepp_test(path):
    test.rm(test.tmp(path))
    test.call(test.build("mcepp"), [], [test.docs(path)], test.tmp(path+".mcepp"), [], {})
    test.regr(test.docs(path+".mcepp"), test.tmp(path+".mcepp"), True)
コード例 #17
0
def opc_image_test(path):
	test.call(test.build("opc_image"), [], [test.docs(path), test.tmp("")], test.tmp(path+".opc_image"), [], {})
	test.regr(test.docs(path+".opc_image"), test.tmp(path+".opc_image"), True)
コード例 #18
0
ファイル: model.py プロジェクト: pah8p/ML
y_np = y.drop('SalePrice', axis=1).to_numpy()

train_id = x_train['Id']
test_id = x_test['Id']

x_train.drop('Id', axis=1, inplace=True)
x_test.drop('Id', axis=1, inplace=True)

cleaner = Cleaner(x_train, x_test)
cleaner.clean(variables)

#linear = regression.build('Linear')
#linear_cv = regression.cross_validate(linear, cleaner.x_train_np, y_np)
#print('LINEAR', linear_cv)

lasso = regression.build('Lasso', alpha=0.002)
lasso_cv = regression.cross_validate(lasso, cleaner.x_train_np, y_np)

elastic_net = regression.build('ElasticNet', alpha=0.002)
elastic_net_cv = regression.cross_validate(elastic_net, cleaner.x_train_np,
                                           y_np)

kernel_ridge = regression.build('KernelRidge')
kernel_ridge_cv = regression.cross_validate(kernel_ridge, cleaner.x_train_np,
                                            y_np)

gradient_boost = regression.build('GradientBoosting')
#gdcv = regression.cross_validate(gradient_boost, cleaner.x_train_np, y_np)
#print('GRADIENT BOOST', gdcv)

xg_boost = regression.build(