当前位置: 首页 > wzjs >正文

济南 网站建设那家好长春餐饮网站建设

济南 网站建设那家好,长春餐饮网站建设,课件模板下载免费,四川学校网站建设pytorch笔记篇:pandas之数据预处理 pytorch笔记篇:pandas之数据预处理(更新中)测试例代码相关的算子 pytorch笔记篇:pandas之数据预处理(更新中) 测试例代码 print(train_data.iloc[0:4, [0, 1, 2, 3, -3, -2, -1]]) # (※1) 为什么test_da…

pytorch笔记篇:pandas之数据预处理

  • pytorch笔记篇:pandas之数据预处理(更新中)
    • 测试例代码
    • 相关的算子

pytorch笔记篇:pandas之数据预处理(更新中)

测试例代码

print(train_data.iloc[0:4, [0, 1, 2, 3, -3, -2, -1]])
# (1) 为什么test_data的列最后不是-1,是因为test_data没有价格这个列项
all_features = pd.concat((train_data.iloc[:, 1:-1], test_data.iloc[:, 1:]))
print('-----------------------------------------------')
print(all_features.iloc[0:4, [0, 1, 2, 3, -3, -2, -1]])# (2) 获取到不是数值的列index]
numeric_features = all_features.dtypes[all_features.dtypes != 'object'].index# print('++++++++++++++++++++++++')
# (3) print(all_features[numeric_features].iloc[0:3, [0,1,2,3,-3,-2,-1]])
# print('----------------------')
all_features[numeric_features] = all_features[numeric_features].apply(lambda x: (x - x.mean()) / (x.std()))
# print(all_features[numeric_features].iloc[0:3, [0,1,2,3,-3,-2,-1]])
# input()# (4) 在标准化数据之后,所有均值消失,因此我们可以将缺失值设置为0
all_features[numeric_features] = all_features[numeric_features].fillna(0)# (5) dummies & pd to tensor
print('++++++++++  demo test dummies  +++++++++++')
test = pd.DataFrame({'“x”':[1,2,3,4,5, 6], "seasion":['here', 'over', '', 'next', '', 'here']})
print(test)
print('-------------------------------')
test = pd.get_dummies(test, dummy_na=True)
print(test)
test = test*1
print(test)
print('++++++++++  test trans to tensor  +++++++++++')
# test1 = torch.tensor(test)
# 全部转化
test1 = torch.tensor(test.values, dtype=torch.float32)
print(test1.shape)
print(test1)
print('-------------------------------')
# 不用iloc的话就是光是行处理
test2 = torch.tensor(test[:3].values, dtype=torch.float32)
print(test2.shape)
print(test2)
print('-------------------------------')
# 特定行列转化需要熟练运动iloc
test3 = torch.tensor(test.iloc[:2, :-1].values, dtype=torch.float32)
print(test3.shape)
print(test3)
input()output-begin:
(1460, 81)
(1459, 80)Id  MSSubClass MSZoning  LotFrontage SaleType SaleCondition  SalePrice
0   1          60       RL         65.0       WD        Normal     208500
1   2          20       RL         80.0       WD        Normal     181500
2   3          60       RL         68.0       WD        Normal     223500
3   4          70       RL         60.0       WD       Abnorml     140000
-----------------------------------------------MSSubClass MSZoning  LotFrontage  LotArea  YrSold SaleType SaleCondition
0          60       RL         65.0     8450    2008       WD        Normal
1          20       RL         80.0     9600    2007       WD        Normal
2          60       RL         68.0    11250    2008       WD        Normal
3          70       RL         60.0     9550    2006       WD       Abnorml
++++++++++  demo test dummies  +++++++++++“x” seasion
0    1    here
1    2    over
2    3        
3    4    next
4    5        
5    6    here
-------------------------------“x”  seasion_  seasion_here  seasion_next  seasion_over  seasion_nan
0    1     False          True         False         False        False
1    2     False         False         False          True        False
2    3      True         False         False         False        False
3    4     False         False          True         False        False
4    5      True         False         False         False        False
5    6     False          True         False         False        False“x”  seasion_  seasion_here  seasion_next  seasion_over  seasion_nan
0    1         0             1             0             0            0
1    2         0             0             0             1            0
2    3         1             0             0             0            0
3    4         0             0             1             0            0
4    5         1             0             0             0            0
5    6         0             1             0             0            0
++++++++++  test trans to tensor  +++++++++++
torch.Size([6, 6])
tensor([[1., 0., 1., 0., 0., 0.],[2., 0., 0., 0., 1., 0.],[3., 1., 0., 0., 0., 0.],[4., 0., 0., 1., 0., 0.],[5., 1., 0., 0., 0., 0.],[6., 0., 1., 0., 0., 0.]])
-------------------------------
torch.Size([3, 6])
tensor([[1., 0., 1., 0., 0., 0.],[2., 0., 0., 0., 1., 0.],[3., 1., 0., 0., 0., 0.]])
-------------------------------
torch.Size([2, 5])
tensor([[1., 0., 1., 0., 0.],[2., 0., 0., 0., 1.]])
output-end

