Esempio n. 1
0
def binary_model_train_test():
    cfg = config_parser.CfgParser(os.path.join(CFG_FILE_PATH, 'binary_config.ini'))
    metric_list, model_label_list = cfg.parse_metrics_models()
    meta_model_label = cfg.parse_meta_models()
    automl = automl_base.AutoML(model_save_path=os.path.join(MODEL_FILE_PATH, 'titanic_models/'))
    
    X_train, X_val, Y_train, Y_val, X_test = binary_model_data_prepare()
    model = automl.train(X_train, Y_train, metric_list, model_label_list, meta_model_label[0], 'titanic_model.pkl', K=3)
Esempio n. 2
0
def binary_model_predict_test():
    cfg = config_parser.CfgParser(os.path.join(CFG_FILE_PATH, 'binary_config.ini'))
    metric_list, model_label_list = cfg.parse_metrics_models()
   
    automl = automl_base.AutoML(model_save_path=os.path.join(MODEL_FILE_PATH, 'titanic_models/'))
    model = automl.load_model(os.path.join(MODEL_FILE_PATH, 'titanic_models/titanic_model.pkl'))
    
    X_train, X_val, Y_train, Y_val, X_test = binary_model_data_prepare()
    val_y = automl.validate(model, X_val, Y_val, metric_list)
    pred_y = automl.predict(model, X_test)
Esempio n. 3
0
def multi_model_predict_test():
    iris = datasets.load_iris()
    X_train, X_test, Y_train, Y_test = train_test_split(iris.data[:, 1:3], iris.target, test_size=0.3, random_state=42)
    
    automl = automl_base.AutoML(model_save_path=os.path.join(MODEL_FILE_PATH, 'iris_models/'))
    cfg = config_parser.CfgParser(os.path.join(CFG_FILE_PATH, 'multi_config.ini'))
    metric_list = cfg.parse_metrics()
    
    model = automl.load_model(os.path.join(MODEL_FILE_PATH, 'iris_models/iris_model.pkl'))
    val_y = automl.validate(model, X_test, Y_test, metric_list)
    pred_y = automl.predict(model, X_test)
Esempio n. 4
0
def multi_model_train_test():
    iris = datasets.load_iris()
    X_train, X_test, Y_train, Y_test = train_test_split(iris.data[:, 1:3], iris.target, test_size=0.3, random_state=42)
    
    cfg = config_parser.CfgParser(os.path.join(CFG_FILE_PATH, 'multi_config.ini'))

    metric_list, model_label_list = cfg.parse_metrics_models()
    meta_model_label = cfg.parse_meta_models()
   
    automl = automl_base.AutoML(model_save_path=os.path.join(MODEL_FILE_PATH, 'iris_models/'))
    model = automl.train(X_train, Y_train, metric_list, model_label_list, meta_model_label[0], model_save_name='iris_model.pkl', K=3)
Esempio n. 5
0
metric_list, model_label_list = cfg.parse_metrics_models()
meta_model_label = cfg.parse_meta_models()

print(metric_list)
print(model_label_list)
print(meta_model_label)

test_df = test_df_raw.copy()
tx = preprocess_data(test_df)
tx = pd.DataFrame(sc.fit_transform(tx.values),
                  index=tx.index,
                  columns=tx.columns)
print(tx)

model_h = model_helper.ModelHelper()
automl = automl_base.AutoML(model_h)
model = automl.train(X_train,
                     Y_train,
                     metric_list,
                     model_label_list,
                     meta_model_label[0],
                     K=3)

pred_y = automl.predict(model, tx)
print(pred_y)

submission = pd.DataFrame({
    "PassengerId": test_df["PassengerId"],
    "Survived": pred_y
})
submission.to_csv('../data/submission_new.csv', index=False)