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.

Als alternatief voor grid search zouden we via sampling kunnen werken.

  1. We starten met een eerste berekende gok voor de parameters en berekenen de SSESSE loss bij de start

  2. Daarna itereren we (30k keer) over volgende stappen:

    • We nemen een sample uit een normale verdeling met gemiddelde 0 om een kleine aanpassing te doen aan de parameterschattingen (in positieve of negatieve zin).

    • We zorgen dat de bijgewerkte schattingen binnen een realistisch interval blijven.

    • We berekenen de SSESSE loss opnieuw. Als de nieuwe SSESSE is gedaald, behouden we de nieuwe parameterwaarden. In het andere geval verwerpen we ze.

Source
Source
Current SSE loss: 115.68 (with guess: -0.34 + -0.49 × standardized_order)
Sample     1: Standardized Tip = 0.00 + 0.00 × Standardized Order Total, loss=50.0
Sample  1000: Standardized Tip = 0.00 + 0.04 × Standardized Order Total, loss=46.2
Sample  2000: Standardized Tip = 0.00 + 0.08 × Standardized Order Total, loss=42.8
Sample  3000: Standardized Tip = 0.00 + 0.12 × Standardized Order Total, loss=39.3
Sample  4000: Standardized Tip = 0.00 + 0.16 × Standardized Order Total, loss=35.8
Sample  5000: Standardized Tip = 0.01 + 0.20 × Standardized Order Total, loss=32.8
Sample  6000: Standardized Tip = 0.00 + 0.24 × Standardized Order Total, loss=29.8
Sample  7000: Standardized Tip = 0.01 + 0.28 × Standardized Order Total, loss=27.0
Sample  8000: Standardized Tip = 0.01 + 0.32 × Standardized Order Total, loss=24.4
Sample  9000: Standardized Tip = 0.01 + 0.35 × Standardized Order Total, loss=21.9
Sample 10000: Standardized Tip = 0.01 + 0.40 × Standardized Order Total, loss=19.5
Sample 11000: Standardized Tip = 0.00 + 0.44 × Standardized Order Total, loss=17.3
Sample 12000: Standardized Tip = 0.00 + 0.47 × Standardized Order Total, loss=15.3
Sample 13000: Standardized Tip = 0.00 + 0.51 × Standardized Order Total, loss=13.5
Sample 14000: Standardized Tip = 0.00 + 0.55 × Standardized Order Total, loss=11.7
Sample 15000: Standardized Tip = 0.00 + 0.59 × Standardized Order Total, loss=10.1
Sample 16000: Standardized Tip = 0.00 + 0.63 × Standardized Order Total, loss=8.7
Sample 17000: Standardized Tip = 0.00 + 0.67 × Standardized Order Total, loss=7.4
Sample 18000: Standardized Tip = 0.00 + 0.71 × Standardized Order Total, loss=6.4
Sample 19000: Standardized Tip = 0.00 + 0.75 × Standardized Order Total, loss=5.5
Sample 20000: Standardized Tip = 0.00 + 0.79 × Standardized Order Total, loss=4.7
Sample 21000: Standardized Tip = 0.00 + 0.83 × Standardized Order Total, loss=4.1
Sample 22000: Standardized Tip = 0.00 + 0.86 × Standardized Order Total, loss=3.6
Sample 23000: Standardized Tip = 0.00 + 0.90 × Standardized Order Total, loss=3.3
Sample 24000: Standardized Tip = 0.00 + 0.94 × Standardized Order Total, loss=3.1
Sample 25000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1
Sample 26000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1
Sample 27000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1
Sample 28000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1
Sample 29000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1
Sample 30000: Standardized Tip = 0.00 + 0.97 × Standardized Order Total, loss=3.1

✅ Finished! Accepted 40.8% of proposed changes

Visualisatie van het SSESSE oppervlak

Nu we de Monte Carlo sampling hebben uitgevoerd, kunnen we stappen visualiseren op het SSESSE oppervlak. Zo zien we hoe het algoritme “bergafwaarts” beweegt naar het minimum.

Source
Loading...

Hieronder herhalen we het naïeve Monte Carlo algorithme 10 keer en visualiseren we de resulterende regressielijnen.

Source
Estimated relationship: Standardized Tip = 0.00 + 0.55 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.00 + -0.13 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.01 + 2.30 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.00 + 0.53 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.02 + 2.25 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.00 + 2.15 × Standardized Order Total
Estimated relationship: Standardized Tip = -0.00 + 0.53 × Standardized Order Total
Estimated relationship: Standardized Tip = 0.00 + 0.93 × Standardized Order Total
Estimated relationship: Standardized Tip = -0.01 + 2.30 × Standardized Order Total
Estimated relationship: Standardized Tip = -0.00 + 0.95 × Standardized Order Total
Source
<Figure size 1200x600 with 1 Axes>

De simpele Monte Carlo benadering levert duidelijk onstabiele resultaten op. In de volgende secties bekijken we betere alternatieven op basis van calculus. Daarvoor behandelen we eerst het concept van de gradiënt van de loss functie.