<jupyter_start><jupyter_text>作業目前已經學過許多的模型，相信大家對整體流程應該比較掌握了，這次作業請改用**手寫辨識資料集**，步驟流程都是一樣的，請試著自己撰寫程式碼來完成所有步驟<jupyter_code>from sklearn import linear_model, datasets, metrics
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.model_selection import train_test_split
# 載入digits的資料
digits = datasets.load_digits()

# 拆分資料
train_X, test_X, train_y, test_y = train_test_split(digits.data, digits.target, test_size=0.25, random_state=4)

# 建立模型
clf = GradientBoostingClassifier(learning_rate=0.2, max_depth=2, n_estimators=150, 
                                 min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.2)

# 擬合數據
clf.fit(train_X, train_y)

# 預測結果
pred = clf.predict(test_X)
acc = metrics.accuracy_score(test_y, pred)
print('準確率為：%.3f' %(acc))<jupyter_output>準確率為：0.976
{'fraction_non_alphanumeric': 0.10421836228287841, 'fraction_numerical': 0.02357320099255583, 'mean_word_length': 6.613207547169812, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '116870', 'license': 'Apache-2.0', 'n_tokens_mistral': 414, 'n_tokens_neox': 434, 'n_words': 45, 'path': 'HomeWork/Day_046_HW.ipynb', 'repo_name': 'rugl/3rd-ML100Days', 'size': '806'}