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

ロジスティック回帰 Part 1 - 基礎編

Kan Nishida
September 19, 2019

ロジスティック回帰 Part 1 - 基礎編

Kan Nishida

September 19, 2019
Tweet

More Decks by Kan Nishida

Other Decks in Science

Transcript

  1. 3 εϐʔΧʔ ੢ా צҰ࿠ CEO EXPLORATORY ུྺ 2016೥ɺσʔλαΠΤϯεͷຽओԽͷͨΊɺExploratory, Inc Λ

    ্ཱͪ͛Δɻ Exploratory, Inc.ͰCEOΛ຿ΊΔ͔ͨΘΒɺσʔλαΠΤϯεɾ ϒʔτΩϟϯϓɾτϨʔχϯάͳͲΛ௨ͯ͠γϦίϯόϨʔͰ ߦΘΕ͍ͯΔ࠷ઌ୺ͷσʔλαΠΤϯεͷීٴͱڭҭʹऔΓ૊ Ήɻ ถΦϥΫϧຊࣾͰɺ16೥ʹΘͨΓσʔλαΠΤϯεͷ։ൃνʔ ϜΛ཰͍ɺػցֶशɺϏοάɾσʔλɺϏδωεɾΠϯςϦδΣ ϯεɺσʔλϕʔεʹؔ͢Δ਺ଟ͘ͷ੡඼ΛੈʹૹΓग़ͨ͠ɻ @KanAugust
  2. ୈ1ͷ೾ ୈ̎ͷ೾ ୈ̏ͷ೾ ϓϥΠϕʔτ(ߴ͍/ݹ͍) Φʔϓϯɾιʔε(ແྉ/࠷ઌ୺) UI & ϓϩάϥϛϯά ϓϩάϥϛϯά 2016

    2000 1976 ϚωλΠθʔγϣϯ ίϞσΟςΟԽ ຽओԽ ౷ܭֶऀ σʔλαΠΤϯςΟετ Exploratory ΞϧΰϦζϜ Ϣʔβʔɾ ମݧ πʔϧ Φʔϓϯɾιʔε(ແྉ/࠷ઌ୺) UI & ࣗಈԽ ϏδωεɾϢʔβʔ ςʔϚ σʔλαΠΤϯεͷຽओԽ
  3. Pr(Father > 35) = 0.039 * 35 - 0.85 =

    0.515 51.5% ͷ֬཰Ͱ෕਌͸35ࡀΑΓ্ɻ Pr(Father > 35) = 0.039 * Mother_Age -0.85 ฼਌ͷ೥ྸ: 35
  4. Pr(Father > 35) = 0.039 * 20 - 0.85 =

    -0.07 Pr(Father > 35) = 0.039 * Mother_Age -0.85 ϚΠφε 7% ͷ֬཰Ͱ෕਌͸35ࡀΑΓ্ɻ ฼਌ͷ೥ྸ: 20
  5. ֬཰ vs. Φοζ P(Father > 35) = 0.2 P(TRUE) =

    P(Father > 35) = 0.2 P(FALSE): 1 - P(Father > 35) = 0.8 Φοζ = P(TRUE) / P(FALSE) = 0.2 / 0.8 = 0.25
  6. ֬཰ vs. Φοζ P(Father > 35) = 0.75 P(TRUE) =

    P(Father > 35) = 0.75 P(FALSE): 1 - P(Father > 35) = 0.25 Φοζ = P(TRUE) / P(FALSE) = 0.75 / 0.25 = 3
  7. Pr(Father > 35) = 0 0 / (1 - 0)

    = 0 ֬཰ Φοζ Pr(Father > 35) = 0.5 0.5 / (1 - 0.5) = 1 Pr(Father > 35) = 0.9 0.9 / (1 - 0.9) = 9 Pr(Father > 35) = 0.999 0.999 / (1 - 0.999) = 999 Pr(Father > 35) = 1 1 / (1 - 1) = ແݶ ม׵
  8. Probability can only range from 0 to 1, Odds can

    be 0 up to any positive number. But, we still have a problem. We want the variable that can range from any negative number to any positive number.
  9. ֬཰ 0 1 Φοζ 0 1 ແݶ ແݶ -ແݶ 0

    ϩάɾΦοζ log( Odds( P(y) )) Odds( P(y) )
  10. ઢܗճؼ ϩδεςΟοΫճؼ Logit( P(Father > 35) ) = a *

    Mother_Age + b Father_Age = a * Mother_Age + b
  11. Logit( P(Father > 35) ) = 0.29 * Mother_Age -

    10.12 Logit( P(Father > 35) ) = 0.29 * 40 - 10.12 = 1.48 ෕਌͕35ࡀҎ্Ͱ͋ΔϩάɾΦοζ͸1.48ɻ ???
  12. Logit(P(Father > 35)) = 0.03 * Mother_Age - 0.85 P(Father

    > 35) = Logit (0.03 * Mother_Age - 0.85) -1 ٯؔ਺
  13. Logit(Pr(Father > 35)) = 0.03 * Mother_Age - 0.85 Pr(Father

    > 35) = (0.03 * Mother_Age - 0.85) Logistic
  14. P(Father > 35) = Logistic(0.29 * Mother_Age - 10.12) P(Father

    > 35) = Logistic(0.29 * 40 - 10.12) = Logistic(1.48) = 0.8145 ฼਌͕40ࡀͷ࣌ɺ෕਌͕35ࡀҎ্Ͱ͋Δ֬཰͸81%ɻ
  15. P(Father > 35) = Logistic(0.29 * Mother_Age - 10.12) P(Father

    > 35) = Logistic(0.29 * 20 - 10.12) = Logistic(-4.32) = 0.01312 ฼਌͕20ࡀͷ࣌ɺ෕਌͕35ࡀҎ্Ͱ͋Δ֬཰͸1.3%ɻ
  16. 109 ෕਌͕35Ҏ্ͷ֬཰ = logistic(a * Mother_Age + b) ܎਺ʢ܏͖ʣ ੾ย

    ܎਺ͱ੾ยΛௐઅ͢Δ͜ͱͰ࣮σʔλͱ Ϛον͢ΔΑ͏ͳۂઢ͕ඳ͚Δɻ
  17. 122 30 35 40 ฼਌ͷ೥ྸ 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE

    ͖͍͠஋Λઃ͚Δɻྫ͑͹ɺ֬཰͕50%Λڥʹ͢Δɻ
  18. 123 30 35 40 ฼਌ͷ೥ྸ 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE

    TRUE FALSE ͜ͷۂઢΛ࢖͏͜ͱͰ෼ྨ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨɻ
  19. 124 30 35 40 ฼਌ͷ೥ྸ 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE

    TRUE FALSE ͜ͷۂઢΛ࢖͏͜ͱͰ෼ྨ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨɻ
  20. 125 30 35 40 ฼਌ͷ೥ྸ 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE

    TRUE FALSE ࣮ࡍʹ͸ɺ෕਌ͷ೥ྸ͕35ࡀҎ্ͩͬͨσʔλʹ౰ͯ͸ΊͯΈΔ
  21. 127 30 35 40 ฼਌ͷ೥ྸ 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE

    TRUE FALSE ࣮ࡍʹ͸ɺ෕਌ͷ೥ྸ͕35ࡀҎ্͡Όͳ͔ͬͨσʔλʹ౰ͯ͸ΊͯΈΔ
  22. 129 30 35 40 50% ෕਌ͷ೥ྸ͕ 35ࡀҎ্ TRUE FALSE TRUE

    FALSE ౰͍ͨͬͯͳ͍ ౰͍ͨͬͯͳ͍
  23. 134 ෕਌͕35Ҏ্ͷ֬཰ = logistic(0.3 * Mother_Age + 1.2 * Mother_Japanese

    - 10) ༧ଌม਺͕Mother_AgeͱMother_Japaneseͷ ̎ͭͷ৔߹