Data Generators

Here is a list of classes in the package.

Overview:

class neural_network.AbstractDataGenerator(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int)[source]

Class to randomly generate datapoints and categorise them according to a given rule or provide an output value if we are regressing.

__call__() DataFrame[source]

Writes to self._df with the generated data and classes.

Returns:

self._df with newly generated data

Return type:

pd.DataFrame

__init__(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int)[source]

Constructor method

Parameters:
  • function (custom_type) – A rule which takes a certain number of coordinates and returns a value representing the class or function output of the datapoint

  • num_datapoints (int) – The number of datapoints to be generated

_generate_data()[source]

To generate the data - cannot be called from AbstractDataGenerator

plot_datapoints(title: str = '', regression: bool = False)[source]

Uses the Plotter class to generate a scatter plot of the datapoints with their true classes/values represented.

titlestr [Optional, Default=’’]

The optional title of the .png file

regressionbool

Whether this is a regression or classification problem

write_to_csv(title: str, directory: str = '')[source]

Writes the generated data to a .csv file.

Parameters:
  • title (str) – The title for the .csv file

  • directory (str (Optional, Default = '')) – The directory for the file

class neural_network.NormalDataGenerator(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int, means: List[float], std_devs: List[float])[source]

Class to randomly generate datapoints and categorise them according to a given rule, or provide an output value if we are regressing, with data being generated via a normal distribution.

__init__(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int, means: List[float], std_devs: List[float])[source]

Constructor method

Parameters:
  • function (custom_type) – A rule which takes a certain number of coordinates and returns a value representing the class or function value of the datapoint

  • num_datapoints (int) – The number of datapoints to be generated

  • means (List[float]) – A list of means for each coordinate

  • std_devs (List[float]) – A list of standard deviations for each coordinate

_generate_data()[source]

To generate normally distributed data

class neural_network.UniformDataGenerator(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int, lower_bounds: List[float], upper_bounds: List[float])[source]

Class to randomly generate datapoints and categorise them according to a given rule, or provide an output value if we are regressing, with data being generated via a uniform distribution.

__init__(function: Callable[[float], Any] | Callable[[float, float], Any] | Callable[[float, float, float], Any] | Callable[[float, float, float, float], Any], num_datapoints: int, lower_bounds: List[float], upper_bounds: List[float])[source]

Constructor method

Parameters:
  • function (custom_type) – A rule which takes a certain number of coordinates and returns a value representing the class or function output of the datapoint

  • num_datapoints (int) – The number of datapoints to be generated

  • lower_bounds (List[float]) – A list of lower bounds for each coordinate

  • upper_bounds (List[float]) – A list of upper bounds for each coordinate

_generate_data()[source]

To generate uniformly distributed data