def main(targets): ''' Runs the main project pipeline logic, given the targets. targets must contain: 'data', 'analysis', 'model'. `main` runs the targets in order of data=>analysis=>model. ''' start_prog = timeit.default_timer() if 'data' in targets: with open('config/data-params.json', 'r', encoding="utf-8") as fh: data_cfg = json.load(fh) # make the data target data = clean_data(**data_cfg) if 'analysis' in targets: with (open('config/analysis-params.json')) as fh: analysis_cfg = json.load(fh) #make the data target X, y = prepare_data(data, **analysis_cfg) if 'model' in targets: with open('config/model-params.json') as fh: model_cfg = json.load(fh) # make the data target train_data(X, y, **model_cfg) stop_prog = timeit.default_timer() print("overall runtime: ", stop_prog - start_prog) return
def train(): path = 'models/' if len(os.listdir(path)) == 0: train_data(log_writer) else: pass return render_template('index.html')
def __init__(self, load): self.lastPercent = 0.0 self.bestPercent = 0.0 if (load != '0'): print("\ncreating train data...") sys.stdout.flush() self.td = train.train_data(files_location) pickle.dump(self.td, open("_train_data.p", "wb")) print("created sucessfully\n") sys.stdout.flush() else: print("\nloading train data...") sys.stdout.flush() self.td = pickle.load(open("_train_data.p", "rb")) print("loaded sucessfully\n") sys.stdout.flush() self.nn = nn_matrix.neural_network(len(self.td.inputs[0][0]),len(self.td.authors),nlayers,dummy_var, learn_rate)
def train(): print('train start') data_dir=request.args.get('data_dir') train_dir=request.args.get('train_dir') train_dir=makeDir(train_dir) if train_data(data_dir=data_dir,train_dir=train_dir): json_path=os.path.join(data_dir,'state.json') json_state={"names":[]} filenames=os.listdir(data_dir) for filename in filenames: extension = os.path.splitext(filename)[1][1:].strip() if extension=='bin': json_temp={"name":filename} json_state['names'].append(json_temp) with open(json_path,"w") as outfile : json.dump(json_state,outfile) print(json_state) print('train end') return 'true'
def __init__(self): self.there_is_a_winner = False self.g = ludopy.Game() self.player = None self.Q = [] self.ca = capture_image() self.list_winner = [] self.number_winner_my_player = 0 self.tr = train_data() self.player_last_piece = [] self.second_player = 0 self.file_name = "" self.file_plyer_hist = "" self.type_play = True self.winner = 0 self.my_player_winner = False self.gamma_m = 0 self.alfa_m = 0 self.percentage = [] self.epsilon = 0
def summary(): print("summary") train_data() test_data() ans_data() print("train2emb模型运行完成")
from train import train from predict import predict_data from train import train_data import numpy as np import pandas as pd #from lightgbm import LGBMClassifier #est_bin是做了每个特征dbscan分箱 #train_x,train_y,est_kbin = train_data() train_x, train_y = train_data() train_x.drop( [ 'lat_var_skew', 'lon_var_skew', 'velocity_var_skew', 'velocity_var_covar', 'angle_var_mean', 'computed_angle_var_mean', 'computed_angle_var_skew', 'computed_angle_var_covar', #'angle_var_velocity_cov' ], axis=1, inplace=True) #构建测试集数据 #test_x,test_id = predict_data(est_kbin) test_x, test_id = predict_data() test_x.drop( [ 'lat_var_skew', 'lon_var_skew',
#!/usr/bin/env python3 -W ignore::DeprecationWarning import sys import warnings from fetch import fetch_data from train import train_data # suppress all warnings warnings.filterwarnings("ignore") if __name__ == "__main__": fetch_obj = fetch_data(data_type=0) test_obj = fetch_data(data_type=1) train_obj = train_data(fetch_obj.label_df, fetch_obj.pseudo_df, test_obj.unlabel_df) # apply a tf-idf model with SVD combine_data = [*train_obj.labeled_data, *train_obj.pseudo_data] train_obj.fit_vectorizer(combine_data, min_df=0.010, max_df=0.8, ngram_range=(1, 2), svd=True) # using lda train_obj.train_model() # test data train_obj.fit_vectorizer(train_obj.test_data, min_df=0.010, max_df=0.8, ngram_range=(1, 2), svd=True,
def train(): train_data() return render_template('index.html')
def train(): train_data(log_writer) return render_template('index.html')
def train(): train_data(log_writer) return render_template('results.html')
def capture(): t = train_data() t.record()
line = ' '.join(string_formatter) fp.write(line) fp.write(linesep) fp.close() if mode == "train": if len(argv) != 5: print( "USAGE: python topics.py mode dataset-directory model-file [fraction]" ) exit(1) fraction = float(argv[4]) print("Training started.") print("Please wait as it could take a while to create model...") model = train.train_data(dataset_dir, fraction) write_top_words_to_file(model, "distinctive_words.txt") print("Top 10 words at each topic is written into distinctive_words.txt.") serialize_model(model, model_file) print("Model File created") exit(0) if mode == "test": model = deserialize_model(model_file) print("Model loaded successfully.") result = test.test_data(model, dataset_dir) print(result) exit(0) print("Operation not supported") exit(1)