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

北京怀柔做网站管理运营的公司主流网站开发

北京怀柔做网站管理运营的公司,主流网站开发,南宁网站建设怎样建立一个好网站,网站安全管理机制建设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://www.yayakq.cn/news/67988/

相关文章:

  • 网站制作公司网站建设公司洛可可工业设计公司
  • 子网站建设工作怎样在网上推广
  • 泗洪网站建设公司深圳建设交易信息网站
  • 做点小本意 哪个网站拿货便宜点怎样在赶集微网站做微招聘
  • 网站制作公司优势旅游网站设计代码模板
  • 蓝色经典通用网站模板目前网站建设用哪种语言
  • 中卫市建设局网站 冯进强互联网设计师
  • asp婚纱摄影网站源码定边网站建设
  • 学校网站建设报价表wordpress 开发版 视频
  • 企业公司关键词排名优化江苏的团队
  • 网站404网页界面psd源文件模板成都网站建设 今网科技
  • 山东省住房城乡建设厅网站首页wordpress获取分类id
  • 网站建设 目的 意义 政策如何用c语言做钓鱼网站
  • 网站建设及维护机wordpress 中文文档下载
  • 延安市住建建设网站建设银行电商网站
  • 网站开发的感想网站系统使用说明书
  • 衡水做淘宝网站权重域名做网站有用么
  • 常德网站建设 天维网站推广工作流程图
  • 网站建设 sam大叔排名三天上首页品牌商城网站开发
  • 烟台响应式网站建设天津市建设教育培训中心网站
  • 做毕业设计的网站长沙专业外贸网站建设
  • 网站建设从入门到精通pdf平台公司的定义
  • 长沙好的网站优化品牌黄骅贴吧超市转租信息
  • 电子商务的网站建设要求步骤最便宜做个网站多少钱
  • 网站设计的网站网站建设中心怎么做
  • 怎么做网站数据库校园网站建设需要哪些
  • dede门户网站模板下载东莞网站建设知名公司排名
  • 大型门户网站系统网站开发都需要哪些图
  • 建设网站注意如何快速推广一个新产品
  • 集团网站cms网站建设前端岗位职责