Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 2.59 KB

CodeDocumentation.md

File metadata and controls

43 lines (38 loc) · 2.59 KB

File location:

  • ml_code_generator/application/code_generator.py

Class:

  • CodeGenerator

Function:

  • one_hot_encode_data

Input Parameters:

  • self

Description:

  • First it gets the previously saved x_values and y_values. Then it determines if the x data, the y data or both should be one hot encoded. It uses the is_categorical function in ml_code_generator/pandas_code/is_categorical.py to determine if categorical data is present in either the x or y data. If categorical data is present in the x data, it gets the code from one_hot_encode_x_data.py in ml_code_generator/pandas_code and saves the new one hot encoded data in place of the previous x data. If categorical data is present in the y data, it gets the code from one_hot_encode_y_data.py in ml_code_generator/pandas_code and saves the new one hot encoded data in place of the previous y data.

File location:

  • ml_code_generator/pandas_code/is_categorical.py

Function:

  • is_categorical

Input Parameters:

  • x_data
  • y_data

Returns:

  • (x_is_cat, y_is_cat) - A tuple of two boolean values. If the data contains any categorical values it will return true in the first spot for x data and the second spot for y data. If the data does not contain any categorical values, it returns false for the respective spots instead.

Description:

  • Checks the x data and the y data to see if there are any columns that are not numeric and if there are any, it returns false in the appropriate spot.

File location:

  • ml_code_generator/pandas_code/parse_template.py

Function:

  • parse_template

Input Parameters:

  • template_name
  • args

Description:

  • Function is responsible for formatting the code that is returned by the functions in the ml_code_generator/pandas_code/code_templates folder. This includes adding proper indenting, excluding the function name, and excluding any return statement in the function. Anything explicitly mentioned here can be removed from the code that is generated by every file in the ml_code_generator/pandas_code/code_templates folder.

File location:

  • ml_code_generator/main.py

Function:

  • run_generator

Input Parameters:

  • args - this comes from the command line and should be the data to be used when generating the code

Description:

  • This function is the only function called by main and is used for testing the backend seperate from the front end. It calls the functions in ml_code_generator/application/code_generator.py directly to generate the same code that needs to be generated by the front end. It is also faster than clicking through all of the front end options.