Automater.Automater¶
-
class
Automater.
Automater
(data_type_dict={}, output_var=None, datatype_handlers={})¶ An Automater object, allows users to rapidly build and iterate on deep learning models.
This class supports building and iterating on deep learning models by providing:
- A cleaned, transformed and correctly formatted X and y (good for keras, sklearn or any other ML platform)
- An input_nub, without the hassle of worrying about input shapes or data types
- An nub, correctly formatted for the kind of response variable provided
-
__init__
(data_type_dict={}, output_var=None, datatype_handlers={})¶ Parameters: - data_type_dict ({str:[str]}) – A dictionary, in the format {‘datatype’: [‘variable_name_1’, ‘variable_name_2’]}
- output_var (str) – The name of the response variable
- datatype_handlers ({str:class}) – Any custom or external datatype handlers, in the format {‘datatype’: DataTypeClass}
Methods
__init__
([data_type_dict, output_var, …])param data_type_dict: A dictionary, in the format {‘datatype’: [‘variable_name_1’, ‘variable_name_2’]} fit
(observations)- Fit input mapper
fit_transform
(observations)Perform a fit, and then a transform. inverse_transform_output
(y)Transform the output_var to be in the same basis (scale / domain) as it was in the original data set. suggest_loss
()Suggest a loss function, based on: transform
(observations[, df_out])- Transform the keras input columns
-
_check_fitted
()¶
-
_check_has_response_var
()¶
-
_check_input_df
(input_dataframe)¶
-
_create_input_nub
(transformed_observations)¶ Generate a nub, appropriate for feeding all input variables into a Keras model. Each input variable has one input layer and one input nub, with:
- One Input (required)
- Possible additional layers (optional, such as embedding layers for text)
All input nubs are then joined with a Concatenate layer :param transformed_observations: A pandas dataframe, containing all keras input variables after their transformation pipelines :type transformed_observations: pandas.DataFrame :return: A Keras layer, which can be fed into future layers :rtype: ([keras,Input], Layer)
-
_create_mapper
(variable_list)¶
-
_create_output_nub
(output_observations_transformed)¶
-
_valid_configurations_check
()¶
-
fit
(observations)¶ - Fit input mapper
- Create input layer and nub
- Create output mapper (if supervised)
- Create output nub (if supervised)
- Set self.fitted to True
Parameters: observations (pandas.DataFrame) – A pandas DataFrame, containing the relevant variables Returns: self, now in a fitted state. The Automater now has initialized input layers, output layer(s) (if response variable is present), and can be used for the transform step Return type: Automater
-
fit_transform
(observations)¶ Perform a fit, and then a transform. See transform for return documentation
-
inverse_transform_output
(y)¶ Transform the output_var to be in the same basis (scale / domain) as it was in the original data set. This is convenient for comparing predictions to actual data, and computing metrics relative to actual data and other models :param y: The output of a Keras model’s .predict function :type y: numpy.ndarray :return: Data, which can be compared to the original data set :rtype numpy.ndarray
-
suggest_loss
()¶ Suggest a loss function, based on:
- Output variable datatype
- Observations of output_var
Returns: A Keras supported loss function
-
transform
(observations, df_out=False)¶ - Transform the keras input columns
- Transform the output_var, if supervised and the output_var is present
- Format the data, consistent w/ df_out
Parameters: - observations (pandas.DataFrame) – A pandas dataframe, containing all keras input layers
- df_out – Whether to return a Pandas DataFrame. Returns DataFrame if True, keras-compatable object if
false :type df_out: bool :return: Either a pandas dataframe (if df_out = True), or a numpy object (if df_out = False). This object
will contain: the transformed input variables, and the transformed output variables (if the output variable is present in input_dataframe