imputer_text.fit(train_df=df_train, learning_rate=1e-4, num_epochs=50, final_fc_hidden_units=[512]) #Fit a Model With HPO imputer_text = SimpleImputer( input_columns=['title', 'text'], output_column='finish', output_path='imputer_model', ) imputer_text.fit_hpo(train_df=df_train, num_epochs=50, learning_rate_candidates=[1e-3, 1e-4], final_fc_hidden_units_candidates=[[100]], num_hash_bucket_candidates=[2**10, 2**15], tokens_candidates=['chars', 'words']) #------------------------------------------------------------------------------------ ''' Numerical Data ''' #Generate synthetic numerical data numeric_data = np.random.uniform(-np.pi, np.pi, (n_samples, )) df = pd.DataFrame({ 'x': numeric_data, '*2': numeric_data * 2. + np.random.normal(0, .1, (n_samples, )), '**2':
# Print overall classification report print( classification_report(predictions['finish'], predictions['finish_imputed'])) # ------------------------------------------------------------------------------------ """ 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')
tokens='chars') imputer_text.fit(train_df=df_train, learning_rate=1e-4, num_epochs=5, final_fc_hidden_units=[512]) # Fit a Model With HPO imputer_text = SimpleImputer( input_columns=['title', 'text'], output_column='finish', output_path='imputer_model', ) imputer_text.fit_hpo(train_df=df_train, num_epochs=5, num_hash_bucket_candidates=[2**10, 2**15], tokens_candidates=['chars', 'words']) # ------------------------------------------------------------------------------------ """ Numerical Data """ # Generate synthetic numerical data n_samples = 100 numeric_data = np.random.uniform(-np.pi, np.pi, (n_samples, )) df = pd.DataFrame({ 'x': numeric_data, '*2': numeric_data * 2. + np.random.normal(0, .1, (n_samples, )) })