コード例 #1
0
ファイル: report.py プロジェクト: felgari/kuicl
def do_report(index, k):
    
    b1_data = read_res_file(B1_RES_FILE)    
    
    a2_data = read_res_file(A2_RES_FILE)
    
    process_k(k, b1_data, a2_data, index)
コード例 #2
0
ファイル: genhis.py プロジェクト: felgari/kuicl
def main(index = DEFAULT_INDEX):
    
    b1_res = read_res_file(B1_RES_FILE)
    a2_res = read_res_file(A2_RES_FILE)
    
    if len(b1_res) and len(a2_res):
        
        cldat = ClDat()
        
        if cldat.loaded:
            b1_hist = gen_hist(b1_res, cldat.b1, HIST_FILE_B1, TYPE_1_COL)
            a2_hist = gen_hist(a2_res, cldat.a2, HIST_FILE_A2, TYPE_2_COL)
            
            if index != DEFAULT_INDEX:
                
                success, k, pro, pre, p = load_local_data(index, cl.b1, cl.a2)
                
                if success:
                    generate_final_hist(index, b1_hist, a2_hist, k, pro, pre, p, cldat)
                else:
                    print "ERROR: Generation of historical not possible, local data not available."
        else: 
            print "ERROR: Generation of historical not possible, cl not available."
    else:
        print "ERROR: Generation of historical not possible, res not available."
コード例 #3
0
def do_report(index, k, cl, pred_rf, pre, ex_mean):

    print "Generating report ..."

    b1_data = read_res_file(B1_RES_FILE)

    a2_data = read_res_file(A2_RES_FILE)

    process_k(k, b1_data, a2_data, cl, index, pred_rf, pre, ex_mean)
コード例 #4
0
def generate_hist(index, cl, k, pro, pre, p):

    b1_res = read_res_file(B1_RES_FILE)
    a2_res = read_res_file(A2_RES_FILE)

    if len(b1_res) and len(a2_res):
        b1_hist = gen_hist(b1_res, cl.b1, HIST_FILE_B1, TYPE_1_COL)
        a2_hist = gen_hist(a2_res, cl.a2, HIST_FILE_A2, TYPE_2_COL)

        generate_final_hist(index, b1_hist, a2_hist, k, pro, pre, p, cl)
    else:
        print "ERROR: Generation of historical not possible, res not available."
コード例 #5
0
ファイル: kuicl.py プロジェクト: felgari/kuicl
def generate_hist(index, cl, k, pro, pre, p):
    
    b1_res = read_res_file(B1_RES_FILE)
    a2_res = read_res_file(A2_RES_FILE)
    
    if len(b1_res) and len(a2_res):
        b1_hist = gen_hist(b1_res, cl.b1, HIST_FILE_B1, TYPE_1_COL)
        a2_hist = gen_hist(a2_res, cl.a2, HIST_FILE_A2, TYPE_2_COL)
        
        generate_final_hist(index, b1_hist, a2_hist, k, pro, pre, p, cl)
    else:
        print "ERROR: Generation of historical not possible, res not available."
コード例 #6
0
ファイル: resdifpos.py プロジェクト: felgari/kuicl
 def _calc_from_res(self, res_file_name, cl_data):
     
     final_dif = {}
     
     cl_dict = self._dict_from_cl(cl_data)
     
     res = read_res_file(res_file_name)
     
     for r in res:
         name1 = r[R_NAME_1_COL]
         name2 = r[R_NAME_2_COL]
         m = r[R_M_COL]
         
         dif = cl_dict[name1] - cl_dict[name2]
         
         sum = SUM_DIF_POS[m]
         
         try:
             val = final_dif[dif]
             
             new_val = [ val[i] + sum[i] for i in range(len(val))]
             
             final_dif.update( {dif: new_val} )
         except KeyError:
             final_dif.update( {dif: sum} )
     
     return final_dif
