Learning

Here is a list of classes in the package.

Overview:

class neural_network.Plotter[source]

Class to create plots evaluating the performance of the neural network.

static comparison_scatter(df: DataFrame, phase: str = 'training', title: str = '')[source]

Creates a scatter plot comparing the true and predicted values from the network.

Parameters:
  • df (pd.DataFrame) – The data

  • phase (str) – The phase of learning (training/validation/testing)

  • title (str) – The title

static datapoint_scatter(df: DataFrame, phase: str = 'training', title: str = '', regression: bool = False)[source]

Creates a scatter plot of the predicted/true classes for a given set of data.

Parameters:
  • df (pd.DataFrame) – The data

  • phase (str) – The phase of learning (training/validation/testing) or true for just the true data

  • title (str) – The title

  • regression (bool) – Whether this is for regressional data or classificational data

static plot_loss(df: DataFrame, title: str = '')[source]

Plots (normally) the training and validation losses over time.

Parameters df : pd.DataFrame

The data

strtitle [Optional, Default=’’]

A title for the plot

class neural_network.Tester(network: Network, data: DataFrame, batch_size: int, weighted: bool = False)[source]

Class to test a neural network.

__init__(network: Network, data: DataFrame, batch_size: int, weighted: bool = False)[source]

Constructor method

Parameters:
  • network (Network) – The neural network

  • data (pd.DataFrame) – All the testing data for the Network

  • batch_size (int) – The number of datapoints used in each epoch

  • weighted (bool) – If True then we use the WeightedPartitioner, otherwise we use the standard Partitioner

comparison_scatter(title: str = '')[source]

Creates scatter plot comparing predicted to actual values (for regressional problems only).

Parameters:

title (str) – An optional title to append to the plot

generate_confusion()[source]

Creates a confusion matrix from the results.

generate_scatter(title: str = '')[source]

Creates scatter plot from the data and their predicted values.

Parameters:

title (str) – An optional title to append to the plot

run()[source]

Performs testing of the network.

class neural_network.Trainer(network: Network, data: DataFrame, num_epochs: int, batch_size: int, validator: Validator | None = None, weighted: bool = False)[source]

Class to train a neural network

__init__(network: Network, data: DataFrame, num_epochs: int, batch_size: int, validator: Validator | None = None, weighted: bool = False)[source]

Constructor method

Parameters:
  • network (Network) – The neural network to train

  • data (pd.DataFrame) – All the training data for the Network

  • num_epochs (int) – The number of epochs we are training for

  • batch_size (int) – The number of datapoints used in each epoch

  • validator (Validator) – The validator used (if any)

  • weighted (bool) – If True then we use the WeightedPartitioner, otherwise we use the standard Partitioner

back_propagate_one_batch()[source]

Performs back propagation for one batch of datapoints (stored within the memory of the edges).

comparison_scatter(title: str = '')[source]

Creates scatter plot comparing predicted to actual values (for regressional problems only).

Parameters:

title (str) – An optional title to append to the plot

generate_loss_plot(title: str = '')[source]

Creates a plot of the training and validation loss over time.

Parameters:

title (str) – An optional title to append to the plot

generate_scatter(title: str = '')[source]

Creates scatter plot from the data and their predicted values.

Parameters:

title (str) – An optional title to append to the plot

run()[source]

Performs training of the network

store_gradients(_id: int)[source]

Stores the gradients of the loss functions after a forward pass

Parameters:

_id (int) – The id of the datapoint

class neural_network.Validator(network: Network, data: DataFrame, batch_size: int, weighted: bool = False)[source]

Class to validate a neural network

__init__(network: Network, data: DataFrame, batch_size: int, weighted: bool = False)[source]

Constructor method

Parameters:
  • network (Network) – The neural network

  • data (pd.DataFrame) – All the validation data for the Network

  • batch_size (int) – The number of datapoints used in each epoch

  • weighted (bool) – If True then we use the WeightedPartitioner, otherwise we use the standard Partitioner

comparison_scatter(title: str = '')[source]

Creates scatter plot comparing predicted to actual values (for regressional problems only).

Parameters:

title (str) – An optional title to append to the plot

generate_scatter(title: str = '')[source]

Creates scatter plot from the data and their predicted values

Parameters:

title (str) – An optional title to append to the plot

validate(factor: int) float[source]

Performs validation of the network.

Parameters:

factor (int) – The epochs on which we need to print out the validation

Returns:

The validation loss

Return type:

float