Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.label_encoders[key] = encoder.deserialize(label_encoder)
for key, label_encoder_state in state['label_encoders_state'].items():
self.label_encoders[key].set_state(label_encoder_state)
self.column_names = state['column_names']
self.column_types = state['column_types']
self.num_columns = state['num_columns']
self.shape = state['shape']
self.num_rows = state['num_rows']
self.categorical_col = state['categorical_col']
self.numerical_col = state['numerical_col']
self.value_counters = utils.to_type_key(state['value_counters'], int)
self.categorical_categorical = utils.to_type_key(
state['categorical_categorical'], ast.literal_eval)
self.numerical_categorical = utils.to_type_key(
state['numerical_categorical'], ast.literal_eval)
self.count_frequency = utils.to_type_key(state['count_frequency'], int)
self.high_level1_col = state['high_level1_col']
self.high_level2_col = state['high_level2_col']
self.high_level_cat_cat = utils.to_type_key(
state['high_level_cat_cat'], ast.literal_eval)
self.high_level_num_cat = utils.to_type_key(
state['high_level_num_cat'], ast.literal_eval)
self.num_columns = state['num_columns']
self.shape = state['shape']
self.num_rows = state['num_rows']
self.categorical_col = state['categorical_col']
self.numerical_col = state['numerical_col']
self.value_counters = utils.to_type_key(state['value_counters'], int)
self.categorical_categorical = utils.to_type_key(
state['categorical_categorical'], ast.literal_eval)
self.numerical_categorical = utils.to_type_key(
state['numerical_categorical'], ast.literal_eval)
self.count_frequency = utils.to_type_key(state['count_frequency'], int)
self.high_level1_col = state['high_level1_col']
self.high_level2_col = state['high_level2_col']
self.high_level_cat_cat = utils.to_type_key(
state['high_level_cat_cat'], ast.literal_eval)
self.high_level_num_cat = utils.to_type_key(
state['high_level_num_cat'], ast.literal_eval)
def set_state(self, state):
super().set_state(state)
for key, label_encoder in state['label_encoders'].items():
self.label_encoders[key] = encoder.deserialize(label_encoder)
for key, label_encoder_state in state['label_encoders_state'].items():
self.label_encoders[key].set_state(label_encoder_state)
self.column_names = state['column_names']
self.column_types = state['column_types']
self.num_columns = state['num_columns']
self.shape = state['shape']
self.num_rows = state['num_rows']
self.categorical_col = state['categorical_col']
self.numerical_col = state['numerical_col']
self.value_counters = utils.to_type_key(state['value_counters'], int)
self.categorical_categorical = utils.to_type_key(
state['categorical_categorical'], ast.literal_eval)
self.numerical_categorical = utils.to_type_key(
state['numerical_categorical'], ast.literal_eval)
self.count_frequency = utils.to_type_key(state['count_frequency'], int)
self.high_level1_col = state['high_level1_col']
self.high_level2_col = state['high_level2_col']
self.high_level_cat_cat = utils.to_type_key(
state['high_level_cat_cat'], ast.literal_eval)
self.high_level_num_cat = utils.to_type_key(
state['high_level_num_cat'], ast.literal_eval)
def get_state(self):
state = super().get_state()
label_encoders = {
key: encoder.serialize(label_encoder)
for key, label_encoder in self.label_encoders.items()}
label_encoders_state = {
key: label_encoder.get_state()
for key, label_encoder in self.label_encoders.items()}
state.update({
'shape': self.shape,
'num_rows': self.num_rows,
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state
super().set_state(state)
for key, label_encoder in state['label_encoders'].items():
self.label_encoders[key] = encoder.deserialize(label_encoder)
for key, label_encoder_state in state['label_encoders_state'].items():
self.label_encoders[key].set_state(label_encoder_state)
self.column_names = state['column_names']
self.column_types = state['column_types']
self.num_columns = state['num_columns']
self.shape = state['shape']
self.num_rows = state['num_rows']
self.categorical_col = state['categorical_col']
self.numerical_col = state['numerical_col']
self.value_counters = utils.to_type_key(state['value_counters'], int)
self.categorical_categorical = utils.to_type_key(
state['categorical_categorical'], ast.literal_eval)
self.numerical_categorical = utils.to_type_key(
state['numerical_categorical'], ast.literal_eval)
self.count_frequency = utils.to_type_key(state['count_frequency'], int)
self.high_level1_col = state['high_level1_col']
self.high_level2_col = state['high_level2_col']
self.high_level_cat_cat = utils.to_type_key(
state['high_level_cat_cat'], ast.literal_eval)
self.high_level_num_cat = utils.to_type_key(
state['high_level_num_cat'], ast.literal_eval)
label_encoders_state = {
key: label_encoder.get_state()
for key, label_encoder in self.label_encoders.items()}
state.update({
'shape': self.shape,
'num_rows': self.num_rows,
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state
def get_state(self):
state = super().get_state()
label_encoders = {
key: encoder.serialize(label_encoder)
for key, label_encoder in self.label_encoders.items()}
label_encoders_state = {
key: label_encoder.get_state()
for key, label_encoder in self.label_encoders.items()}
state.update({
'shape': self.shape,
'num_rows': self.num_rows,
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state
state.update({
'shape': self.shape,
'num_rows': self.num_rows,
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state
def get_state(self):
state = super().get_state()
label_encoders = {
key: encoder.serialize(label_encoder)
for key, label_encoder in self.label_encoders.items()}
label_encoders_state = {
key: label_encoder.get_state()
for key, label_encoder in self.label_encoders.items()}
state.update({
'shape': self.shape,
'num_rows': self.num_rows,
'categorical_col': self.categorical_col,
'numerical_col': self.numerical_col,
'label_encoders': utils.to_type_key(label_encoders, str),
'label_encoders_state': utils.to_type_key(label_encoders_state, str),
'value_counters': utils.to_type_key(self.value_counters, str),
'categorical_categorical': utils.to_type_key(
self.categorical_categorical, str),
'numerical_categorical': utils.to_type_key(
self.numerical_categorical, str),
'count_frequency': utils.to_type_key(self.count_frequency, str),
'high_level1_col': self.high_level1_col,
'high_level2_col': self.high_level2_col,
'high_level_cat_cat': utils.to_type_key(self.high_level_cat_cat, str),
'high_level_num_cat': utils.to_type_key(self.high_level_num_cat, str),
'column_names': self.column_names,
'column_types': utils.to_type_key(self.column_types, str),
'num_columns': self.num_columns,
})
return state