Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Machine Learning and Trend Analysis in PHP - De...

Machine Learning and Trend Analysis in PHP - DevDays Vilnius

Michael C.

May 23, 2018
Tweet

More Decks by Michael C.

Other Decks in Programming

Transcript

  1. @MICHAELCULLUMUK EXAMPLE 1+1= 2 1+2= 3 1+3= 4 2+1= 3

    3+1= 4 Cause 3+1= Predicted Effect 4 Knowledge
  2. @MICHAELCULLUMUK INFERENCE 1x + 3 = 4 1x + 4

    = 4 1x + 3 = 5 2x + 3 = 7 1x + 4 = ? x = 10
  3. @MICHAELCULLUMUK SLIDO: #K100 REGRESSION Price % alcohol 5.00 8.25 6.00

    10 4.00 6.75 3.00 5 0 2.5 5 7.5 10 0 1.5 3 4.5 6
  4. @MICHAELCULLUMUK SLIDO: #K100 REGRESSION Price % alcohol 5.00 8.25 6.00

    10 4.00 6.75 3.00 5 0 2.5 5 7.5 10 0 1.5 3 4.5 6
  5. @MICHAELCULLUMUK SLIDO: #K100 ASSOCIATION Item 1 Item 2 T-shirt Shorts

    Shorts T-shirt Suit Black Shoes Socks Underwear Item 1 Item 2 Black shoes Suit Socks Underwear Underwear Socks T-shirt Socks
  6. @MICHAELCULLUMUK SLIDO: #K100 ASSOCIATION Item 1 Item 2 T-shirt Shorts

    Shorts T-shirt Suit Black Shoes Socks Underwear Item 1 Item 2 Black shoes Suit Socks Underwear Underwear Socks T-shirt Socks People who buy socks,
 also often buy underwear People who who buy
 underwear always buy
 socks
  7. @MICHAELCULLUMUK SLIDO: #K100 ASSOCIATION Item 1 Item 2 T-shirt Shorts

    Shorts T-shirt Suit Black Shoes Socks Underwear Item 1 Item 2 Black shoes Suit Socks Underwear Underwear Socks T-shirt Socks People who buy socks,
 also often buy underwear People who buy suits
 always buy black shoes People who who buy
 underwear always buy
 socks People who buy black
 shoes, always buy suits
  8. @MICHAELCULLUMUK SLIDO: #K100 ASSOCIATION Item 1 Item 2 T-shirt Shorts

    Shorts T-shirt Suit Black Shoes Socks Underwear Item 1 Item 2 Black shoes Suit Socks Underwear Underwear Socks T-shirt Socks People who buy socks,
 also often buy underwear People who buy suits
 always buy black shoes People who who buy
 underwear always buy
 socks People who buy black
 shoes, always buy suits People who buy shorts
 always buy t-shirts People who buy t-shirts,
 also often buy shorts
  9. @MICHAELCULLUMUK SLIDO: #K100 CLUSTER ANALYSIS IS THE TASK OF GROUPING

    A SET OF OBJECTS IN SUCH A WAY THAT OBJECTS IN THE SAME GROUP ARE MORE SIMILAR TO EACH OTHER THAN TO THOSE IN OTHER GROUPS.
  10. @MICHAELCULLUMUK SLIDO: #K100 ▸ Each point has an x and

    y value ▸ We need an equation of a line ▸ We move the line an infinite number of times ▸ Each time, we draw a box between every point, and the line, with one corner on the line, and another on the point ▸ The correct line is the one where the sum of the area of all the squares is smallest PROCESS
  11. @MICHAELCULLUMUK SLIDO: #K100 CODE $samples = [[60], [61], [62], [63],

    [65]]; $targets = [3.1, 3.6, 3.8, 4, 4.1]; $regression = new LeastSquares(); $regression->train($samples, $targets); echo $regression->predict([64]);
  12. @MICHAELCULLUMUK SLIDO: #K100 DEMO $samples = [[1, 3], [1, 4],

    [2, 4], [3, 1], [4, 1], [4, 2]]; $labels = ['a', 'a', 'a', 'b', 'b', 'b']; $classifier = new KNearestNeighbors(); $classifier->train($samples, $labels); echo $classifier->predict([3, 2]);