Reference
snoscience.metrics
This module contains functions to calculate network performance.
calculate_accuracy
Calculate the accuracy percentage from the given matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calc
|
ndarray
|
Array containing all the calculated or predicted values. |
required |
true
|
ndarray
|
Array containing all the true or expected values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
accuracy |
float
|
Accuracy percentage. |
calculate_mse
Calculate the mean squared error per output vector from the given matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calc
|
ndarray
|
Array containing all the calculated or predicted values. |
required |
true
|
ndarray
|
Array containing all the true or expected values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Mean squared error per output. |
snoscience.networks
This module contains the implementations of the neural network interfaces.
SimpleNeuralNetwork
Bases: NeuralNetwork
Single-process sequential feed-forward neural network.
__init__
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loss
|
str
|
Loss function to use when training the network. |
'mse'
|
optimiser
|
str
|
Optimiser to use when training the network. |
'sgd'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Loss function is not supported. |
ValueError
|
Optimiser is not supported. |
predict
Let the neural network predict the outputs from the given inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Inputs for the network. |
required |
classify
|
bool
|
Create classification from output layer, otherwise keep regression. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Predictions from the network. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Size of the input array does not match with the network inputs. |
ValueError
|
No layers are present in the network. |
ValueError
|
Network is not trained. |
train
Train the neural network with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Input samples to train the network with. |
required |
y
|
ndarray
|
Output samples to train the network with. |
required |
epochs
|
int
|
Number of training iterations. |
required |
samples
|
int
|
Number of samples taken from the dataset per iteration. |
required |
kwargs
|
Optimiser hyperparameters as keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Number of samples in the input array do not match with the output array. |
ValueError
|
No layers are present in the network. |
ValueError
|
Outputs per sample do not match with the number of neurons in the output layer. |
ValueError
|
Number of samples per epoch is larger than the dataset. |
KeyError
|
Hyperparameters required for optimiser are not given as kwargs. |