Esempio n. 1
0
 def get_imputer(cls):
     """Get the model object for this instance, loading it if it's not already loaded."""
     if cls.imputer is None:
         imputer = SimpleImputer.load(model_path)
         print(imputer.input_columns)
         imputer.load_hpo_model()
         print(imputer.input_columns)
         imputer.imputer.batch_size = 1
         cls.imputer = imputer
     return cls.imputer
Esempio n. 2
0
Run SimpleImputer with hyperparameter optimization
"""
# Initialize a SimpleImputer model
imputer = SimpleImputer(input_columns=['title', 'text'],
                        output_column='finish',
                        output_path='imputer_model')

# Fit an imputer model with default list of hyperparameters
imputer.fit_hpo(train_df=df_train)

# Fit an imputer model with customized HPO
imputer.fit_hpo(train_df=df_train,
                num_epochs=5,
                patience=3,
                learning_rate_candidates=[1e-3, 1e-4],
                num_hash_bucket_candidates=[2**15],
                tokens_candidates=['words', 'chars'])

# ------------------------------------------------------------------------------------
"""
Load saved model and get metrics from SimpleImputer
"""
# Load saved model
imputer = SimpleImputer.load('./imputer_model')

# Load a dictionary of metrics from the validation set
metrics = imputer.load_metrics()
weighted_f1 = metrics['weighted_f1']
avg_precision = metrics['avg_precision']
# ... explore other metrics stored in this dictionary!
Esempio n. 3
0
 def get_imputer(cls):
     """Get the model object for this instance, loading it if it's not already loaded."""
     if cls.imputer == None:
         cls.imputer = SimpleImputer.load(model_path)
     return cls.imputer