示例#1
0
def mx_mul(mlst, x_test,  y_test,yk0=5,fgInt=False,fgDebug=False):    
    #1
    print('\ny_pred,预测')
    df9,xc,mxn9=x_test.copy(),0,len(mlst)
    df9['y_test']=y_test
    #2   
    for msgn in mlst:
        xc+=1;tim0=arrow.now()
        mx=xmodel[msgn]
        y_pred = mx.predict(x_test.values)
        #3
        if xc==1:df9['y_sum']=y_pred
        else:df9['y_sum']=df9['y_sum']+y_pred            
        #4
        tn=zt.timNSec('',tim0)
        df9['y_pred']=y_pred
        #4.b   
        if fgInt:
            df9['y_predsr']=df9['y_pred']
            df9['y_pred']=round(df9['y_predsr']).astype(int)
       
        #5   
        dacc=ai_acc_xed(df9,yk0,fgDebug)
        xss='y_pred{0:02},kok:{1:.2f}%'.format(xc,dacc);print(xc,xss,msgn,tn,'s')
        ysgn='y_pred'+str(xc);df9[ysgn]=y_pred
    #6
    df9['y_pred']=df9['y_sum']/mxn9
    
    if fgInt:
        df9['y_predsr']=df9['y_pred']
        df9['y_pred']=round(df9['y_predsr']).astype(int)
        
    #7    
    dacc=zat.ai_acc_xed(df9,yk0,fgDebug)    
    #8
    if fgDebug:
        df9.to_csv('tmp/df9_pred.csv');
   
    #9
    print('@mx:mx_sum,kok:{0:.2f}%'.format(dacc))   
    return dacc,df9        
示例#2
0
def mx_fun_call(df,xlst,ysgn,funSgn,yksiz=1,yk0=5,fgInt=False,fgDebug=False):
    #1
    df[ysgn]=df[ysgn].astype(float)
    df[ysgn]=round(df[ysgn]*yksiz).astype(int)
    
    
    #2
    x,y= df[xlst],df[ysgn]  
    #3
    x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1)
    num_train, num_feat = x_train.shape
    num_test, num_feat = x_test.shape
    print('\nn_tran:,',num_train,' ,ntst,' , num_test, ' ,dimension:,',num_feat,',kbin,',fgInt)
    
    #4
    print('\ny_pred,预测')
    df9=x_test.copy()
    mx_fun=mxfunSgn[funSgn]
    mx =mx_fun(x_train.values,y_train.values)
    #5
    y_pred = mx.predict(x_test.values)
    df9['y_test'],df9['y_pred']=y_test,y_pred
    #6
    if fgInt:
        df9['y_predsr']=df9['y_pred']
        df9['y_pred']=round(df9['y_predsr']).astype(int)
        
    #7
    dacc=zat.ai_acc_xed(df9,yk0,fgDebug)
    #8
    if fgDebug:
        #print(df9.head())
        print('@fun name:',mx_fun.__name__)
        df.to_csv('tmp/df_sr.csv');
        df9.to_csv('tmp/df9_pred.csv');
    #------------
    #9
    print('@mx:mx_sum,kok:{0:.2f}%'.format(dacc))   
    return dacc,df9    
示例#3
0
def mx_fun8mx(mx,x_test,y_test,yk0=5,fgInt=False,fgDebug=False):
    #1
    df9=x_test.copy()
    #mx=....
    #2
    y_pred = mx.predict(x_test.values)
    df9['y_test'],df9['y_pred']=y_test,y_pred
    #3   
    if fgInt:
        df9['y_predsr']=df9['y_pred']
        df9['y_pred']=round(df9['y_predsr']).astype(int)
        
    #4
    dacc=zat.ai_acc_xed(df9,yk0,fgDebug)
    #5
    if fgDebug:
        #print(df9.head())
        #print('@fun name:',mx_fun.__name__)
        df9.to_csv('tmp/df9_pred.csv',index=False);
    #
    #6
    #print('@mx:mx_sum,kok:{0:.2f}%'.format(dacc))   
    return dacc,df9       
示例#4
0
def mx_fun010(funSgn,x_train, x_test, y_train, y_test,yk0=5,fgInt=False,fgDebug=False):
    #1
    df9=x_test.copy()
    mx_fun=mxfunSgn[funSgn]
    mx =mx_fun(x_train.values,y_train.values)
    #2
    y_pred = mx.predict(x_test.values)
    df9['y_test'],df9['y_pred']=y_test,y_pred
    #3   
    if fgInt:
        df9['y_predsr']=df9['y_pred']
        df9['y_pred']=round(df9['y_predsr']).astype(int)
        
    #4
    dacc=zat.ai_acc_xed(df9,yk0,fgDebug)
    #5
    if fgDebug:
        #print(df9.head())
        print('@fun name:',mx_fun.__name__)
        df9.to_csv('tmp/df9_pred.csv');
    #
    #6
    print('@mx:mx_sum,kok:{0:.2f}%'.format(dacc))   
    return dacc,df9