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 GetDFs(tag,myconfig): """Simply return Test and Train Dataframes for a given tag tag = tag name myconfig = config file for accessing MySQL database """ #Get all data: df_all = dfmaker.get_train_dfs(tag,myconfig) #Break into test and train: df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) return df_all, df_Train, df_Test
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
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 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
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 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 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
def GetDFs(tag, myconfig): df_all = dfmaker.get_train_dfs(tag, myconfig) df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) return df_all, df_Train, df_Test
def GetDFs(tag,myconfig): df_all = dfmaker.get_train_dfs(tag,myconfig) df_Train, df_Test = dfmaker.GenerateTestTrain(df_all) return df_all, df_Train, df_Test