Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix _pickle_method for predictor #396

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ old_data/*
t2.py
venv/*
xgboost/*
.idea/
2 changes: 1 addition & 1 deletion auto_ml/DataFrameVectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def transform_categorical_col(self, col_vals, col_name):
encoded_col_names = []

for trained_feature, col_idx in self.vocabulary_.items():
if trained_feature[:len_col_name] == col_name:
if trained_feature[:len_col_name] == col_name and '=' in trained_feature:
encoded_col_names.append([trained_feature, col_idx])
num_trained_cols += 1
if min_transformed_idx is None:
Expand Down
22 changes: 11 additions & 11 deletions auto_ml/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@
from evolutionary_search import EvolutionaryAlgorithmSearchCV

# For handling parallelism edge cases
def _pickle_method(m):
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
else:
return getattr, (m.im_self, m.im_func.func_name)

try:
import copy_reg
if sys.version_info[0] < 3:
import copy_reg as copy_reg


def _pickle_method(m):
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
else:
return getattr, (m.im_self, m.im_func.func_name)


copy_reg.pickle(types.MethodType, _pickle_method)
except:
import copyreg
copyreg.pickle(types.MethodType, _pickle_method)


class Predictor(object):
Expand Down
2 changes: 1 addition & 1 deletion auto_ml/utils_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def insert_deep_learning_model(pipeline_step, file_name):
# Load the Keras model here
keras_file_name = file_name[:-5] + random_name + '_keras_deep_learning_model.h5'

model = keras_load_model(keras_file_name)
model = load_keras_model(keras_file_name)

# Put the model back in place so that we can still use it to get predictions without having to load it back in from disk
return model
Expand Down