Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a26546593
dive-into-dl-pytorch
提交
aa75893a
D
dive-into-dl-pytorch
项目概览
a26546593
/
dive-into-dl-pytorch
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dive-into-dl-pytorch
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa75893a
编写于
11月 07, 2019
作者:
S
ShusenTang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug(#46) in feature preprocessing
上级
62bee2ff
变更
3
展开全部
显示空白变更内容
内联
并排
Showing
3 changed file
with
1828 addition
and
368 deletion
+1828
-368
code/chapter03_DL-basics/3.16_kaggle-house-price.ipynb
code/chapter03_DL-basics/3.16_kaggle-house-price.ipynb
+363
-363
code/chapter03_DL-basics/submission.csv
code/chapter03_DL-basics/submission.csv
+1460
-0
docs/chapter03_DL-basics/3.16_kaggle-house-price.md
docs/chapter03_DL-basics/3.16_kaggle-house-price.md
+5
-5
未找到文件。
code/chapter03_DL-basics/3.16_kaggle-house-price.ipynb
浏览文件 @
aa75893a
此差异已折叠。
点击以展开。
code/chapter03_DL-basics/submission.csv
0 → 100644
浏览文件 @
aa75893a
此差异已折叠。
点击以展开。
docs/chapter03_DL-basics/3.16_kaggle-house-price.md
浏览文件 @
aa75893a
...
...
@@ -83,8 +83,8 @@ all_features = pd.concat((train_data.iloc[:, 1:-1], test_data.iloc[:, 1:]))
numeric_features
=
all_features
.
dtypes
[
all_features
.
dtypes
!=
'object'
].
index
all_features
[
numeric_features
]
=
all_features
[
numeric_features
].
apply
(
lambda
x
:
(
x
-
x
.
mean
())
/
(
x
.
std
()))
# 标准化后,每个特征的均值变为0,所以可以直接用0来替换缺失值
all_features
=
all_features
.
fillna
(
0
)
# 标准化后,每个
数值
特征的均值变为0,所以可以直接用0来替换缺失值
all_features
[
numeric_features
]
=
all_features
[
numeric_features
]
.
fillna
(
0
)
```
接下来将离散数值转成指示特征。举个例子,假设特征MSZoning里面有两个不同的离散值RL和RM,那么这一步转换将去掉MSZoning特征,并新加两个特征MSZoning
\_
RL和MSZoning
\_
RM,其值为0或1。如果一个样本原来在MSZoning里的值为RL,那么有MSZoning
\_
RL=1且MSZoning
\_
RM=0。
...
...
@@ -92,12 +92,12 @@ all_features = all_features.fillna(0)
```
python
# dummy_na=True将缺失值也当作合法的特征值并为其创建指示特征
all_features
=
pd
.
get_dummies
(
all_features
,
dummy_na
=
True
)
all_features
.
shape
# (2919, 3
54
)
all_features
.
shape
# (2919, 3
31
)
```
可以看到这一步转换将特征数从79增加到了3
54
。
可以看到这一步转换将特征数从79增加到了3
31
。
最后,通过
`values`
属性得到NumPy格式的数据,并转成
`
NDArray
`
方便后面的训练。
最后,通过
`values`
属性得到NumPy格式的数据,并转成
`
Tensor
`
方便后面的训练。
```
python
n_train
=
train_data
.
shape
[
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录