コード例 #7
0
ファイル: modsel.py プロジェクト: felgari/kuicl
def main():
    
    clda = ClDat()
    
    if clda.loaded:
    
        b1_res = read_res_file(B1_RES_FILE)
        a2_res = read_res_file(A2_RES_FILE)
        
        if len(b1_res) and len(a2_res):
            mdls_b1 = evaluate_all_models(clda.b1, b1_res)
            mdls_a2 = evaluate_all_models(clda.a2, a2_res)
            
            save_data_to_csv(MODELS_FILENAME, mdls_b1 + mdls_a2)
        else:
            print "Res data couldn't be read."
    else:
        print "Cl data couldn't be loaded."
コード例 #8
0
ファイル: pre.py プロジェクト: felgari/kuicl
 def _generate(self, force_calc):  
     
     pre_file_name = PRE_FILE_NAME_PREFIX + self._index + INPUT_FILE_NAME_EXT
     
     if not force_calc:
         self._pre = read_input_file(pre_file_name)
     
     if not len(self._pre):
     
         b1_res = read_res_file(B1_RES_FILE)
         a2_res = read_res_file(A2_RES_FILE)
         
         for k in self._k:
             if k[TYPE_COL] == TYPE_1_COL:  
                 cl_data = self._b1
                 res_data = b1_res
             else:
                 cl_data = self._a2
                 res_data = a2_res
                 
             lo_data, lo_target_data = Pre.get_data_for_pre(k[NAME_LO_COL], 
                                                            cl_data,
                                                            res_data, True) 
                 
             lo_mdl = Pre.get_mdl(k[NAME_LO_COL]) 
             
             vi_data, vi_target_data = Pre.get_data_for_pre(k[NAME_VI_COL], 
                                                            cl_data,
                                                            res_data, False)
                 
             vi_mdl = Pre.get_mdl(k[NAME_VI_COL]) 
                 
             print "Predicting: %s - %s" % (k[NAME_LO_COL], k[NAME_VI_COL])
             
             lo_pre = self.get_pre_values(lo_data, lo_target_data, 
                                          lo_mdl.lo_mdls)             
 
             vi_pre = self.get_pre_values(vi_data, vi_target_data, 
                                          vi_mdl.vi_mdls)
             
             self._pre.append(combine_lo_vi(lo_pre, vi_pre))
             
         if self.generated:
             save_data_to_csv(pre_file_name, self._pre)
コード例 #9
0
ファイル: pre.py プロジェクト: felgari/kuicl
    def _generate(self, force_calc):

        pre_file_name = PRE_FILE_NAME_PREFIX + self._index + INPUT_FILE_NAME_EXT

        if not force_calc:
            self._pre = read_input_file(pre_file_name)

        if not len(self._pre):

            b1_res = read_res_file(B1_RES_FILE)
            a2_res = read_res_file(A2_RES_FILE)

            for k in self._k:
                if k[TYPE_COL] == TYPE_1_COL:
                    cl_data = self._b1
                    res_data = b1_res
                else:
                    cl_data = self._a2
                    res_data = a2_res

                lo_data, lo_target_data = Pre.get_data_for_pre(
                    k[NAME_LO_COL], cl_data, res_data, True)

                lo_mdl = Pre.get_mdl(k[NAME_LO_COL])

                vi_data, vi_target_data = Pre.get_data_for_pre(
                    k[NAME_VI_COL], cl_data, res_data, False)

                vi_mdl = Pre.get_mdl(k[NAME_VI_COL])

                print "Predicting: %s - %s" % (k[NAME_LO_COL], k[NAME_VI_COL])

                lo_pre = self.get_pre_values(lo_data, lo_target_data,
                                             lo_mdl.lo_mdls)

                vi_pre = self.get_pre_values(vi_data, vi_target_data,
                                             vi_mdl.vi_mdls)

                self._pre.append(combine_lo_vi(lo_pre, vi_pre))

            if self.generated:
                save_data_to_csv(pre_file_name, self._pre)