Beispiel #1
0
def main(argv):
    conf_file = argv[1]
    impstr = "import %s as conf" % conf_file
    print impstr
    exec impstr

    dfAll = None
    for each in conf.l_params:
        print each
        cls = joblib.load(os.path.join(root, 'data', 'models',"model_" + each[0]+ ".pkl"))
        sym2ta = model.get_all_from(each[1])
        df = model.build_trains(sym2ta, each[3][0], each[3][1])
        feat_names = model.get_feat_names(df)
        npFeat = df.loc[:,feat_names].values
        df["pred"] = cls.predict_proba(npFeat)[:,1]
        if dfAll is None:
            dfAll = df
        else:
            dfAll = dfAll.append(df)
    dfAll.to_csv(os.path.join(root, 'data', 'crosses', conf_file+ ".csv"))
    dacc =  accu(dfAll, each[2], 0.0)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"]*1.0 / dacc["pos"]
    dacc =  accu(dfAll, each[2], 0.5)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"]*1.0 / dacc["pos"]
    dacc =  accu(dfAll, each[2], 0.6)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"]*1.0 / dacc["pos"]
    dacc =  accu(dfAll, each[2], 0.7)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"]*1.0 / dacc["pos"]
    dacc =  accu(dfAll, each[2], 0.8)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"]*1.0 / dacc["pos"]
Beispiel #2
0
def main(argv):
    conf_file = argv[1]
    impstr = "import %s as conf" % conf_file
    print impstr
    exec impstr

    dfAll = None
    for each in conf.l_params:
        print each
        cls = joblib.load(
            os.path.join(root, 'data', 'models', "model_" + each[0] + ".pkl"))
        sym2ta = model.get_all_from(each[1])
        df = model.build_trains(sym2ta, each[3][0], each[3][1])
        feat_names = model.get_feat_names(df)
        npFeat = df.loc[:, feat_names].values
        df["pred"] = cls.predict_proba(npFeat)[:, 1]
        if dfAll is None:
            dfAll = df
        else:
            dfAll = dfAll.append(df)
    dfAll.to_csv(os.path.join(root, 'data', 'crosses', conf_file + ".csv"))
    dacc = accu(dfAll, each[2], 0.0)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"] * 1.0 / dacc["pos"]
    dacc = accu(dfAll, each[2], 0.5)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"] * 1.0 / dacc["pos"]
    dacc = accu(dfAll, each[2], 0.6)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"] * 1.0 / dacc["pos"]
    dacc = accu(dfAll, each[2], 0.7)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"] * 1.0 / dacc["pos"]
    dacc = accu(dfAll, each[2], 0.8)
    print dacc["trueInPos"], dacc["pos"], dacc["trueInPos"] * 1.0 / dacc["pos"]
Beispiel #3
0
def one_work(cls, ta_dir, label, date_range, th):
    re =  "%s\t%s\t%s\t%s\t%s\t%f\t" % (cls, ta_dir[-4:], label, date_range[0], date_range[1],th)
    merged_file = os.path.join(ta_dir, "merged.pkl")
    df = filter_(get_df(merged_file))
    df = get_range(df, date_range[0], date_range[1])
    cls = joblib.load(os.path.join(root, 'data', 'models',"model_" + cls + ".pkl"))
    feat_names = model.get_feat_names(df)
    npFeat = df.loc[:,feat_names].values
    npPred = cls.predict_proba(npFeat)[:,1]
    df["pred"] = npPred
    dacc =  accu(df, label, th)
    re += "%d\t%d\t" % (dacc["trueInPos"], dacc["pos"])
    if dacc["pos"] > 0:
        re += "%f" % (dacc["trueInPos"]*1.0 / dacc["pos"])
    else :
        re += "0.0"
    return re
Beispiel #4
0
def one_work(cls, ta_dir, label, date_range, th):
    re = "%s\t%s\t%s\t%s\t%s\t%f\t" % (cls, ta_dir[-4:], label, date_range[0],
                                       date_range[1], th)
    merged_file = os.path.join(ta_dir, "merged.pkl")
    df = filter_(get_df(merged_file))
    df = get_range(df, date_range[0], date_range[1])
    cls = joblib.load(
        os.path.join(root, 'data', 'models', "model_" + cls + ".pkl"))
    feat_names = model.get_feat_names(df)
    npFeat = df.loc[:, feat_names].values
    npPred = cls.predict_proba(npFeat)[:, 1]
    df["pred"] = npPred
    dacc = accu(df, label, th)
    re += "%d\t%d\t" % (dacc["trueInPos"], dacc["pos"])
    if dacc["pos"] > 0:
        re += "%f" % (dacc["trueInPos"] * 1.0 / dacc["pos"])
    else:
        re += "0.0"
    return re