Exemplo n.º 1
0
    def run(self):
        custom_out('Predict Node initiated')
        model_str = model_in(sys.argv[4])
        if model_str == 'xgbtolr':
            #pass off functional call to helper files
            #predictions = xgb_lr()
            pass
        elif not (model_str in function_mappings().keys()):
            custom_out('Model input is not in available models')
        else:
            prices_model = pd.read_pickle(Train().output().path)
            test_df = pd.read_csv(TestDataPreProcessing().output().path)
            test_x = test_postprocess(model_str, test_df)
            predictions = prices_model.predict(test_x)

            model_str2 = model_in(sys.argv[5])
            if not (model_str2 in function_mappings().keys()):
                custom_out('No (or invalid) 2nd model choice')
            else:
                second_model = pd.read_pickle(WeightedModel().output().path)
                test_x2 = test_postprocess(model_str2, test_df)
                predictions2 = second_model.predict(test_x2)
                predictions = stacked_model_compute(predictions, predictions2)

        submission = prediction_to_submission(test_df, predictions, model_str)
        submission.to_csv(self.output().path, index=False)

        custom_out('Write of submission to csv successful')
Exemplo n.º 2
0
    def run(self):
        custom_out('Train Node initiated')

        train_df = pd.read_csv(self.input().path)

        model_str = model_in(sys.argv[4])
        custom_out('Model chosen: {}'.format(model_str))
        train_df = preprocess_data(train_df, model_str, 'train')
        prices_model = model_choice(model_str, train_df)

        custom_out('Successfully trained model')
        with open(self.output().path, 'wb') as f:
            pickle.dump(prices_model, f)
        custom_out('Successfully wrote model to pickle')
Exemplo n.º 3
0
    def run(self):
        model_str = model_in(sys.argv[5])
        if model_str in function_mappings():
            custom_out('Stacked Model Node initiated')

            train_df = pd.read_csv(self.input().path)

            custom_out('2nd Model chosen: {}'.format(model_str))
            train_df = preprocess_data(train_df, model_str, 'train')
            prices_model = model_choice(model_str, train_df)

            custom_out('Successfully trained model')
            with open(self.output().path, 'wb') as f:
                pickle.dump(prices_model, f)
            custom_out('Successfully wrote model to pickle')

        else:
            with open(self.output().path, 'wb') as f:
                pickle.dump('none', f)
Exemplo n.º 4
0
 def run(self):
     model_str = model_in(sys.argv[4])
     print '\n\ndebug successful\n\n'