💁 新人博主,多多支持
👋 本文由 EasyAI 原创,首发于 CSDN🙉
⌚️ 欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正!
😎未来很长,值得我们全力奔赴更美好的生活✋
了解如何在 PyTorch 中构建完整的深度学习管道
介绍
近期国际油价油价飞涨,国内成品油零售价格也将再创新高,当你抬头看的油价时候,你有没有注意到在网上,您的汽车从 A 点到 B 点应该花多少油费,这些数字几乎与现实不符?
在本文中,我想开发一个简单的模型,该模型可以预测汽车的效率(或消耗),以单加仑 (MPG) 行驶的英里数来衡量。
这些都将使用 PyTorch 在 Python 中完成。
数据集
我们将在这个项目中使用的数据集是一个里程碑式的数据集,来自 UCI 存储库的 Auto MPG 数据集。它由 9 个特征组成,包含 398 条记录。具体而言,变量名称及其类型如下:
- mpg: continuous
- cylinders: multi-valued discrete
- displacement: continuous
- horsepower: continuous
- weight: continuous
- acceleration: continuous
- model year: multi-valued discrete
- origin: multi-valued discrete
- car name: string (unique for each instance)
开始
首先,我们加载数据集并适当地重命名列,na_values 属性用于让pandas识别‘?’类型的数据应该被视为null。
import pandas as pd
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data'
col_names = ['MPG','Cylinders','Displacement','Horsepower','Weight','Acceleration','Model_Year','Origin']
df = pd.read_csv(url, names = col_names, na_values = '?', comment = '\t', sep = ' ', skipinitialspace = True)
现在使用 df.head() 显示数据集。
index | MPG | Cylinders | Displacement | Horsepower | Weight | Acceleration | Model_Year | Origin |
---|---|---|---|---|---|---|---|---|
0 | 18.0 | 8 | 307.0 | 130.0 | 3504.0 | 12.0 | 70 | 1 |
1 | 15.0 | 8 | 350.0 | 165.0 | 3693.0 | 11.5 | 70 | 1 |
2 | 18.0 | 8 | 318.0 | 150.0 | 3436.0 | 11.0 | 70 | 1 |
3 | 16.0 | 8 | 304.0 | 150.0 | 3433.0 | 12.0 | 70 | 1 |
4 | 17.0 | 8 | 302.0 |