probability and statistics
play

Probability and Statistics for Computer Science (II) - PowerPoint PPT Presentation

Probability and Statistics for Computer Science (II) Correla)on is not Causa)on but Correla)on is so beau)ful! Credit: wikipedia Hongye Liu,


  1. Probability ¡and ¡Statistics ¡ ì ¡ for ¡Computer ¡Science ¡(II) ¡ “Correla)on ¡is ¡not ¡Causa)on” ¡ but ¡Correla)on ¡is ¡so ¡beau)ful! ¡ Credit: ¡wikipedia ¡ Hongye ¡Liu, ¡Teaching ¡Assistant ¡Prof, ¡CS361, ¡UIUC, ¡8.29.2019 ¡

  2. Last ¡time ¡ ✺ Variance ¡ ✺ Visualizing ¡& ¡ Summarizing ¡ ✺ Standardizing ¡data ¡ rela)onships ¡ ✺ Median, ¡interquar)le ¡ ✺ Heatmap ¡ range, ¡box ¡plots ¡and ¡ ✺ 3D ¡bar ¡ outliers ¡ ✺ Time ¡series ¡plots ¡ ✺ ScaUer ¡plots ¡ ✺ Correla)on ¡ coefficient ¡

  3. One ¡correction ¡

  4. Q: ¡Estimate ¡the ¡range ¡of ¡data ¡in ¡ standard ¡coordinates ¡ ¡ ¡ ✺ Es)mate ¡as ¡close ¡as ¡possible, ¡99% ¡data ¡ is ¡within: ¡ ¡ 90 ¡ ¡A. ¡[-­‑10, ¡10] ¡ ¡ ¡ ¡B. ¡[-­‑100, ¡100] ¡ ¡C. ¡[-­‑1, ¡1] ¡ x i = x i − mean ( { x i } ) � ¡D. ¡[-­‑4, ¡4] ¡ std ( { x i ) } ¡E. ¡others ¡

  5. Homework ¡(I) ¡ ✺ Due ¡on ¡Sept. ¡9 ¡ ✺ There ¡is ¡one ¡op)onal ¡problem ¡with ¡ extra ¡5 ¡points. ¡(Won’t ¡be ¡in ¡exams) ¡ ✺ Gradescope ¡has ¡been ¡set ¡up. ¡Entry ¡ Code:M3DWYE ¡ ¡ ✺ Online ¡latex ¡editor ¡for ¡wri)ng ¡ formulas ¡

  6. Office ¡hours ¡& ¡Attendance ¡ ✺ Office ¡hours ¡of ¡the ¡staff ¡are ¡updated ¡ ✺ We ¡can ¡adjust ¡the ¡schedule ¡if ¡there ¡is ¡ a ¡need ¡ ✺ AUendance ¡will ¡be ¡tracked ¡from ¡ today ¡

  7. Today ¡ ✺ Visualizing ¡& ¡Summarizing ¡ rela)onships ¡ ✺ Correla)on ¡coefficient ¡ ¡ ✺ Predic)on ¡with ¡correla)on ¡ coefficient ¡

  8. It’s ¡about ¡ Relationship ¡between ¡ data ¡features ¡ ✺ Example: ¡does ¡the ¡Height ¡of ¡people ¡relate ¡to ¡ people’s ¡weight? ¡ ¡ ✺ x ¡: ¡ ¡HIGHT, ¡ ¡y: ¡WEIGHT ¡

  9. Correlation ¡Coefficient ¡ ✺ Given ¡a ¡data ¡set ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡consis)ng ¡of ¡ { ( x i , y i ) } items ¡ ¡ ( x 1 , y 1 ) ... ( x N , y N ) , ✺ Standardize ¡the ¡coordinates ¡of ¡each ¡feature: ¡ x i = x i − mean ( { x i } ) y i = y i − mean ( { y i } ) � � std ( { x i } ) std ( { y i } ) ✺ Define ¡the ¡correla)on ¡coefficient ¡as: ¡ N � corr ( { ( x i , y i ) } ) = 1 x i � � y i N i =1

  10. Correlation ¡Coefficient ¡ ¡ x i = x i − mean ( { x i } ) y i = y i − mean ( { y i } ) � � std ( { x i } ) std ( { y i } ) � N corr ( { ( x i , y i ) } ) = 1 x i � � y i N i =1

  11. Q: ¡Correlation ¡Coefficient ¡ ✺ Which ¡of ¡the ¡following ¡describe(s) ¡ correla)on ¡coefficient ¡correctly? ¡ ¡ A. ¡It’s ¡unitless ¡ ¡ ¡ ¡ ¡ ¡ ¡B. ¡It’s ¡defined ¡in ¡standard ¡coordinates ¡ ¡ ¡ ¡ ¡ ¡C. ¡Both ¡A ¡& ¡B ¡ N � corr ( { ( x i , y i ) } ) = 1 x i � � y i N i =1

  12. A ¡visualization ¡of ¡correlation ¡ coefficient ¡ hUps://rpsychologist.com/d3/correla)on/ ¡ In ¡a ¡data ¡set ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡consis)ng ¡of ¡items ¡ ¡ ¡ { ( x i , y i ) } ( x 1 , y 1 ) ... ( x N , y N ) , ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡shows ¡posi)ve ¡correla)on ¡ corr ( { ( x i , y i ) } ) > 0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡shows ¡nega)ve ¡correla)on ¡ corr ( { ( x i , y i ) } ) < 0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡shows ¡no ¡correla)on ¡ corr ( { ( x i , y i ) } ) = 0

  13. Correlation ¡seen ¡from ¡scatter ¡plots ¡ Zero ¡ ¡ Posi)ve ¡ ¡ Nega)ve ¡ ¡ Correla)on ¡ correla)on ¡ correla)on ¡ ¡ ¡ Credit: ¡ Prof.Forsyth ¡

  14. The ¡Properties ¡of ¡ ¡Correlation ¡ Coefficient ¡ ✺ The ¡correla)on ¡coefficient ¡is ¡symmetric ¡ corr ( { ( x i , y i ) } ) = corr ( { ( y i , x i ) } ) ¡ ✺ Transla)ng ¡the ¡data ¡does ¡ NOT ¡change ¡the ¡ correla)on ¡coefficient ¡

  15. The ¡Properties ¡of ¡ ¡Correlation ¡ Coefficient ¡ ✺ Scaling ¡ the ¡data ¡may ¡change ¡the ¡sign ¡of ¡ the ¡correla)on ¡coefficient ¡ corr ( { ( a x i + b, c y i + d ) } ) = sign ( a c ) corr ( { ( x i , y i ) } )

  16. The ¡Properties ¡of ¡ ¡Correlation ¡ Coefficient ¡ ✺ The ¡correla)on ¡coefficient ¡is ¡bounded ¡ within ¡[-­‑1, ¡1] ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡and ¡only ¡if ¡ x i = � � corr ( { ( x i , y i ) } ) = 1 y i ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡and ¡only ¡if ¡ corr ( { ( x i , y i ) } ) = − 1 x i = − � � y i

  17. Concept ¡of ¡ ¡Correlation ¡Coefficient’s ¡ bound ¡ ✺ The ¡correla)on ¡coefficient ¡can ¡be ¡ wriUen ¡as ¡ � N corr ( { ( x i , y i ) } ) = 1 x i � � y i N i =1 � N � � x i y i corr ( { ( x i , y i ) } ) = √ √ N N i =1 ✺ It’s ¡the ¡inner ¡product ¡of ¡two ¡vectors ¡ � � � � ¡ ¡ ¡ ¡ ¡ ¡and ¡ � y 1 � y N � � x 1 x N √ √ √ √ N , ... N , ... N N ¡

  18. Inner ¡product ¡ ✺ Inner ¡product’s ¡geometric ¡meaning: ¡ ν 1 ¡ | ν 1 | | ν 2 | cos ( θ ) θ ¡ ν 2 ¡ ✺ Lengths ¡of ¡both ¡vectors ¡ ν 1 = ¡ � � ν 2 = ¡ � � � � y 1 y N x N � x 1 � √ √ √ √ N , ... N , ... N N are ¡1 ¡

  19. Bound ¡of ¡correlation ¡coefficient ¡ | corr ( { ( x i , y i ) } ) | = | cos ( θ ) | ≤ 1 ν 1 ¡ θ ¡ ν 2 ¡ ν 1 = ¡ � � � � ν 2 = ¡ y 1 � y N � x N � x 1 � √ √ √ √ N , ... N , ... N N

  20. The ¡Properties ¡of ¡ ¡Correlation ¡ Coefficient ¡ ✺ Symmetric ¡ ✺ Transla)ng ¡invariant ¡ ¡ ✺ Scaling ¡only ¡may ¡change ¡sign ¡ ✺ bounded ¡within ¡[-­‑1, ¡1] ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

  21. Using ¡correlation ¡to ¡predict ¡ ¡ ✺ Cau*on ! ¡Correla)on ¡is ¡ NOT ¡Causa)on ¡ Credit: ¡Tyler ¡ ¡Vigen ¡

  22. How ¡do ¡we ¡go ¡about ¡the ¡prediction? ¡ ✺ Removed ¡of ¡outliers ¡& ¡standardized ¡

  23. Using ¡correlation ¡to ¡predict ¡ ¡ ✺ ¡Given ¡a ¡correlated ¡data ¡set ¡ { ( x i , y i ) } ¡we ¡can ¡predict ¡a ¡value ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡that ¡goes ¡with ¡ p y 0 ¡ ¡a ¡value ¡ ¡ x 0 ✺ ¡In ¡standard ¡coordinates ¡ ¡ ¡ { ( � x i , � y i ) } ¡we ¡can ¡predict ¡a ¡value ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡that ¡goes ¡with ¡ � p y 0 ¡a ¡value ¡ ¡ � x 0 ¡

  24. Q: ¡ ¡ ✺ ¡Which ¡coordinates ¡will ¡you ¡use ¡for ¡the ¡ predictor ¡using ¡correla)on? ¡ ¡ ¡A. ¡ ¡Standard ¡coordinates ¡ ¡ ¡B. ¡ ¡Original ¡coordinates ¡ ¡ ¡

  25. Linear ¡predictor ¡and ¡its ¡error ¡ ¡ ✺ We ¡will ¡assume ¡that ¡our ¡predictor ¡is ¡linear ¡ y p = a � � x + b ✺ We ¡denote ¡the ¡predic)on ¡at ¡each ¡ ¡ ¡ ¡ ¡ ¡ ¡in ¡the ¡data ¡ � x i set ¡as ¡ ¡ p � y i p = a � � y i x i + b ✺ The ¡error ¡in ¡the ¡predic)on ¡is ¡denoted ¡ u i p = � u i = � y i − � y i − a � y i x i − b ¡

  26. Require ¡the ¡mean ¡of ¡error ¡to ¡be ¡zero ¡ We ¡would ¡try ¡to ¡make ¡the ¡mean ¡of ¡error ¡equal ¡to ¡ zero ¡so ¡that ¡it ¡is ¡also ¡centered ¡around ¡0 ¡as ¡ ¡ the ¡standardized ¡data: ¡ mean ( { u i } ) = 0 ⇒ mean ( { � x i − b } ) = 0 y i − a � ⇒ mean ( { � y i } ) − a mean ( { � x i } ) − b = 0 0 ¡ 0 ¡ ⇒ − b = 0 ⇒ b = 0 y p = a � ⇒ � x

  27. Require ¡the ¡variance ¡of ¡error ¡is ¡ minimal ¡ var ( { u i } ) = mean ( { ( u i − mean ( { u i } )) 2 } ) 0 ¡ = mean ( { u 2 i } ) p ) 2 } ) = mean ( { ( � y i − � y i x i ) 2 } ) = mean ( { ( � y i − a � y i + a 2 � 2 − 2 a � 2 ) } ) = mean ( { ( � x i � y i x i y i } ) + a 2 var ( { � = var ( { � y i } ) − 2 a corr ( { � x i � x i } ) r 1 ¡ 1 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend