""" ## strategy: retrain-new oracle_retrain_new_errors = [] oracle_retrain_new = lg.LgSegmentModel(xs,ys,ss,'train-all',k) svm_retrain_new = lg.UserDefineModel(xs,ys,dy,ss,'train-all') # using the default value test_xs,test_ys,test_ss = digits.generate_additional_data (tasks, oracle_retrain_new, svm_retrain_new,3) for j in range(train_iter): oracle_retrain_new.train_all_fs() oracle_retrain_new.train_ws() oracle_retrain_new.strategy = 'retrain-new' svm_retrain_new.train_all_fs() svm_retrain_new.train_ws() svm_retrain_new_errors = [] svm_retrain_new.strategy = 'retrain-new' oracle_err = lg.seg_model_error_01(oracle_retrain_new, test_xs, test_ys, test_ss, num=20) oracle_retrain_new_errors.append(oracle_err) svm_err = lg.seg_model_error_01(svm_retrain_new,test_xs,test_ys,test_ss) svm_retrain_new_errors.append(svm_err) print "Initial Error OracleMTL---Train All: %f" % oracle_err print 'Initial Error SVM_mtl---Train All: ', svm_err """ ## strategy: average-weight oracle_average_weight_errors = [] oracle_average_weight = lg.LgSegmentModel(xs,ys,ss,'train-all',k) svm_average_weight = lg.UserDefineModel(xs,ys,dy,ss,'train-all') # using the default value test_xs,test_ys,test_ss = digits.generate_additional_data (tasks, oracle_average_weight, svm_average_weight,3) for j in range(train_iter): oracle_average_weight.train_all_fs()
test_Z = digits.normalize_digits(test_x) #Z = digits.fourier_project(train_x) ####### Initialization ########## tasks = digits.create_mtl_datasets(Z, train_y, nTasks=100, taskSize=30, testSize=40) xs,ys,dy,ss,test_xs,test_ys,test_dy,test_ts = digits.generate_data(tasks) k = 20 k_svm = 10 oracle_mtl_errors = [] oracle_mtl = lg.LgSegmentModel(xs,ys,ss,'train-all',k) for j in range(6): oracle_mtl.train_all_fs() oracle_mtl.train_ws() oracle_err = lg.seg_model_error_01(oracle_mtl, test_xs, test_ys, test_ts, num=20) #oracle_mtl_errors.append(oracle_err) print "Initial Error OracleMTL: %f" % oracle_err svm_mtl = lg.UserDefineModel(xs,ys,dy,ss,'train-all','l2') # using the default value svm_mtl.train_all_fs() svm_mtl.train_ws() svm_err = lg.seg_model_error_01(svm_mtl,test_xs,test_ys,test_ts) print 'Initial Error SVM_mtl-l2 ', svm_err svm_feature_errors = [] svm_mtl1 = lg.UserDefineModel(xs,ys,dy,ss,'train-all','l1') # using the default value svm_mtl1.train_all_fs() svm_mtl1.train_ws() svm_err = lg.seg_model_error_01(svm_mtl1,test_xs,test_ys,test_ts) print 'Initial Error SVM_mtl-l1 ', svm_err