コード例 #1
0
 def predict_and_save_csv(self,test_features,test_ids, avg_score, final_score = None):
     title = get_filename(self.model_args['model'])
     print(f'Saving predictions to {title}.csv...\n')
     y_preds = self.model.predict(test_features)
     y_ids = pd.DataFrame(test_ids, columns=['ID'])
     y_preds_df = pd.DataFrame(y_preds, columns=['target'])
     predictions = y_ids.join(y_preds_df)
     predictions.to_csv(f'{self.config_args["output"]}/{title}.csv', index = False)
     self.log_experiment(self.model_args['model'], title, avg_score, final_score)
コード例 #2
0
 def predict_and_save_csv(self, test_features):
     print('Training Decision Tree Model...\n')
     self.train_model()
     print('Saving predictions to csv...\n')
     title = get_filename('decision_tree')
     output_directory = Config().get_config()['output_directory']
     y_preds = self.model.predict(test_features)
     y_ids = pd.DataFrame(self.test_ids, columns=['ID'])
     y_preds_df = pd.DataFrame(y_preds, columns=['Label_Id'])
     predictions = y_ids.join(y_preds_df)
     predictions = self.label_encoder.decode(predictions)
     predictions.to_csv(f'{output_directory}/{title}.csv', index=False)
コード例 #3
0
 def predict_and_save_csv(self, test_features, skip_pipeline=False):
     print('Training XGBoost Classifier...\n')
     self.train_model(skip_pipeline)
     title = get_filename('xgboost')
     print(f'Saving predictions to csv {title}...\n')
     output_directory = Config().get_config()['output_directory']
     y_preds = self.model.predict(test_features)
     y_ids = pd.DataFrame(self.test_ids, columns=['ID'])
     y_preds_df = pd.DataFrame(y_preds, columns=['Label_Id'])
     predictions = y_ids.join(y_preds_df)
     predictions = self.label_encoder.decode(predictions)
     predictions.to_csv(f'{output_directory}/{title}.csv', index=False)
コード例 #4
0
 def predict_and_save_csv(self, test_features, model_type='Gaussian'):
     print('Training NaiveBayesian model...\n')
     self.train_model(model_type)
     print('Saving predictions to csv...\n')
     title = get_filename('naive_bayesian_multinom')
     output_directory = Config().get_config()['output_directory']
     y_preds = None
     if model_type == 'Gaussian':
         y_preds = self.model.predict(self.test_features.toarray())
     else:
         y_preds = self.model.predict(test_features)
     y_ids = pd.DataFrame(self.test_ids, columns=['ID'])
     y_preds_df = pd.DataFrame(y_preds, columns=['Label_Id'])
     predictions = y_ids.join(y_preds_df)
     predictions = self.label_encoder.decode(predictions)
     predictions.to_csv(f'{output_directory}/{title}.csv', index=False)
コード例 #5
0
    def tileset_dialog(self, path_input: TextInput, name_input: Optional[TextInput] = None):
        if not has_tk:
            return
        value = path_input.get_value()
        initialfile = value or None
        filepath = askopenfilename(
            initialfile = initialfile,
            filetypes = [
                (
                    "Arquivos de Imagem",
                    (".png", ".jpg", ".bmp", ".tiff", ".webp")
                )
            ]
        )

        if filepath:
            path_input.set_value(filepath)
            if name_input and not name_input.get_value():
                name = utils.get_filename(filepath)
                name_input.set_value(name)