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 = [
    [
30006000.4],
    [
80007500.2],
    [
20005000.7],
    [
100008000.1],
];

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

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

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