예제 #1
0
def ModelIt(name, cut, df, myconfig):

    config = ConfigParser.RawConfigParser()
    config.read(myconfig)

    #MySQL info:
    db_username = config.get('DB', 'username')
    db_pwd = config.get('DB', 'pwd')

    #Database connection:
    con = mdb.connect('localhost', db_username, db_pwd, 'InsightPaths')
    path = "/home/ubuntu/WebApp/Web/FanGuardFlask/files"

    #Prefilter Models:
    vp1, vp2, pcutval = GetPFModel(name, con, path)
    c0 = GetPred(df, vp1, vp2)
    #p0 = pmodel.predict_proba(Xp0)[:,1]

    #Spoiler Filter Models:
    smodel, vs1, vs2, scutval = GetSFModel(name, con, path, cut)
    p1 = modelmaker.model_tester(df, smodel, vs1, vs2)

    #c0 = (p0>pcutval).astype(int)
    #c0 = c0.reshape(c0.shape[0],1)

    c1 = (p1 > scutval).astype(int)
    c1 = c1.reshape(c1.shape[0], 1)

    return c0 * c1
예제 #2
0
def Train_A_Model_Direct(tag, model, vocab1,vocab2,df_Train,df_Test):

    #Train the actual model:
    trained_model,trained_vocab,tagged_vocab = modelmaker.model_trainer(df_Train,model,vocab1,vocab2)

    #Get predictions
    result = modelmaker.model_tester(df_Test,trained_model,trained_vocab,tagged_vocab)

    return trained_model, trained_vocab, tagged_vocab, result, df_Test
예제 #3
0
def Train_A_Model_Direct(tag, model, vocab1, vocab2, df_Train, df_Test):

    #Train the actual model:
    trained_model, trained_vocab, tagged_vocab = modelmaker.model_trainer(
        df_Train, model, vocab1, vocab2)

    #Get predictions
    result = modelmaker.model_tester(df_Test, trained_model, trained_vocab,
                                     tagged_vocab)

    return trained_model, trained_vocab, tagged_vocab, result, df_Test
예제 #4
0
def Train_A_Model(tag, model, vocab1,vocab2,myconfig,downsample=True):

    df_all = dfmaker.get_train_dfs(tag,myconfig)
    df_Train, df_Test = dfmaker.GenerateTestTrain(df_all)

    #Train the actual model:
    trained_model,trained_vocab,tagged_vocab = modelmaker.model_trainer(df_Train,model,vocab1,vocab2,downsample)

    #Get predictions
    result = modelmaker.model_tester(df_Test,trained_model,trained_vocab,tagged_vocab)

    return trained_model, trained_vocab, tagged_vocab, result, df_Test
예제 #5
0
def Train_A_Model(tag, model, vocab1, vocab2, myconfig, downsample=True):

    df_all = dfmaker.get_train_dfs(tag, myconfig)
    df_Train, df_Test = dfmaker.GenerateTestTrain(df_all)

    #Train the actual model:
    trained_model, trained_vocab, tagged_vocab = modelmaker.model_trainer(
        df_Train, model, vocab1, vocab2, downsample)

    #Get predictions
    result = modelmaker.model_tester(df_Test, trained_model, trained_vocab,
                                     tagged_vocab)

    return trained_model, trained_vocab, tagged_vocab, result, df_Test
예제 #6
0
파일: AnaFunc.py 프로젝트: rbtoner/Fanguard
def Train_A_Model_Direct(tag, model, vocab1,vocab2,df_Train,df_Test):
    """Given a testing and training dataframe, train a model
    tag = tag name
    model = model object (sklearn) to train to
    vocab1 = Body vocab
    vocab2 = Tag vocab
    df_Train = Train dataframe
    df_Test = Test dataframe
    """
    
    #Train the actual model:
    trained_model,trained_vocab,tagged_vocab = modelmaker.model_trainer(df_Train,model,vocab1,vocab2)

    #Get predictions
    result = modelmaker.model_tester(df_Test,trained_model,trained_vocab,tagged_vocab)

    #Return trained model, vocab, prediction:
    return trained_model, trained_vocab, tagged_vocab, result, df_Test
예제 #7
0
파일: AnaFunc.py 프로젝트: rbtoner/Fanguard
def Train_A_Model(tag, model, vocab1,vocab2,myconfig,downsample=True):
    """Given a tag name, train a model
    tag = tag name
    model = model object (sklearn) to train to
    vocab1 = Body vocab
    vocab2 = Tag vocab
    myconfig = config file for accessing MySQL database
    downsample = force spoiler and non-spoiler sets to have same size
    """

    #Get the data and make Test/Train frames:
    df_all = dfmaker.get_train_dfs(tag,myconfig)
    df_Train, df_Test = dfmaker.GenerateTestTrain(df_all)

    #Train the actual model:
    trained_model,trained_vocab,tagged_vocab = modelmaker.model_trainer(df_Train,model,vocab1,vocab2,downsample)

    #Get predictions
    result = modelmaker.model_tester(df_Test,trained_model,trained_vocab,tagged_vocab)

    #Return trained model, vocab, prediction:
    return trained_model, trained_vocab, tagged_vocab, result, df_Test