Logistic regression

Case 3. Spam or not spam

Case Goal:
We will build a simple model that detects whether an email is spam using two basic features:

1) Number of links in the email
2) Email length

This will let you see how logistic regression works not just on a single axis, but in a two-dimensional feature space.

Example of code:

 
<?php

use Rubix\ML\Classifiers\LogisticRegression;
use 
Rubix\ML\Datasets\Labeled;

// Features: [number_of_links, email_length]
$samples = [
    [
0, 50],
    [
1, 120],
    [
5, 300],
    [
7, 500],
    [
0, 40],
];

$labels = ['not_spam', 'not_spam', 'spam', 'spam', 'not_spam'];

$dataset = new Labeled($samples, $labels);

$model = new LogisticRegression();
$model->train($dataset);