Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

โœ… Data loaded successfully!
  • Target variabele y\pmb{y}:

    • Payment Method

  • Features X\pmb{X}:

    • Avg VTAT

    • Avg CTAT

    • Booking Value

    • Ride Distance

['UPI' 'Debit Card' 'Cash' 'Uber Wallet' 'Credit Card']

โœ๏ธยถ

Maak NumPy array aan voor de target y\pmb{y}.

[0 1 2 3 4]

โœ๏ธยถ

Maak NumPy array aan voor de featurematrix X\pmb{X} mรจt standaardschaling.

โœ๏ธยถ

Maak random 80/20% train/test split van y\pmb{y} en X\pmb{X}.

Training set size: 81600
Test set size: 20400
Training set shape: X=(81600, 4), y=(81600,)
Test set shape: X=(20400, 4), y=(20400,)

โœ๏ธยถ

Converteer y\pmb{y} en X\pmb{X} naar PyTorch formaat.

โœ๏ธยถ

Train een NeuralNetwork model (zie hierboven) met 10 hidden neurons.

โœ“ PyTorch Neural Network Model Created!

Model Architecture:
NeuralNetwork(
  (fc1): Linear(in_features=4, out_features=10, bias=True)
  (relu): ReLU()
  (fc2): Linear(in_features=10, out_features=5, bias=True)
)

Total parameters: 105

Parameter details:
  fc1.weight: torch.Size([10, 4]) (40 parameters)
  fc1.bias: torch.Size([10]) (10 parameters)
  fc2.weight: torch.Size([5, 10]) (50 parameters)
  fc2.bias: torch.Size([5]) (5 parameters)

โœ๏ธยถ

Definieer de Cross Entropy Loss functie en Stochastic Gradient Descent als optimalisatiealgoritme (learning rate = 0.02)

โœ“ Loss function and optimizer configured!

Loss function: CrossEntropyLoss()
Optimizer: SGD (
Parameter Group 0
    dampening: 0
    differentiable: False
    foreach: None
    fused: None
    lr: 0.02
    maximize: False
    momentum: 0
    nesterov: False
    weight_decay: 0
)
Learning rate: 0.02

โœ๏ธยถ

Train the model for 2000 epochs and plot the test/training loss en accuraatheid.

Training Neural Network with PyTorch...
Architecture: 4 โ†’ 10 (ReLU) โ†’ 5
Learning rate: 0.02
Epochs: 2000

Training progress:
----------------------------------------------------------------------
Epoch    1 | Train Loss: 2.1648 | Test Loss: 2.1529 | Train Acc: 16.45% | Test Acc: 16.88%
Epoch  200 | Train Loss: 1.4613 | Test Loss: 1.4589 | Train Acc: 43.11% | Test Acc: 43.03%
Epoch  400 | Train Loss: 1.4191 | Test Loss: 1.4152 | Train Acc: 44.52% | Test Acc: 44.53%
Epoch  600 | Train Loss: 1.4101 | Test Loss: 1.4062 | Train Acc: 44.86% | Test Acc: 44.89%
Epoch  800 | Train Loss: 1.4059 | Test Loss: 1.4021 | Train Acc: 44.99% | Test Acc: 44.97%
Epoch 1000 | Train Loss: 1.4034 | Test Loss: 1.3996 | Train Acc: 45.01% | Test Acc: 45.00%
Epoch 1200 | Train Loss: 1.4017 | Test Loss: 1.3979 | Train Acc: 45.01% | Test Acc: 45.00%
Epoch 1400 | Train Loss: 1.4005 | Test Loss: 1.3968 | Train Acc: 45.01% | Test Acc: 45.00%
Epoch 1600 | Train Loss: 1.3996 | Test Loss: 1.3959 | Train Acc: 45.01% | Test Acc: 45.00%
Epoch 1800 | Train Loss: 1.3989 | Test Loss: 1.3953 | Train Acc: 45.01% | Test Acc: 45.00%
Epoch 2000 | Train Loss: 1.3984 | Test Loss: 1.3947 | Train Acc: 45.01% | Test Acc: 45.00%
----------------------------------------------------------------------

โœ“ Training completed!

Final Results:
  Training Loss: 1.3984
  Test Loss: 1.3947
  Training Accuracy: 45.01%
  Test Accuracy: 45.00%