Logistic regression

Case 5. Loan approval

In lending tasks, a model rarely answers "yes or no" directly. Instead, it estimates a probability that is then turned into a decision.
Even more important is the client’s risk. This is why logistic regression is used so often in credit scoring: it gives not just a label, but the probability that the client is reliable – something you can work with.

Case Goal
Estimate the client’s credit risk and make a loan approval decision.

The model should:
1) Compute the probability that the client will repay the loan
2) Allow flexible decision control via a threshold

Example of code:

 
<?php

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

$samples = [
    [
3000, 600, 0.4],
    [
8000, 750, 0.2],
    [
2000, 500, 0.7],
    [
10000, 800, 0.1],
];

$labels = ['decline', 'approve', 'decline', 'approve'];

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

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