相关的算子

concat — 合并.
iloc — 筛选行列.
apply — 处理列数据.
fillna — 填补数值空缺.
get_dummies — 独热编码(自行测试显示)

PS: 略。


文章转载自:

http://1oP6783C.Lbrrn.cn
http://fvsIYWR4.Lbrrn.cn
http://gOEkKBAv.Lbrrn.cn
http://ANjuw1cn.Lbrrn.cn
http://vaz67IbV.Lbrrn.cn
http://KPEdnRiY.Lbrrn.cn
http://tmuPYD2d.Lbrrn.cn
http://SKfyn5rW.Lbrrn.cn
http://dXTcNUgP.Lbrrn.cn
http://YXADmD6h.Lbrrn.cn
http://ceHAsmFj.Lbrrn.cn
http://q7wVfypa.Lbrrn.cn
http://XftdMxCw.Lbrrn.cn
http://9bK0LZrn.Lbrrn.cn
http://WMwD4bW3.Lbrrn.cn
http://wiT1fk77.Lbrrn.cn
http://Jccg95si.Lbrrn.cn
http://96L1cZ7v.Lbrrn.cn
http://ni5bYLn0.Lbrrn.cn
http://VqgR4eDu.Lbrrn.cn
http://kFhwrTjy.Lbrrn.cn
http://MDdGVY5J.Lbrrn.cn
http://AinjOzdB.Lbrrn.cn
http://ky8nap2M.Lbrrn.cn
http://JDpEFhOX.Lbrrn.cn
http://DJHFehgV.Lbrrn.cn
http://xJZZrCqC.Lbrrn.cn
http://rKcNuyUm.Lbrrn.cn
http://xwzP5QaB.Lbrrn.cn
http://okJXead9.Lbrrn.cn
http://www.dtcms.com/wzjs/708278.html

相关文章:

  • 那个网站做代买贵州省建设厅建筑质监站网站
  • 网站改版收录减少深圳网站系统哪家强
  • 四平网站建设哪家效果好自己的网站怎么建立
  • 怎么做班级网站企业管理软件定制开发
  • 一篇关于大学网站建设与管理的论文电话投放小网站
  • 买个域名就可以建立网站吗企业网站关键词放几个
  • 图书网站建设策划书1万字qq空间注册申请
  • 关于网站建设的参考文献设计公司品牌企业
  • 织梦网站首页文字修改松原网站开发
  • 凡科建站免费版可以做什么网站建设与研发
  • 营销型网站功能平面设计要什么学历
  • 万荣做网站合肥网站制作哪家有名
  • 太原建站公司有哪些syntaxhighlighter wordpress
  • wordpress 微商城模板下载地址燕郊seo
  • 广州模板建站多少钱毕节市网站建设58同城
  • 山东网站开发网络公司app手机网站
  • 山东网站备案拍照营销型网站管理方案
  • 从写代码到网站运行不了了网站嵌入视频代码
  • 自动化设备东莞网站建设网站搭建学什么软件
  • 广东省建设厅网站ps怎么做网站一寸的照片
  • 什么是速成网站网站建设定金合同范本
  • 网站备案接入商名称wordpress托管在哪里
  • 有做公司网站的吗适合大学生浏览的网站
  • 宁波商城网站建设做网站 除了域名
  • 天津做公司网站wordpress超cpu
  • 丹阳市网站制作网络营销外包收费吗
  • 河南网站建设哪里有上海seo网站
  • 旅游网站建设的方法怎么能创建自己的网站
  • 烟台工程建设信息网站网络公司注册多少钱
  • 网站被清空了怎么办做文创的网站