ð決å®æšã«ããããããŒã¹ãã£ã³ã°ãšãã®ã³ã°ã®éãã«ã€ããŠæããŠãã ãã
決å®æšã«ãããããŒã¹ãã£ã³ã°ãšãã®ã³ã°ã¯ãã©ã¡ããã¢ã³ãµã³ãã«åŠç¿ã®äžçš®ã§ãè€æ°ã®ã¢ãã«ãçµã¿åãããããšã§äºæž¬ã®æ§èœãåäžãããææ³ã§ããããã®ã¢ãããŒãã«ã¯å€§ããªéãããããŸãã
ãã®ã³ã°
å šäœæŠå¿µ: ãã®ã³ã°ïŒBootstrap Aggregatingã®ç¥ïŒã¯ãè€æ°ã®ã¢ãã«ïŒæ±ºå®æšãªã©ïŒãç¬ç«ã«èšç·Žãããã®äºæž¬çµæã®å¹³åïŒååž°ã®å ŽåïŒãå€æ°æ±ºïŒåé¡ã®å ŽåïŒãåãããšã§æçµçãªäºæž¬ãè¡ããŸãã
ããŒã¿ã®åãæ±ã: åã¢ãã«ã¯ãå ã®èšç·ŽããŒã¿ã»ããããããŒãã¹ãã©ããïŒã©ã³ãã ã«éè€ãèš±ããŠãµã³ããªã³ã°ïŒãããããŒã¿ã»ããã䜿çšããŠèšç·ŽãããŸãã
ç®ç: ãã®ã³ã°ã¯ãã¢ãã«ã®ããªã¢ã³ã¹ïŒéå°é©åïŒãæžããããšãç®çãšããŠããŸãã
代衚çãªã¢ã«ãŽãªãºã : ã©ã³ãã ãã©ã¬ã¹ãããã®ã³ã°ã®ä»£è¡šçãªäŸã§ãã
ããŒã¹ãã£ã³ã°
å šäœæŠå¿µ: ããŒã¹ãã£ã³ã°ã¯ãè€æ°ã®åŒ±åŠç¿åšïŒåºæ¬çã«ã¯æ§èœãäœãã¢ãã«ïŒãé çªã«èšç·ŽããŠããã誀ããä¿®æ£ããªããæçµçãªåŒ·åŠç¿åšãæ§ç¯ããææ³ã§ãã
ããŒã¿ã®åãæ±ã: å匱åŠç¿åšã®èšç·Žã§ã¯ãåã®åŠç¿åšã誀ã£ãŠåé¡ããããŒã¿ã«å¯ŸããŠã次ã®åŠç¿åšã¯ããéç¹ã眮ããŠåŠç¿ããŸããã€ãŸãã誀åé¡ãããããŒã¿ã®éã¿ãå¢ãããŠãããŸãã
ç®ç: ããŒã¹ãã£ã³ã°ã¯ãã¢ãã«ã®ãã€ã¢ã¹ïŒæªåŠç¿ïŒãæžãããäºæž¬ã®ç²ŸåºŠãåäžãããããšãç®çãšããŠããŸãã
代衚çãªã¢ã«ãŽãªãºã : AdaBoostïŒAdaptive BoostingïŒãGradient BoostingããããŸãã
ãŸãšã
ãã®ã³ã°ã¯ãè€æ°ã®ç¬ç«ããã¢ãã«ãå¹³è¡ããŠèšç·Žãããã®çµæãçµã¿åãããããšã§ã¢ãã«ã®ããªã¢ã³ã¹ãäœæžããŸããããã«ãããéå°é©åãé²ããŸãã
ããŒã¹ãã£ã³ã°ã¯ãè€æ°ã®ã¢ãã«ãé çªã«èšç·Žããåã®ã¢ãã«ã®èª€ãã次ã®ã¢ãã«ãä¿®æ£ãã圢ã§ãã¢ãã«ã®ãã€ã¢ã¹ãäœæžããŸããããã«ãããæªåŠç¿ã®åé¡ãæ¹åããŸãã
ã©ã¡ãã®ææ³ãããããã®ã·ããªãªã«å¿ããŠæå¹ã§ããã䜿çšããããŒã¿ã解決ããããšããåé¡ã«å¿ããŠéžæãããŸãã
import random
# èšç·ŽããŒã¿ã»ãã
training_data = [...]
# ã¢ãã«ã®éå
models = []
# ã¢ãã«ã®æ°
n_models = 10
# ãã®ã³ã°ã«ããã¢ãã«ã®èšç·Ž
for i in range(n_models):
# ããŒãã¹ãã©ãããµã³ããªã³ã°ïŒããŒã¿ã®ã©ã³ãã éžæïŒ
sample_data = random.choices(training_data, k=len(training_data))
model = train_model(sample_data)
models.append(model)
# æ°ããããŒã¿ã«å¯Ÿããäºæž¬
new_data = [...]
predictions = [model.predict(new_data) for model in models]
# äºæž¬ã®å¹³åãŸãã¯å€æ°æ±ºãåã
final_prediction = majority_vote(predictions) # åé¡ã®å Žå
# final_prediction = mean(predictions) # ååž°ã®å Žå
# èšç·ŽããŒã¿ã»ãã
training_data = [...]
weights = [1/len(training_data)] * len(training_data) # åããŒã¿ãã€ã³ãã®éã¿
# ã¢ãã«ã®éå
models = []
# ã¢ãã«ã®éã¿
model_weights = []
# ã¢ãã«ã®æ°
n_models = 10
# ããŒã¹ãã£ã³ã°ã«ããã¢ãã«ã®èšç·Ž
for i in range(n_models):
model, error = train_model_with_weights(training_data, weights)
models.append(model)
# ã¢ãã«ã®éã¿ãèšç®ïŒäœããšã©ãŒã»ã©é«ãéã¿ïŒ
model_weight = calculate_model_weight(error)
model_weights.append(model_weight)
# ããŒã¿ã®éã¿ã®æŽæ°
weights = update_weights(weights, model, model_weight, training_data)
# æ°ããããŒã¿ã«å¯Ÿããäºæž²
new_data = [...]
predictions = [model.predict(new_data) for model in models]
# å éå¹³åãŸãã¯å éæ祚ã«ããæçµäºæž¬
final_prediction = weighted_vote(predictions, model_weights)
ãããã®æ¬äŒŒã³ãŒãã¯ããã®ã³ã°ãšããŒã¹ãã£ã³ã°ã®åºæ¬çãªæŠå¿µã瀺ããŠããŸãããã®ã³ã°ã§ã¯ãããŒã¿ã®ã©ã³ãã ãªãµãã»ããã䜿çšããŠè€æ°ã®ã¢ãã«ãç¬ç«ã«èšç·Žãããã®äºæž¬ãçµã¿åãããŸããäžæ¹ãããŒã¹ãã£ã³ã°ã§ã¯ãäžé£ã®ã¢ãã«ãé次çã«èšç·Žããåã¹ãããã§åã®ã¢ãã«ã®èª€ããä¿®æ£ããããšã«éç¹ã眮ããŸã