- ãã®è¨äºã¯ä½ï¼
- ãã«ãã¼ã¤åå¸ã®å¦ç¿
- ã«ãã´ãªåå¸ã®å¦ç¿
- ãã¢ã½ã³åå¸ã®å¦ç¿
- 1次å ã¬ã¦ã¹åå¸ã®å¦ç¿ã¨äºæ¸¬
- ãã®ä»
ãã®è¨äºã¯ä½ï¼
ããã¤ãºæ¨è«ã«ããæ©æ¢°å¦ç¿å
¥éããèªãã§ãã¤ãºæ¨è«ãç解ããæ°ãããã®ã§ãæ¬ã®3ç« ã§ç´¹ä»ããã¦ããã¢ã«ã´ãªãºã ãå®é¨ãã¦ã¿ã¾ããã
www.kspub.co.jp
ãã«ãã¼ã¤åå¸ã®å¦ç¿
æ¬ã®3.2.1ç¯ã§ç´¹ä»ããã¦ãããã«ãã¼ã¤åå¸ã®å¦ç¿ã¨äºæ¸¬ãUCI Machine Learning Repository: Breast Cancer Wisconsin (Diagnostic) Data Setã«é©ç¨ãã¦ã¿ã¾ãã
ãã®ãã¼ã¿ã»ããã¯ä¹³ãã診æã®çµæã«é¢ãããã¼ã¿ã»ããã§ããã診æçµæãè¯æ§ãæªæ§ãã¨ããæ
å ±ãä¸ãããã¦ãã¾ãã
ãã¼ã¿ã»ããã®ãµã¤ãºã¯ã§ãããè¯æ§ã®ã¬ã³ã¼ãæ°ã¯357ãæªæ§ã®ã¬ã³ã¼ãæ°ã¯212ã§ããã
確çå¤æ°ãã診æçµæãè¯æ§ã®ã¨ãã«ãæªæ§ã®ã¨ãã«ã¨å®ç¾©ãã¾ãã
2å¤ãåãé¢æ£ã®äºè±¡ã表ç¾ããããã«ããã«ãã¼ã¤åå¸ãèãã¾ãã
ãã«ãã¼ã¤åå¸ã®å ±å½¹äºååå¸ã§ãããã¼ã¿åå¸ãèãã¾ãã
ããã§ãã¯ãã¼ã¿åå¸ã®ãã©ã¡ã¼ã¿ã§ãããäºåã«é©å½ã«ä¸ãããã¨ã«ãã¾ããããã¨ãäºå¾åå¸ã¯ä»¥ä¸ã§ä¸ãããã¾ãã詳ããã¯æ¬ã®P78ãåç §ãã¦ãã ããã
ããã§ã¯ãã«ãã¼ã¤åå¸ã®å¦ç¿ãå®è£ ãã¦ã¿ã¾ããã¨ãã£ã¦ãããè¨ç®ããã ãã§ããâ¦â¦
def fit(X, a, b): # X: numpy array ([0, 1, 0, 1, ..., ]) # a, b: hyper parameter of the prior distribution N = X.shape[0] hat_a = np.sum(X) + a hat_b = N - np.sum(X) + b return hat_a, hat_b
ãã«ãã¼ã¤åå¸ã®å¦ç¿ãä¸ã®ãã¼ã¿ã»ããã«é©ç¨ãã¾ããäºååå¸ã®ãã©ã¡ã¼ã¿ã¯ã¨ãã¾ããã
å¦ç¿ã®çµæããå¾ããã¾ããï¼ä¸å¼ã«ä»£å
¥ããã ãã§æ±ãããã¾ãï¼ã
å®éã«äºååå¸ã»äºå¾åå¸ãè¦ã¦ã¿ã¾ããããä¸å³ã®å·¦å´ã¯äºååå¸ãå³å´ã¯äºå¾åå¸ã表ãã¦ãã¾ãã
äºå¾åå¸ã¯ãããã®é¨åã§ãã¼ã¯ãè¦ããã¾ãã
ã«ãã´ãªåå¸ã®å¦ç¿
æ¬ã®3.2.2ç¯ã§ç´¹ä»ããã¦ããã«ãã´ãªåå¸ã®å¦ç¿ã¨äºæ¸¬ã
UCI Machine Learning Repository: Adult Data Setã«é©ç¨ãã¦ã¿ã¾ãã
ãã®ãã¼ã¿ã»ããã¯äººå£èª¿æ»ã®ãã¼ã¿ã»ããã§ããã人種æ
å ±(White, Asian-Pac-Islander, Amer-Indian-Eskimo, Other, Black)ãä¸ãããã¦ãã¾ãã
ãã¼ã¿ã»ããã®ãµã¤ãºã¯ã§ãããå人種ã®ã¬ã³ã¼ãæ°ã¯ä»¥ä¸ã®éãã§ãã
å±æ§ | ãµã¤ãº |
---|---|
White | 27816 |
Black | 3124 |
Asian-Pac-Islander | 1039 |
Amer-Indian-Eskimo | 311 |
Other | 271 |
確çå¤æ°ãåå±æ§ã«å¯¾å¿ãã1-hotãã¯ãã«ã¨å®ç¾©ãã¾ãã
ä¾ãã°ã"White"ã¯ã¨è¡¨ãã"Black"ã¯ã¨è¡¨ãã¾ãã
5å¤ãåãé¢æ£ã®äºè±¡ã表ãããã«ãã«ãã´ãªåå¸ãèãã¾ãã
ããã§ãã¯ã«ãã´ãªåå¸ã®ãã©ã¡ã¼ã¿ã§ãããã®åå¸ãè¨ç·´ãã¼ã¿ããæ¨è«ãã¾ããã«ãã´ãªåå¸ã®å ±å½¹äºååå¸ã§ãããã£ãªã¯ã¬åå¸ãèãã¾ãã
ããã§ãã¯ãã£ãªã¯ã¬åå¸ã®ãã©ã¡ã¼ã¿ã§ãããäºåã«é©å½ã«ä¸ãããã¨ã«ãã¾ããããã¨ãäºå¾åå¸ã¯ä»¥ä¸ã§ä¸ãããã¾ãã詳ããã¯æ¬ã®P82ãåç §ãã¦ãã ããã
ããã§ã¯ã«ãã´ãªåå¸ã®å¦ç¿ãå®è£ ãã¦ã¿ã¾ããäºååå¸ã®ãã©ã¡ã¼ã¿ã«åå±æ§ã®ã¬ã³ã¼ãæ°ã足ãã ãã§ãã
def fit(S, alpha): # S: numpy array, shape: (N, K) # alpha: hyper parameter of the prior distribution hat_alpha = np.sum(S, axis=0) + alpha return hat_alpha
ã¨ããã¨ããå¾ããã¾ããã
ã¯5次å
ï¼åã1ã«ãªãã¨ããå¶ç´æ¡ä»¶ãèããã°4次å
ã§ããï¼ãªã®ã§ãäºååå¸ã»äºå¾åå¸ã®æç»ã¯ã¡ãã£ã¨é£ããã§ãããã
ãã¢ã½ã³åå¸ã®å¦ç¿
æ¬ã®3.2.3ç¯ã§ç´¹ä»ããã¦ãããã¢ã½ã³åå¸ã®å¦ç¿ã¨äºæ¸¬ã
UCI Machine Learning Repository: Wine Quality Data Set
ã«é©ç¨ãã¦ã¿ã¾ãã
ãã®ãã¼ã¿ã»ããã¯ã¯ã¤ã³ã®è³ªã«é¢ãããã¼ã¿ã»ããã§ãããã¯ã¤ã³ã®è³ªã0ãã10ã®é¢æ£å¤ã§è¡¨ãã¦ãã¾ãã
赤ã¯ã¤ã³ã¨ç½ã¯ã¤ã³ã®ãã¼ã¿ã»ãããããã¾ãããä»åã¯ç½ã¯ã¤ã³ã®ãã¼ã¿ã»ããã使ãã¾ãã
ãã¼ã¿ã»ããã®ãµã¤ãºã¯ã§ãããã¯ã¤ã³ã®è³ªã«å¯¾å¿ããã¬ã³ã¼ãæ°ã¯ä¸è¡¨ã®éãã§ãã
ã¯ã¤ã³ã®è³ª | ã¬ã³ã¼ãæ° |
---|---|
3 | 20 |
4 | 163 |
5 | 1457 |
6 | 2198 |
7 | 880 |
8 | 175 |
9 | 5 |
確çå¤æ°ãã¯ã¤ã³ã®è³ªã表ãé¢æ£å¤ã§å®ç¾©ãã¾ãã
ãã®äºè±¡ã表ç¾ããããã«ããã¢ã½ã³åå¸ãèãã¾ãã
ãã¢ã½ã³åå¸ã®å ±å½¹äºååå¸ã§ããã¬ã³ãåå¸ãèãã¾ãã
ããã§ãã¯ã¬ã³ãåå¸ã®ãã©ã¡ã¼ã¿ã§ãããäºåã«é©å½ã«ä¸ãããã¨ã«ãã¾ããããã¨ãäºå¾åå¸ã¯ä»¥ä¸ã§ä¸ãããã¾ãã詳ããã¯æ¬ã®P85ãåç §ãã¦ãã ããã
ããã§ã¯ãã¢ã½ã³åå¸ã®å¦ç¿ãå®è£ ãã¦ã¿ã¾ãã
def fit(X, a, b): # X: numpy array [6, 5, 9, ...] # a, b: hyper parameter of the prior distribution N = X.shape[0] hat_a = np.sum(X) + a hat_b = N + b return hat_a, hat_b
ã¨ããã¨ããå¾ããã¾ããã
å®éã«äºååå¸ã»äºå¾åå¸ãè¦ã¦ã¿ã¾ããããä¸å³ã®å·¦å´ã¯äºååå¸ãå³å´ã¯äºå¾åå¸ã表ãã¦ãã¾ãã
äºå¾åå¸ã¯ãããã®é¨åã§ãã¼ã¯ãè¦ããã¾ãã
ãã®ãã¨ã¯ãã¨ãªããã¨ããã確ããããã¾ãã
ãã£ãããªã®ã§ãµã³ããªã³ã°ããã£ã¦ã¿ã¾ãã
ããã§ã¯æ¯è¼ã®ãããè¨ç·´ãã¼ã¿ã®ãã¹ãã°ã©ã ã»MAPæ¨å®ã®çµæå¾ããããç¨ãããããµã³ããªã³ã°ã»ãã¤ãºæ¨è«ã«ããäºæ¸¬åå¸ãããµã³ããªã³ã°ã®3ã¤ã®çµæã示ãã¾ãã
ããã§ãã§ä¸ãããã¾ãã詳ããã¯æ¬ã®P86ãåç
§ãã¦ãã ããã
è¨ç·´ãã¼ã¿ã®ãã¹ãã°ã©ã ã»ãããµã³ããªã³ã°ã»ãããµã³ããªã³ã°ããçµæãä¸å³ã«ç¤ºãã¾ãã
ãµã³ããªã³ã°ã®çµæã0~2ã9~13ã®å¤ãçµæ§åºã¦ãã¦ãã¾ããããå°ãå°ã£ã¦æ¬²ãããâ¦ï¼
1次å ã¬ã¦ã¹åå¸ã®å¦ç¿ã¨äºæ¸¬
æ¬ã®3.2.3ç¯ã§ç´¹ä»ããã¦ããå¹³åã»ç²¾åº¦ãæªç¥ã®å ´åã®ã¬ã¦ã¹åå¸ã®å¦ç¿ã¨äºæ¸¬ãUCI Machine Learning Repository: Wine Quality Data Setã«é©ç¨ãã¦ã¿ã¾ãã
ãã¢ã½ã³åå¸ã®å¦ç¿ã¨äºæ¸¬ã§ç¨ãããã¼ã¿ã»ããã§ããããã®ãã¼ã¿ã»ããã«ã¯ã¯ã¤ã³ã®è³ªä»¥å¤ã«ããã¯ã¤ã³ã®pHãä¸ãããã¦ãã¾ãã
pHã«ã¤ãã¦ã®ãã¹ãã°ã©ã ãä¸å³ã«ç¤ºãã¾ãã
確çå¤æ°ãã¯ã¤ã³ã®pHã表ãå®æ°å¤ã§å®ç¾©ãã¾ãã
ãã®äºè±¡ã表ç¾ããããã«ãã¬ã¦ã¹åå¸ãèãã¾ãã
ã¬ã¦ã¹åå¸ã®å ±å½¹äºååå¸ã§ããã¬ã¦ã¹ã»ã¬ã³ãåå¸ãèãã¾ãã
ããã§ãã¯ã¬ã¦ã¹ã»ã¬ã³ãåå¸ã®ãã©ã¡ã¼ã¿ã§ãããäºåã«é©å½ã«ä¸ãããã¨ã«ãã¾ããããã¨ã«é¢ããäºå¾åå¸ã¯ä»¥ä¸ã§ä¸ãããã¾ãã
ã¾ããã«é¢ããäºå¾åå¸ã¯ä»¥ä¸ã§ä¸ãããã¾ãã
ãããã®å°åºã¯æ¬ã®P95ãåç §ãã¦ãã ããã
ããã§ã¯ã¬ã¦ã¹åå¸ã®å¦ç¿ãå®è£ ãã¦ã¿ã¾ãã
def fit(X, m, beta, a, b): # X: numpy array # m, beta, a, b: hyper parameter of the prior distribution N = X.shape[0] hat_beta = N + beta hat_m = 1 / hat_beta * (np.sum(X) + beta * m) hat_a = N / 2 + a hat_b = 1 / 2 * (np.sum(X ** 2) + beta * (m ** 2) - hat_beta * (hat_m ** 2)) + b return hat_beta, hat_m, hat_a, hat_b
ã¨ããã¨ããå¾ããã¾ããã
å®éã«äºååå¸ã»äºå¾åå¸ãè¦ã¦ã¿ã¾ããããä¸å³ã®å·¦å´ã¯äºååå¸ãå³å´ã¯äºå¾åå¸ã表ãã¦ãã¾ãã
ãããã®é¨åã§ãã¼ã¯ãè¦ããã¾ãã
äºååå¸ã¯ã¹ã¡ãã¼ã£ã¦ãªã£ã¦ãã¾ãããäºå¾åå¸ã¯ãã·ãã¦ãªã£ã¦ããã®ãè¯ãã§ããï¼ã¯ï¼ï¼
ãã®ä»
äºå¾åå¸ã解æçã«æ±ã¾ããªãå®è£ ãç°¡åã§ããã次ã¯4ç« ã®æ··åã¢ãã«ã¨è¿ä¼¼æ¨è«ã«ã¤ãã¦å®è£ ãã¦ããã¾ã