for train_index, test_index in skf.split(atribute, output): x_train_com, x_test = atribute.iloc[train_index, :], atribute.iloc[ test_index, :] y_train_com, Y_test = output.iloc[train_index, :], output.iloc[ test_index, :] x_train_un, x_train_st, y_train_un, Y_train = train_test_split( x_train_com, y_train_com, test_size=testsize2, random_state=31) """ STRUCTURED PREDICTORS """ ACC_ST[i, :], HL_ST[i, :], time_ST[i, :] = Strukturni( x_train_com, y_train_com, x_test, Y_test) """ UNSTRUCTURED PREDICTORS """ Skor_com_AUC[i, :], Skor_com_AUC2[i, :], Skor_com_ACC[i, :], Skor_com_ACC2[ i, :], Skor_com_HL[ i, :], R_train, R_test, R2, Noinst_train, Noinst_test, timeUN[ i, :] = Nestrukturni_fun(x_train_un, y_train_un, x_train_st, Y_train, x_test, Y_test, No_class) """ STructured matrix """ Se_train, Se_test = Struktura_fun(No_class, NoGraph, R2, y_train_com, Noinst_train, Noinst_test) """ Model GCRFC """ Y_train = Y_train.values Y_test = Y_test.values start_time = time.time() mod1 = GCRFCNB() mod1.fit(R_train, Se_train, Y_train, learn='TNC', learnrate=6e-4, maxiter=iteracija)
staze = np.load('staze.npy') staze = staze.astype(int) skijasi = pd.read_csv(str(staze[0]),index_col='date1') output = skijasi.label atribute = skijasi.drop(['label','vreme_pros'],axis=1) skf = KFold(n_splits = broj_fold) skf.get_n_splits(atribute, output) i = 0 for train_index,test_index in skf.split(atribute, output): timeST[i,:], Skor_R2_struct[i,:] = Strukturni_predict_fun(train_index, test_index, ModelSTNo) Skor_com_AUC[i,:], Skor_com_AUC2[i,:], R_train, R_test, R2, Noinst_train, Noinst_test, Y_train, Y_test = Nestrukturni_fun(train_index, test_index, No_class, testsize2) Se_train, Se_test = Struktura_fun(No_class,NoGraph,R2, train_index, test_index, Noinst_train, Noinst_test, testsize2) """ Model GCRFC """ start_time = time.time() mod1 = GCRFCNB() mod1.fit(R_train, Se_train, Y_train, learn = 'TNC', learnrate = 6e-4, maxiter = iteracija) probNB, YNB = mod1.predict(R_test,Se_test) timeNB[i] = time.time() - start_time start_time = time.time() mod2 = GCRFC() mod2.fit(R_train, Se_train, Y_train, learn = 'TNC', learnrate = 3e-4, learnratec = 0.5, maxiter = iteracija) np.save('mod2',mod2.x)
test_index, :] x_train_un, x_train_st, y_train_un1, Y_train1 = train_test_split( x_train_com, y_train_com, test_size=testsize2, random_state=31) Y_test = Y_test1.iloc[:, :18] Y_train = Y_train1.iloc[:, :18] y_train_un = y_train_un1.iloc[:, :18] Y_test_reg = Y_test1.iloc[:, 18:] Y_train_reg = Y_train1.iloc[:, 18:] y_train_un_reg = y_train_un1.iloc[:, 18:] timeST[i, :], Skor_R2_struct[i, :] = Strukturni_predict_fun( train_index, test_index, atribute, output, ModelSTNo) Skor_com_AUC[i, :], Skor_com_AUC2[ i, :], R_train, R_test, R2, Noinst_train, Noinst_test = Nestrukturni_fun( x_train_un, y_train_un, x_train_st, Y_train, x_test, Y_test, No_class) Se_train, Se_test = Struktura_fun(No_class, NoGraph, R2, y_train_com, Noinst_train, Noinst_test) """ Model GCRFC """ Y_train = Y_train.values Y_test = Y_test.values start_time = time.time() mod1 = GCRFCNB() mod1.fit(R_train, Se_train, Y_train, learn='TNC', learnrate=6e-4, maxiter=iteracija)
y_train_com, Y_test = output.iloc[train_index,:], output.iloc[test_index,:] provera = Y_test[Y_test==1].any().all() print(provera) file = open("rezultatiEMOCIJE.txt","w") for train_index,test_index in skf.split(atribute, output): x_train_com, x_test = atribute.iloc[train_index,:], atribute.iloc[test_index,:] y_train_com, Y_test = output.iloc[train_index,:], output.iloc[test_index,:] x_train_un, x_train_st, y_train_un, Y_train = train_test_split(x_train_com, y_train_com, test_size=testsize2, random_state=31) """ STRUCTURED PREDICTORS """ ACC_ST[i,:], HL_ST[i,:], time_ST[i,:] = Strukturni(x_train_com, y_train_com, x_test, Y_test) """ UNSTRUCTURED PREDICTORS """ Skor_com_AUC[i,:], Skor_com_AUC2[i,:], Skor_com_ACC[i,:], Skor_com_ACC2[i,:], Skor_com_HL[i,:], R_train, R_test, R2, Noinst_train, Noinst_test, timeUN[i,:] = Nestrukturni_fun(x_train_un, y_train_un, x_train_st, Y_train, x_test, Y_test, No_class) """ STructured matrix """ Se_train, Se_test = Struktura_fun(No_class,NoGraph, R2 , y_train_com, Noinst_train, Noinst_test) """ Model GCRFC """ Y_train = Y_train.values Y_test = Y_test.values start_time = time.time() mod1 = GCRFCNB() mod1.fit(R_train, Se_train, Y_train, learn = 'TNC', learnrate = 6e-4, maxiter = iteracija) probNB, YNB = mod1.predict(R_test,Se_test) timeNB[i] = time.time() - start_time start_time = time.time()