备忘记录

上传代码到Git

1
2
3
git add .        (注:别忘记后面的.,此操作是把Test文件夹下面的文件都添加进来)
git commit -m "提交信息" (注:“提交信息”里面换成你需要,如“first commit”)
git push -u origin master (注:此操作目的是把本地仓库push到github上面,此步骤需要你输入帐号和密码)

读取类数据

1
2
3
4
5
6
data = pd['typeA']
data = pd.typeA
class = ['typeA','typeB','typeC']
data = pd[class] %% 多个
data.describe() %% 描述数据的统计特性
data.head() %% 列出前几个

提交比赛答案

1
2
3
my_submission = pd.DataFrame({'Id': test.Id, 'SalePrice': predicted_prices})
# you could use any filename. We choose submission here
my_submission.to_csv('submission.csv', index=False)

字典用法 巧用key

1
2
3
4
5
candidate = [5, 25, 50, 100, 200] 
scores = {leaf_size: get_mae(leaf_size, train_X, val_X, train_y, val_y) for leaf_size in candidate}
## 这里直接把leaf_size 当作key
best_tree_size = min(scores, key=scores.get)
plt.plot(scores.keys(),scores.values())