How to use test_l1 method in avocado

Best Python code snippet using avocado_python

fasttext_classify.py

Source:fasttext_classify.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3处理原始数据,生成训练数据集4@author: bruce5"""6import os,re7import time8import fastText.FastText as ff9from read_write_tool import read_file10 11#训练分类模型12def fastText_classifier(train_data,test_data,model_save_path,result_save_path):13 files = []14 results = []15 if not os.path.exists(train_data):16 os.makedirs(train_data)17 if not os.path.exists(model_save_path):18 os.makedirs(model_save_path)19 if not os.path.exists(result_save_path):20 os.makedirs(result_save_path)2122 for level_one,test_l1 in zip(os.listdir(train_data),os.listdir(test_data)):23 print(level_one+'-->'+test_l1)2425 if '.txt' in level_one and '.txt' in test_l1:26 classifier=ff.train_supervised(train_data+level_one,、lr=0.1,loss='hs',wordNgrams=2,epoch=100)27 #classifier = load_model.load_model(model_save_path+'train_level_1_classifier.model','nt')28 model = classifier.save_model(model_save_path+level_one+'_classifier.model') # 保存模型29 classifier.get_labels() # 输出标签30 result = classifier.test(test_data+test_l1)31 files.append(level_one)32 results.append(result)33 print(result)34 else:35 data_list = os.listdir(train_data+level_one+'/')36 test_list = os.listdir(test_data+test_l1+'/')37 if not len(data_list) or not len(test_data):38 continue39 classifier=ff.train_supervised(train_data+level_one+'/'+data_list[0],lr=0.1,loss='hs',wordNgrams=2,epoch=50)40 #classifier = load_model.load_model(model_save_path+'train_level_1_classifier.model','nt')41 model = classifier.save_model(model_save_path+level_one+'_classifier.model') # 保存模型42 classifier.get_labels() # 输出标签43 result = classifier.test(test_data+test_l1+'/'+test_list[0])44 files.append(data_list[0])45 results.append(result)46 print(result)47 print(files)48 print(results)4950 with open(result_save_path+'train_results.txt','w') as fp:51 for i,j in zip(files,results):52 fp.write(str(i)+'-->'+str(j))53 fp.write('\n')54 '''55 #linux系统56 classifier=fasttext.supervised(train_data+'level_3_train.txt',lr=0.1,loss='hs',wordNgrams=2,epoch=100,lable_prefix='__lable__')57 model = classifier.save_model(model_save_path+'fastText_classifier.model') # 保存模型58 classifier.get_labels() # 输出标签59 result = classifier.test(train_data+'level_3_train.txt')60 print(result) 61 # print("P@1:",result.precision) #准确率62 # print("R@2:",result.recall) #召回率63 # print("Number of examples:",result.nexamples) #预测错的例子64 '''65if __name__ == '__main__':66 train_path = '../datas/data_set/train/'67 test_path = '../datas/data_set/test/'68 model_save_path = '../datas/model/paper_train/'69 result_save_path = '../datas/results/paper_train/' ...

Full Screen

Full Screen

test_multipler.py

Source:test_multipler.py Github

copy

Full Screen

1import pytest2from sandpit_package.mathers.multiplier import Multiplier3expected_op = "*"4test_l1 = 55test_r1 = 76expected_result1 = test_l1 * test_r17expected_msg1 = "%s %s %s = %s" % (test_l1, expected_op, test_r1, expected_result1)8test_l2 = "abc"9test_r2 = 510expected_result2 = test_l2 * test_r211expected_msg2 = "%s %s %s = %s" % (test_l2, expected_op, test_r2, expected_result2)12def test_init():13 with pytest.raises(Exception):14 x1 = Multiplier()15 with pytest.raises(Exception):16 x2 = Multiplier(test_l1)17 x3 = Multiplier(test_l1, test_r1)18 assert (x3.l, x3.r) == (test_l1, test_r1)19 x4 = Multiplier(test_l2, test_r2)20 assert (x4.l, x4.r) == (test_l2, test_r2)21def test_op_str():22 x = Multiplier(test_l1, test_r1)23 assert x._op_str() == expected_op24def test_result():25 x1 = Multiplier(test_l1, test_r1)26 assert x1.result() == expected_result127 x1 = Multiplier(test_r1, test_l1)28 assert x1.result() == expected_result129 x2 = Multiplier(test_l2, test_r2)30 assert x2.result() == expected_result231 x2 = Multiplier(test_r2, test_l2)32 assert x2.result() == expected_result233def test_msg():34 x1 = Multiplier(test_l1, test_r1)35 assert x1._msg() == expected_msg136 x2 = Multiplier(test_l2, test_r2)37 assert x2._msg() == expected_msg238def test_print(capsys):39 x1 = Multiplier(test_l1, test_r1)40 x1.print()...

Full Screen

Full Screen

test_adder.py

Source:test_adder.py Github

copy

Full Screen

1import pytest2from sandpit_package.mathers.adder import Adder3expected_op = "+"4test_l1 = 55test_r1 = 76expected_result1 = test_l1 + test_r17expected_msg1 = "%s %s %s = %s" % (test_l1, expected_op, test_r1, expected_result1)8test_l2 = "abc"9test_r2 = "def"10expected_result2 = test_l2 + test_r211expected_msg2 = "%s %s %s = %s" % (test_l2, expected_op, test_r2, expected_result2)12def test_init():13 with pytest.raises(Exception):14 x1 = Adder()15 with pytest.raises(Exception):16 x2 = Adder(test_l1)17 x3 = Adder(test_l1, test_r1)18 assert (x3.l, x3.r) == (test_l1, test_r1)19 x4 = Adder(test_l2, test_r2)20 assert (x4.l, x4.r) == (test_l2, test_r2)21def test_op_str():22 x = Adder(test_l1, test_r1)23 assert x._op_str() == expected_op24def test_result():25 x1 = Adder(test_l1, test_r1)26 assert x1.result() == expected_result127 x1 = Adder(test_r1, test_l1)28 assert x1.result() == expected_result129 x2 = Adder(test_l2, test_r2)30 assert x2.result() == expected_result231 x2 = Adder(test_r2, test_l2)32 assert x2.result() != expected_result233def test_msg():34 x1 = Adder(test_l1, test_r1)35 assert x1._msg() == expected_msg136 x2 = Adder(test_l2, test_r2)37 assert x2._msg() == expected_msg238def test_print(capsys):39 x1 = Adder(test_l1, test_r1)40 x1.print()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful