Case 4. MLP for nonlinear phishing risk (RubixML)
Implementation in RubixML
We solve this task with a multilayer neural network. In this case, phishing risk is estimated from two features: employee security-awareness level and current workload. The dependency can be nonlinear, so we use an MLP (Multilayer Perceptron) from RubixML: build a labeled dataset, standardize features with ZScaleStandardizer, train the model, and get a prediction for a new employee profile.
Example of code:
<?php
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Classifiers\MultilayerPerceptron;
use Rubix\ML\NeuralNet\ActivationFunctions\ReLU;
use Rubix\ML\NeuralNet\Layers\Activation;
use Rubix\ML\NeuralNet\Layers\Dense;
use Rubix\ML\Transformers\ZScaleStandardizer;
$samples = [
[1, 6],
[5, 3],
[10, 1],
[3, 7],
];
$labels = [
'risk',
'safe',
'risk',
'safe',
];
$dataset = new Labeled($samples, $labels);
$standardizer = new ZScaleStandardizer();
$dataset->apply($standardizer);
// Hidden layers: 8 and 4 neurons add enough nonlinearity for this tiny demo dataset.
$model = new MultilayerPerceptron([
new Dense(8),
new Activation(new ReLU()),
new Dense(4),
new Activation(new ReLU()),
]);
$model->train($dataset);