task2 EDA探索性数据分析
程序员文章站
2024-03-07 17:50:33
...
赛题以预测二手车的交易价格为任务,数据集报名后可见并可下载,该数据来自某交易平台的二手车交易记录,总数据量超过40w,包含31列变量信息,其中15列为匿名变量。为了保证比赛的公平性,将会从中抽取15万条作为训练集,5万条作为测试集A,5万条作为测试集B,同时会对name、model、brand和regionCode等信息进行脱敏
2、评测标准
评价标准为MAE(Mean Absolute Error)。
MAE越小,说明模型预测得越准确。
赛事官网:
零基础入门数据挖掘 - 二手车交易价格预测
3、具体步骤
3.1、环境:pycharm + python3
3.2、读取数据
下面展示一些 内联代码片
。
// An highlighted block
var foo = 'bar';
#读取数据并#切分数据
dataset = pd.read_csv(r'C:\python3\envs\pytorch\atest_torch\data\used_car_train_20200313.csv', sep=' ')
# print(dataset)
# print(dataset.columns.values)
X = dataset[['SaleID', 'name', 'regDate', 'model', 'brand', 'bodyType', 'fuelType', 'gearbox', 'power', 'kilometer',
'notRepairedDamage', 'regionCode', 'seller', 'offerType', 'creatDate', 'v_0', 'v_1', 'v_2',
'v_3', 'v_4', 'v_5', 'v_6', 'v_7', 'v_8', 'v_9', 'v_10', 'v_11', 'v_12', 'v_13', 'v_14']]
Y = dataset['price']
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
#需要注意:因为该csv文件数据是按一个空格隔开的,在读取时需要用sep=’ '来分割开来。
3.2.2查看各列数据类型
#查看各列数据类型
print([X[column].dtypes for column in X])
- 1
- 2
发现notRepairedDamage数据存在异常,该特征为汽车有尚未修复的损坏:是:0,否:1。
我将“-”进行缺失值处理,赋值为0.5
更新时间:2020年3月17日
3.3拆分数据集与测试集
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33, random_state=7)
- 1
3.4xgboost构建模型
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
<div class="more-toolbox">
<div class="left-toolbox">
<ul class="toolbox-list">
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count"></span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{"mod":"1582594662_002"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/zxxmx">
<img src="https://profile.csdnimg.cn/D/A/8/3_zxxmx" class="avatar_pic" username="zxxmx">
<img src="https://g.csdnimg.cn/static/user-reg-year/1x/2.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/zxxmx" data-report-click="{"mod":"popu_379"}" target="_blank">zxxmx</a></span>
</div>
<div class="text"><span>发布了1 篇原创文章</span> · <span>获赞 0</span> · <span>访问量 105</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=zxxmx" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>
上一篇: PHP编辑器PhpStrom运行缓慢问题
下一篇: Asp.Net中的三种分页方式总结