def CV_A_Model_FromSQL(tag, model, vocab1,vocab2,myconfig,nfold=5,downsample=True): df_all = dfmaker.get_train_dfs(tag,myconfig,downsample) df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) #Test with cross-validation: modelmaker.model_cv(df_Train,model,vocab1,vocab2,nfold,downsample)
def CV_A_Model_FromSQL(tag, model, vocab1, vocab2, myconfig, nfold=5, downsample=True): df_all = dfmaker.get_train_dfs(tag, myconfig, downsample) df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) #Test with cross-validation: modelmaker.model_cv(df_Train, model, vocab1, vocab2, nfold, downsample)
def Train_Final_Model(tag, model, vocab1,vocab2,myconfig,downsample=True): df_all = dfmaker.get_train_dfs(tag,myconfig) #Check that CV looks fine: print "Checking CV (nfold=2):" modelmaker.model_cv(df_all,model,vocab1,vocab2,2,downsample) #Train the actual model: print "Training final model:" trained_model,trained_vocab1,trained_vocab2 = modelmaker.model_trainer(df_all,model,vocab1,vocab2,downsample) return trained_model, trained_vocab1, trained_vocab2
def Train_Final_Model(tag, model, vocab1, vocab2, myconfig, downsample=True): df_all = dfmaker.get_train_dfs(tag, myconfig) #Check that CV looks fine: print "Checking CV (nfold=2):" modelmaker.model_cv(df_all, model, vocab1, vocab2, 2, downsample) #Train the actual model: print "Training final model:" trained_model, trained_vocab1, trained_vocab2 = modelmaker.model_trainer( df_all, model, vocab1, vocab2, downsample) return trained_model, trained_vocab1, trained_vocab2
def CV_A_Model_FromSQL(tag, model, vocab1,vocab2,myconfig,nfold=5,downsample=True): """K-fold CV a model for time and performance, calling from MySQL tag = tag name model = model object (sklearn) to train to vocab1 = Body vocab vocab2 = Tag vocab myconfig = config file for accessing MySQL database nfold = number of folds for CV downsample = force spoiler and non-spoiler sets to have same size """ df_all = dfmaker.get_train_dfs(tag,myconfig,downsample) df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) #Test with cross-validation: modelmaker.model_cv(df_Train,model,vocab1,vocab2,nfold,downsample)
def CV_A_Model(model, vocab1,vocab2,df,nfold=5,downsample=True): """K-fold CV a model for time and performance model = model object (sklearn) to train to vocab1 = Body vocab vocab2 = Tag vocab df = Dataframe to sample from nfold = number of folds for CV downsample = force spoiler and non-spoiler sets to have same size """ #Start time: start_time = time.time() #Test with cross-validation: modelmaker.model_cv(df,model,vocab1,vocab2,nfold,downsample) #How much time elapsed? print "Time elapsed:",(time.time() - start_time)
def Train_Final_Model(tag, model, vocab1,vocab2,myconfig,downsample=True): """Given a tag name, train a model WITH CROSS-VALIDATION 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 """ df_all = dfmaker.get_train_dfs(tag,myconfig) #Check that CV looks fine: print "Checking CV (nfold=2):" modelmaker.model_cv(df_all,model,vocab1,vocab2,2,downsample) #Train the actual model: print "Training final model:" trained_model,trained_vocab1,trained_vocab2 = modelmaker.model_trainer(df_all,model,vocab1,vocab2,downsample) return trained_model, trained_vocab1, trained_vocab2
def CV_A_Model(model, vocab1, vocab2, df, nfold=5, downsample=True): start_time = time.time() #Test with cross-validation: modelmaker.model_cv(df, model, vocab1, vocab2, nfold, downsample) print "Time elapsed:", (time.time() - start_time)
def CV_A_Model(model, vocab1,vocab2,df,nfold=5,downsample=True): start_time = time.time() #Test with cross-validation: modelmaker.model_cv(df,model,vocab1,vocab2,nfold,downsample) print "Time elapsed:",(time.time() - start_time)