def sousProcessClassify(c,n_fold, loadingFolder): #subprocess.call(["/media/lalil0u/New/software2/downloads/unpacked/svm-python-v204/svm_python_classify", "--m", "test", "-v", "3", "results/data_TEST_fold"+str(n_fold)+".pkl", "results/modelfile_"+c+"_"+str(n_fold)+".pkl"]) f = open(loadingFolder+"models/modelfile_"+c+"_"+str(n_fold)+".pkl", 'r') mesPoids = pickle.load(f) f.close() #pdb.set_trace() test_sol = classify.read_examples(loadingFolder+"data_TEST_fold"+str(n_fold)+".pkl") total_loss = []; test_contenu = [] for (x,y) in test_sol: test_contenu.append(classify.contenu(y)) ybar = classify.classify_example(x, mesPoids) l = classify.loss(y, ybar)#attention ce n'est plus la hamming loss ms une liste de cinq chiffres total_loss = l if total_loss == [] else np.vstack((total_loss, l)) return total_loss, test_contenu
def sousProcessClassify(sol, loadingFolder, loadingFile= None, i =None, n_f =None, n_big_f=None): #subprocess.call(["/media/lalil0u/New/software2/downloads/unpacked/svm-python-v204/svm_python_classify", "--m", "test", "-v", "3", "results/data_TEST_fold"+str(n_fold)+".pkl", "results/modelfile_"+c+"_"+str(n_fold)+".pkl"]) if i==None: f = open(os.path.join(loadingFolder,"modelfile_all.pkl"), 'r') elif n_f==None: c = "{:f}".format(10**i) if n_big_f==None: f = open(os.path.join(loadingFolder,"modelfile_all"+c+".pkl"), 'r') else: f = open(os.path.join(loadingFolder,"modelfile_all"+c+"_"+str(n_big_f)+".pkl"), 'r') else: c = "{:f}".format(10**i) if n_big_f is not None: f = open(os.path.join(loadingFolder,"modelfile_"+c+"_"+str(n_big_f)+'_'+str(n_f)+".pkl"), 'r') else: f = open(os.path.join(loadingFolder,"modelfile_"+c+"_"+str(n_f)+".pkl"), 'r') mesPoids = pickle.load(f) f.close() new_sol = [] zz=0 if loadingFile == None: for solu in sol.lstSolutions: new_sol.append((solu, solu.truthVec())) zz+=1 else: new_sol = classify.read_examples(loadingFile) for x,_ in new_sol: r1=[] try: ybar = classify.classify_example(x, mesPoids) except: print "pbl de NaN" x.truth = "PROBLEME DE NaN" continue else: for k in range(len(ybar)): r1.extend(ybar[k]) x.truth = r1 return new_sol