task2 EDA探索性数据分析
生活随笔
收集整理的這篇文章主要介紹了
task2 EDA探索性数据分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、賽題數據
賽題以預測二手車的交易價格為任務,數據集報名后可見并可下載,該數據來自某交易平臺的二手車交易記錄,總數據量超過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>總結
以上是生活随笔為你收集整理的task2 EDA探索性数据分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: H5页面适配iOS、Android和微信
- 下一篇: 前端插件——Bootstrap Dual