Regressify is a multi-task neural network coded from scratch that performs simultaneous regression and classification.
The neural network has been trained on a dummy dataset of 2 features F1 and F2, and 2 target variables T1 and T2, corresponding to a class label and a regression value respectively. Here is a sample subset of the same:
F1 | F2 | T1 (class label) | T2 (regression value) |
---|---|---|---|
1.4 | 0.2 | 1 | 0.28 |
1.6 | 0.2 | 1 | 0.32 |
4 | 1.2 | 2 | 4.8 |
3.3 | 1 | 2 | 3.3 |
... | ... | ... | ... |
- There are 150 samples in the dataset
- Each sample belongs to one of 2 classes where the class ID is either 1 or 2
Consists of two neurons, each corresponding to one of the two feature variables, F1 and F2.
Hidden Layers
- Controlled by the
num_layers
hyperparameter. Note:num_layers
includes the last (output) layer. Thus, the number of hidden layers isnum_layers - 1
- Each hidden layer can have either a
sigmoid
or atanh
activation function applied to it. Hyperparameter:layer_activation_fns
num_neurons
controls the number of neurons in each layer
- Has two neurons, one for a classification prediction, and the other for a regression value
- The matrix output by the penultimate layer undergoes:
- a
sigmoid
function to obtain the respective probabilities of each sample belonging to one of the two classes - a
linear
function to obtain regression values corresponding to each sample
- a
♾️ Math
Forward Propagation
Used to product an output in the forward direction by sequentially processing the input data through each layer of the neural network.
This processing involves mutliplying each layer's input with its corresponding weight matrix and then passing the product to an activation function
For each layer L,
where
Backward Propagation
Involves computation of losses in the backward direction which in turn allows for changes in layer weights to make the network produce more accurate outputs.
For each layer L,
where
Note for the last layer:
📝 Performance Analysis
Training
Classification accuracy: 0.975
Regression 0.9712041992163881
Validation
Classification accuracy: 1.0
Regression 0.723742056420074