SK-Learn Neural Network

SK-Learn supports some form of basic neural network. This is good as an initial go to approach. However, it is advised to look into packages such as Keras and Tensorflow for more complex neural networks.


  • hidden_layers = a tuple defining the number of neurons per hidden layer. default is (100,) which means one hidden layer of 100 neurons. (100, 100) would mean two hidden layers of 100 neurons.
  • activation_fn = the activation function used in the neurons. Default is "relu". Other activation functions include: {‘identity’, ‘logistic’, ‘tanh’, ‘relu’}
  • solver = This is the type of algorithm used for the gradient descent. Default is "adam", other choices include: {‘lbfgs’, ‘sgd’, ‘adam’}
  • alpha = The L2 regularization penalty, default is: 0.0001
  • learning_rate = default: "constant", choices: {‘constant’, ‘invscaling’, ‘adaptive’}
  • learning_rate_init = default: 0.001
  • momentum = momentum of the gradient descent, default: 0.9


  • model_title: set to "Neural Network" for deployment package
  • structure: Initially None, gets defined to the matrix dimensions when the define_structure method is fired. Whilst hard coding algorithms is not recomended, this gives the user a high-level blueprint of what structure the neural network should undergo


The neural network has the following methods:

define activation function

This method takes an activation function arguement, defining it for the neural network. This enables the user to try and compare multiple activation functions without having to create new model classes.

neural = NeuralNetworkBase()

define network structure

This method takes no arguements. When fired is defines the structure atribute with a list of shapes of the matrices of the neural network model. Useful for reference.

Practical Example

from deployml.sklearn import NeuralNetworkBase

# We define the model
NN = NeuralNetworkBase(hidden_layers=(4, 4))

# We define the data (pandas data frame) = input_data

# We define the key of the column we are trying to predict
NN.outcome_pointer = 'attended'

# Now we've defined the network we produce a training curve and show it 
# with scaled data using a standard scaler
NN.plot_learning_curve(scale=True, batch_size=100)

# We then print out the precision, recall and F-1 score 

# And show the ROC curve 

Not Enough?

It's understandable that you might want a more custom model. Whilst we are always working on making Deploy-ML more versatile, you can define your own SK-Learn model and import it into the Deploy-ML learning and packaging framework!