ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选+数据降内)利用算法实现二手汽车产品交易价格回归预测之详细攻略

本文主要是介绍ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选+数据降内)利用算法实现二手汽车产品交易价格回归预测之详细攻略,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选+数据降内)利用算法实现二手汽车产品交易价格回归预测之详细攻略

目录

二手汽车产品交易价格预测

赛题背景

字段说明

通过数据预处理利用LightGBM算法实现二手汽车产品交易价格回归预测

# 一、定义数据集

# 1.1、载入训练集和测试集

# 1.2、简略观察数据

# 1.3、分离特征与标签

# 1.4、合并训练集、测试集(标记数据来源):以便同步各种操作(特征处理、构造特征等)

# 1.5、划分特征类型

# B1.7、纠正字段数据类型

# B1.8、纠正后重新统计

# T1.1、统计每个【类别型】特征的子分类

# T1.2、统计每个【类别型】特征的多样性

# 二、特征工程/数据集预处理

# 2.1、缺失值分析与处理

# 2.1.1、缺失值统计分析

# T1、所有特征样本个数(非空数值)柱状图可视化

# T2、仅缺失值的特征空值占比柱状图可视化

# 2.1.2、缺失值填充处理

# T1、两大类型数据缺失值填充

# 2.2、异常值分析与处理

# 2.2.2、异常值的处理

# T2、基于3-Sigma标准差的删除异常样本点+箱线图对比可视化

# T3、对异常值执行截断处理:只针对异常值,截断阈值要具体看分布

# 2.3、特殊值的分析与处理

# T1、将某字段的特殊字符替换填充

# 2.4、特殊字段的分析与处理

# 2.4.1、寻找严重失衡/倾斜分布的字段

# 2.5、变量分布的分析与处理

# 2.5.1、统计并可视化所有变量的偏态skew、峰态kurt

 # 2.5.2、【数字型】特征的长尾分布转为正态分布

# 2.6、目标变量的分析与处理

# 2.6.1、查看目标变量的分布

# 2.6.2、计算目标变量的skew、kurt

# 2.6.3、目标变量分布log变换

# 2.7、【类别型】特征分析

# 2.7.1、各个特征的丰富度统计及其可视化

# 2.7.2、各个特征的与目标变量的柱形图/箱形图/小提琴图可视化

# 2.8、【数字型】特征分析与处理

# 2.8.1、【数字型】特征分布性可视化

# 2.8.2、【数字型】特征相关性分析

# T1、【数字型】特征间的PCC热图可视化

# T3、【数字型】特征间的散点图可视化

# 2.9、构造特征

# 2.10、数据规范化

 # 2.11、定义入模特征

# 2.11.1、删除特征

# 2.11.2、特征筛选

# T2、包裹式wrapper

# T3、嵌入式Embedded(最常用)

# 2.12、导出入模数据集

三、模型训练与验证

ML之R:通过数据预处理利用LiR/XGBoost等(特征重要性/交叉训练曲线可视化/线性和非线性算法对比/三种模型调参/三种模型融合)实现二手汽车产品交易价格回归预测之详细攻略


相关文章
ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选)利用算法实现二手汽车产品交易价格回归预测之详细攻略
ML之R:通过数据预处理利用LiR/XGBoost等(特征重要性/交叉训练曲线可视化/线性和非线性算法对比/三种模型调参/三种模型融合)实现二手汽车产品交易价格回归预测之详细攻略
ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选)利用算法实现二手汽车产品交易价格回归预测代码实现

二手汽车产品交易价格预测

官网地址:零基础入门数据挖掘 - 二手车交易价格预测_学习赛_赛题与数据_天池大赛-阿里云天池

赛题背景

赛题以二手车市场为背景,要求选手预测二手汽车的交易价格。

字段说明

该数据来自某交易平台的二手车交易记录,总数据量超过40w,包含31列变量信息,其中15列为匿名变量。为了保证比赛的公平性,将会从中抽取15万条作为训练集,5万条作为测试集A,5万条作为测试集B,同时会对name、model、brand和regionCode等信息进行脱敏。

Field

Description

SaleID

交易ID,唯一编码

name

汽车交易名称,已脱敏

汽车编码

regDate

汽车注册日期,例如20160101,2016年01月01日

model

车型编码,已脱敏

brand

汽车品牌,已脱敏

bodyType

车身类型:豪华轿车:0,微型车:1,厢型车:2,大巴车:3,敞篷车:4,双门汽车:5,商务车:6,搅拌车:7

fuelType

燃油类型:汽油:0,柴油:1,液化石油气:2,天然气:3,混合动力:4,其他:5,电动:6

gearbox

变速箱:手动:0,自动:1

power

发动机功率:范围 [ 0, 600 ]

kilometer

汽车已行驶公里,单位万km

notRepairedDamage

汽车有尚未修复的损坏:是:0,否:1

regionCode

地区编码,已脱敏

seller

销售方:个体:0,非个体:1

offerType

报价类型:提供:0,请求:1

creatDate

汽车上线时间,即开始售卖时间

price

二手车交易价格(预测目标)

v系列特征

匿名特征,包含v0-14在内15个匿名特征

通过数据预处理利用LightGBM算法实现二手汽车产品交易价格回归预测

# 一、定义数据集

# 1.1、载入训练集和测试集

SaleIDnameregDatemodelbrandbodyTypefuelTypegearboxpowerkilometernotRepairedDamageregionCodesellerofferTypecreatDatepricev_0v_1v_2v_3v_4v_5v_6v_7v_8v_9v_10v_11v_12v_13v_14
0736200404023061006012.5010460020160404185043.357796313.9663441660.0502570942.1597440941.1437861870.2356759070.1019882410.1295486610.0228163670.097461829-2.8818032392.804096771-2.4208207930.7952919430.9147625
1226220030301401200015-43660020160309360045.305273025.2361118980.1379253241.38065746-1.4221649210.2647772560.1210035940.1357307070.0265974480.020581663-4.9004818822.096337644-1.030482837-1.7226737750.245522411
214874200404031151510016312.5028060020160402622245.978359064.8237922151.319524152-0.998467274-0.9969110350.2514101480.1149122770.1651474930.0621728370.027074824-4.846749261.8035589411.565329625-0.832687327-0.229962856
37186519960908109100011931504340020160312240045.68747824.492574134-0.0506158430.883599671-2.2280787250.2742931710.1103000850.1219637460.0333945470-4.5095988241.285939744-0.501867908-2.438352737-0.478699379
4111080201201031105100685069770020160313520044.383510842.0314332580.572168948-1.5712390282.2460883250.2280356220.0732050540.0918804790.0788193850.121534241-1.8962402790.9107831340.9311095592.834517821.923481963

# 1.2、简略观察数据

RangeIndex: 150000 entries, 0 to 149999
Data columns (total 31 columns):#   Column             Non-Null Count   Dtype  
---  ------             --------------   -----  0   SaleID             150000 non-null  int64  1   name               150000 non-null  int64  2   regDate            150000 non-null  int64  3   model              149999 non-null  float644   brand              150000 non-null  int64  5   bodyType           145494 non-null  float646   fuelType           141320 non-null  float647   gearbox            144019 non-null  float648   power              150000 non-null  int64  9   kilometer          150000 non-null  float6410  notRepairedDamage  150000 non-null  object 11  regionCode         150000 non-null  int64  12  seller             150000 non-null  int64  13  offerType          150000 non-null  int64  14  creatDate          150000 non-null  int64  15  price              150000 non-null  int64  16  v_0                150000 non-null  float6417  v_1                150000 non-null  float6418  v_2                150000 non-null  float6419  v_3                150000 non-null  float6420  v_4                150000 non-null  float6421  v_5                150000 non-null  float6422  v_6                150000 non-null  float6423  v_7                150000 non-null  float6424  v_8                150000 non-null  float6425  v_9                150000 non-null  float6426  v_10               150000 non-null  float6427  v_11               150000 non-null  float6428  v_12               150000 non-null  float6429  v_13               150000 non-null  float6430  v_14               150000 non-null  float64
dtypes: float64(20), int64(10), object(1)
memory usage: 35.5+ MB
used_car.info: None
used_car.shape:     (150000, 31) 31 150000
used_car.columns: Index(['SaleID', 'name', 'regDate', 'model', 'brand', 'bodyType', 'fuelType','gearbox', 'power', 'kilometer', 'notRepairedDamage', 'regionCode','seller', 'offerType', 'creatDate', 'price', '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'],dtype='object')
used_car.dtypes:   float64    20
int64      10
object      1
dtype: int64
used_car.head: SaleID    name   regDate  model  ...      v_11      v_12      v_13      v_14
0            0     736  20040402   30.0  ...  2.804097 -2.420821  0.795292  0.914762
1            1    2262  20030301   40.0  ...  2.096338 -1.030483 -1.722674  0.245522
2            2   14874  20040403  115.0  ...  1.803559  1.565330 -0.832687 -0.229963
3            3   71865  19960908  109.0  ...  1.285940 -0.501868 -2.438353 -0.478699
4            4  111080  20120103  110.0  ...  0.910783  0.931110  2.834518  1.923482
149995  149995  163978  20000607  121.0  ... -2.983973  0.589167 -1.304370 -0.302592
149996  149996  184535  20091102  116.0  ... -2.774615  2.553994  0.924196 -0.272160
149997  149997  147587  20101003   60.0  ... -1.630677  2.290197  1.891922  0.414931
149998  149998   45907  20060312   34.0  ... -2.633719  1.414937  0.431981 -1.659014
149999  149999  177672  19990204   19.0  ... -3.179913  0.031724 -1.483350 -0.342674[10 rows x 31 columns]
SaleIDnameregDatemodelbrandbodyTypefuelTypegearboxpowerkilometerregionCodesellerofferTypecreatDatepricev_0v_1v_2v_3v_4v_5v_6v_7v_8v_9v_10v_11v_12v_13v_14
count150000150000150000149999150000145494141320144019150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000150000
mean74999.568349.1728720034170.5147.129020868.0527333331.7923694450.3758420610.224942542119.316546712.597162583.0772676.67E-06020160330.795923.32733344.40626753-0.0448091230.0807650580.0788334230.0178746150.2482035280.0449230040.1246924610.0581438550.061995895-0.0010002390.0090345430.0048125950.000312612-0.000688231
std43301.4145361103.8750953649.8792649.536039657.8649563411.7606395030.5486766230.417545932177.16841923.9195755321885.3632180.0025819890106.73280887501.9984772.4575479063.6418930182.9296179452.0265140361.1936613870.0458039710.0517427870.201409530.0291857560.0356919793.7723863943.2860712212.5174776761.2889876391.038685151
min00199100010000000.5000201506181130.45197649-4.295588903-4.47067143-7.275036707-4.36456524200000-9.16819241-5.558206704-9.639552114-4.153898796-6.546555965
25%37499.7511156199909121010007512.510180020160313130043.13579888-3.192349286-0.9706712-1.462580044-0.9211914840.2436153533.81E-050.0624735330.0353336870.033930177-3.72230288-1.951543007-1.871845761-1.057788984-0.437033668
50%74999.551638200309123061001101521960020160321325044.61026572-3.052671416-0.382946890.099721985-0.0759104290.2577979660.0008120590.0958658980.0570135980.0584836671.624076331-0.358052697-0.130753318-0.0362446040.141245993
75%112499.25118841.252007110966133101501538430020160329770046.00472094.0006697950.2413348521.5658382020.8687584350.2652972590.1020092980.1252429450.0793815710.0874905482.8443567761.2550216571.7769329490.9428130830.680378075
max14999919681220151212247397611931215812010201604079999952.304178267.32030837519.03549659.8547015346.829351640.2918381130.1514195961.4049363750.1607909850.22278748812.3570106218.8190424713.8477915211.147668618.658417877

# 1.3、分离特征与标签

# 1.4、合并训练集、测试集(标记数据来源):以便同步各种操作(特征处理、构造特征等)

# 1.5、划分特征类型

float64 20 ['model', 'bodyType', 'fuelType', 'gearbox', 'kilometer', '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']
int32 0 []
int64 10 ['SaleID', 'name', 'regDate', 'brand', 'power', 'regionCode', 'seller', 'offerType', 'creatDate', 'price']
object_category_bool 1 ['notRepairedDamage']
others 0 []

# B1.7、纠正字段数据类型

# B1.8、纠正后重新统计

# T1.1、统计每个【类别型】特征的子分类

字段回归正确数据类型:#   Column             Non-Null Count   Dtype  
---  ------             --------------   -----  0   SaleID             150000 non-null  int64  1   name               150000 non-null  int64  2   regDate            150000 non-null  int64  3   model              149999 non-null  object 4   brand              150000 non-null  object 5   bodyType           145494 non-null  object 6   fuelType           141320 non-null  object 7   gearbox            144019 non-null  object 8   power              150000 non-null  int64  9   kilometer          150000 non-null  float6410  notRepairedDamage  150000 non-null  object 11  regionCode         150000 non-null  int64  12  seller             150000 non-null  int64  13  offerType          150000 non-null  int64  14  creatDate          150000 non-null  int64  15  price              150000 non-null  int64  16  v_0                150000 non-null  float6417  v_1                150000 non-null  float6418  v_2                150000 non-null  float6419  v_3                150000 non-null  float6420  v_4                150000 non-null  float6421  v_5                150000 non-null  float6422  v_6                150000 non-null  float6423  v_7                150000 non-null  float6424  v_8                150000 non-null  float6425  v_9                150000 non-null  float6426  v_10               150000 non-null  float6427  v_11               150000 non-null  float6428  v_12               150000 non-null  float6429  v_13               150000 non-null  float6430  v_14               150000 non-null  float64
dtypes: float64(16), int64(9), object(6)
memory usage: 35.5+ MB

# T1.2、统计每个【类别型】特征的多样性

modelcountsbrandcountsbodyTypecountsfuelTypecountsgearboxcountsnotRepairedDamagecounts
01176203148004142009165601116230.0111361
199573416737135272146991132396-24324
48445141608923032422212null59811.014315
1603810142493134913262null0
295186113794496094118
48505261021757607545
4045029730666482636
2644965466571289null8680
84391133817null4506
313827112945
13376232461
17312172361
652730162223
49260882077
462454252064
302342272053
442195211547
52063151458
102004191388
211872201236
731789121109
111775221085
23169626966
22152430940
69152217913
63146924772
7146028649
16134932592
88130929406
66125037333
6011772321
67108431318
41107818316
104102036228
8796534227
11592733218
392023186
12181135180
327053865
77675399
98662null0
2471
null1

# 二、特征工程/数据集预处理

# 2.1、缺失值分析与处理

# 2.1.1、缺失值统计分析

# T1、所有特征样本个数(非空数值)柱状图可视化

# T2、仅缺失值的特征空值占比柱状图可视化

{'fuelType': 0.057866666666666663, 'gearbox': 0.03987333333333333, 'bodyType': 0.03004, 'model': 6.666666666666667e-06}

# 2.1.2、缺失值填充处理

# T1、两大类型数据缺失值填充

-------------------before fillna: 
 SaleID                  0
name                    0
regDate                 0
model                   1
brand                   0
bodyType             4506
fuelType             8680
gearbox              5981
power                   0
kilometer               0
notRepairedDamage       0
regionCode              0
seller                  0
offerType               0
creatDate               0
price                   0
v_0                     0
v_1                     0
v_2                     0
v_3                     0
v_4                     0
v_5                     0
v_6                     0
v_7                     0
v_8                     0
v_9                     0
v_10                    0
v_11                    0
v_12                    0
v_13                    0
v_14                    0
dtype: int64
-------------------after fillna: 
 SaleID               0
name                 0
regDate              0
model                0
brand                0
bodyType             0
fuelType             0
gearbox              0
power                0
kilometer            0
notRepairedDamage    0
regionCode           0
seller               0
offerType            0
creatDate            0
price                0
v_0                  0
v_1                  0
v_2                  0
v_3                  0
v_4                  0
v_5                  0
v_6                  0
v_7                  0
v_8                  0
v_9                  0
v_10                 0
v_11                 0
v_12                 0
v_13                 0
v_14                 0
dtype: int64
 

# 2.2、异常值分析与处理

# 2.2.2、异常值的处理

# T2、基于3-Sigma标准差的删除异常样本点+箱线图对比可视化

3-Sigma,Delete number is: 963
Now column number is: 149037
outliers_low: Description of data less than the lower bound is:
count    0.0
mean     NaN
std      NaN
min      NaN
25%      NaN
50%      NaN
75%      NaN
max      NaN
Name: power, dtype: float64
outliers_up: Description of data larger than the upper bound is:
count      963.000000
mean       846.836968
std       1929.418081
min        376.000000
25%        400.000000
50%        436.000000
75%        514.000000
max      19312.000000
Name: power, dtype: float64

# T3、对异常值执行截断处理:只针对异常值,截断阈值要具体看分布

# 2.3、特殊值的分析与处理

# T1、将某字段的特殊字符替换填充

df_train:0.0    135685
1.0     14315
Name: notRepairedDamage, dtype: int64

# 2.4、特殊字段的分析与处理

# 2.4.1、寻找严重失衡/倾斜分布的字段

seller 0    149999
1         1
Name: seller, dtype: int64
offerType 0    150000
Name: offerType, dtype: int64

# 2.5、变量分布的分析与处理

# 2.5.1、统计并可视化所有变量的偏态skew、峰态kurt

 # 2.5.2、【数字型】特征的长尾分布转为正态分布

# 2.6、目标变量的分析与处理

# 2.6.1、查看目标变量的分布

# 2.6.2、计算目标变量的skew、kurt

price Skewness:  3.3464867626369608
price Kurtosis:  18.995183355632562

# 2.6.3、目标变量分布log变换

# 2.7、【类别型】特征分析

# 2.7.1、各个特征的丰富度统计及其可视化

# 2.7.2、各个特征的与目标变量的柱形图/箱形图/小提琴图可视化

 

# 2.8、【数字型】特征分析与处理

# 2.8.1、【数字型】特征分布性可视化

# 2.8.2、【数字型】特征相关性分析

# T1、【数字型】特征间的PCC热图可视化

corr sort_values price         1.000000
v_12          0.692823
v_8           0.685798
v_0           0.628397
regDate       0.611959
power         0.219834
v_5           0.164317
v_2           0.085322
v_6           0.068970
v_1           0.060914
v_14          0.035911
regionCode    0.014036
creatDate     0.002955
name          0.002030
SaleID       -0.001043
seller       -0.002004
v_13         -0.013993
brand        -0.043799
v_7          -0.053024
v_4          -0.147085
v_9          -0.206205
v_10         -0.246175
v_11         -0.275320
kilometer    -0.440519
v_3          -0.730946
offerType          NaN
Name: price, dtype: float64

# T3、【数字型】特征间的散点图可视化

 

 

# 2.9、构造特征

Int64Index: 150000 entries, 0 to 149999
Data columns (total 41 columns):#   Column                  Non-Null Count   Dtype  
---  ------                  --------------   -----  0   SaleID                  150000 non-null  float641   name                    150000 non-null  float642   regDate                 150000 non-null  float643   model                   150000 non-null  int32  4   brand                   150000 non-null  float645   bodyType                150000 non-null  int32  6   fuelType                150000 non-null  int32  7   gearbox                 150000 non-null  int32  8   power                   150000 non-null  float649   kilometer               150000 non-null  float6410  notRepairedDamage       150000 non-null  int32  11  regionCode              150000 non-null  float6412  seller                  150000 non-null  float6413  offerType               150000 non-null  float6414  creatDate               150000 non-null  float6415  price                   150000 non-null  int64  16  v_0                     150000 non-null  float6417  v_1                     150000 non-null  float6418  v_2                     150000 non-null  float6419  v_3                     150000 non-null  float6420  v_4                     150000 non-null  float6421  v_5                     150000 non-null  float6422  v_6                     150000 non-null  float6423  v_7                     150000 non-null  float6424  v_8                     150000 non-null  float6425  v_9                     150000 non-null  float6426  v_10                    150000 non-null  float6427  v_11                    150000 non-null  float6428  v_12                    150000 non-null  float6429  v_13                    150000 non-null  float6430  v_14                    150000 non-null  float6431  city                    150000 non-null  int32  32  used_time               150000 non-null  float6433  brand_amount            150000 non-null  float6434  price_max_GBYbrand      150000 non-null  float6435  price_median_GBYbrand   150000 non-null  float6436  price_min_GBYbrand      150000 non-null  float6437  price_sum_GBYbrand      150000 non-null  float6438  price_std_GBYbrand      150000 non-null  float6439  price_average_GBYbrand  150000 non-null  float6440  power_bin               150000 non-null  float64

# 2.10、数据规范化

catcols2LabelEncoder: 7 ['model', 'bodyType', 'fuelType', 'gearbox', 'notRepairedDamage', 'city', 'power_bin']
LEDict {'model': {'0.0': 0, '1.0': 1, '10.0': 2, '100.0': 3, '101.0': 4, …… '93.0': 241, '94.0': 242, '95.0': 243, '96.0': 244, '97.0': 245, '98.0': 246, '99.0': 247, 'missing': 248}, 
'bodyType': {'0.0': 0, '1.0': 1, '2.0': 2, '3.0': 3, '4.0': 4, '5.0': 5, '6.0': 6, '7.0': 7, 'missing': 8}, 
'fuelType': {'0.0': 0, '1.0': 1, '2.0': 2, '3.0': 3, '4.0': 4, '5.0': 5, '6.0': 6, 'missing': 7}, 
'gearbox': {'0.0': 0, '1.0': 1, 'missing': 2}, 
'notRepairedDamage': {'0.0': 0, '1.0': 1}, 
'city': {'1': 0, '2': 1, '3': 2, '4': 3, '5': 4, '6': 5, '7': 6, '8': 7, 'missing': 8}, 
'power_bin': {'0.0': 0, '1.0': 1, '10.0': 2, '11.0': 3, '12.0': 4, '13.0': 5, '14.0': 6, '15.0': 7, '16.0': 8, '17.0': 9, '18.0': 10, '19.0': 11, '2.0': 12, '20.0': 13, '21.0': 14, '22.0': 15, '23.0': 16, '24.0': 17, '25.0': 18, '26.0': 19, '27.0': 20, '28.0': 21, '29.0': 22, '3.0': 23, '4.0': 24, '5.0': 25, '6.0': 26, '7.0': 27, '8.0': 28, '9.0': 29, 'missing': 30}}

after Encoder NoneSaleID      name  ...  price_average_GBYbrand  power_bin
0       0.000000  0.003740  ...                0.073848          0
1       0.000007  0.011493  ...                0.234956          4
2       0.000013  0.075575  ...                0.251439          3
3       0.000020  0.365145  ...                0.212120          3
4       0.000027  0.564396  ...                0.065144          0
...          ...       ...  ...                     ...        ...
149995  0.999973  0.833171  ...                0.212120          3
149996  0.999980  0.937621  ...                0.100505          2
149997  0.999987  0.749888  ...                0.100505          1
149998  0.999993  0.233253  ...                0.212120          3
149999  1.000000  0.902750  ...                0.135830          3

 # 2.11、定义入模特征

# 2.11.1、删除特征

# 2.11.2、特征筛选

# T2、包裹式wrapper

k_featurenames ('bodyType', 'gearbox', 'kilometer', 'v_0', 'v_3', 'v_7', 'v_14', 'used_time', 'price_average_GBYbrand', 'power_bin')

# T3、嵌入式Embedded(最常用)

LiR_MSE: 15993321.471365392
LiR_R2: 0.7057326262665655
intercept: -480467.6143789641
coef: [('v_5', 547248.1399627327), ('v_6', 517106.21250813385), ('v_7', 497333.878927629), ('v_10', 365570.90980079107), ('v_11', 171543.6146836947), ('v_8', 164227.00112090845), ('v_9', 128578.71403340848), ('power', 48863.6068485829), ('v_4', 43508.82539409367), ('v_14', 19828.850095900943), ('price_average_GBYbrand', 10572.754737316918), ('brand_amount', 6968.85289671065), ('price_median_GBYbrand', 6595.631072990875), ('price_max_GBYbrand', 2237.7971368071658), ('price_std_GBYbrand', 956.376637996673), ('gearbox', 679.4055026736423), ('used_time', 387.4132818355945), ('power_bin', 291.5175148434141), ('bodyType', 217.02045635721151), ('model', -2.4899364779927495), ('city', -10.258028861593232), ('notRepairedDamage', -20.486887939604173), ('fuelType', -24.736780561186862), ('price_min_GBYbrand', -3762.1215956763376), ('kilometer', -4299.815762643461), ('price_sum_GBYbrand', -6953.314648619096), ('v_0', -67643.70870061051), ('v_2', -142475.32076890446), ('v_13', -148508.8116222008), ('v_3', -276643.4143410439), ('v_12', -303764.0882419921), ('v_1', -379287.1351181704)]

# 选取少量样本数据的单个特征分析模型的预测与真实标签的分布差异

# 2.12、导出入模数据集

modelbrandbodyTypefuelTypegearboxpowerkilometernotRepairedDamagepricev_0v_1v_2v_3v_4v_5v_6v_7v_8v_9v_10v_11v_12v_13v_14cityused_timebrand_amountprice_max_GBYbrandprice_median_GBYbrandprice_min_GBYbrandprice_sum_GBYbrandprice_std_GBYbrandprice_average_GBYbrandpower_bin
1720.1538461541000.0031068770.827586207018500.5905958560.7112608580.1923294570.5507837110.492084360.8075569850.6735471730.0922096290.1419007870.4374654510.2920478460.3430372070.3073455830.3234433840.4907156400.4704401140.3243621110.5870297330.0292699720.0020639830.2115945460.1869440950.0738479550
1830.02564102620001036000.6797162450.8205737850.1960590420.5053021850.2628570810.9072744220.7991277040.096609860.1654162890.0923824890.198265750.3140036140.3665407810.1588873190.44670108930.5111670680.4380223060.9989804220.1910812670.0041279670.7340209420.3993065670.2349560974
190.3846153851000.0084403480.827586207062220.7105179940.7850776310.2463266490.3664136220.3008468120.8614712630.7588996380.1175480230.3866686750.121527580.2007620160.3019932890.4770604080.2170504090.41542939710.4701116710.0460423880.4335781010.2599862260.0918472650.0822801250.220633580.2514390073
120.2564102560010.0099937861024000.697206710.7565634260.1880381180.4762849420.1908613880.9398812510.7284399620.0868108680.20768917500.2164250710.2807595890.3890471540.1121157080.39907050580.7704182180.4524800610.9794127640.1532369150.0041279670.6926030090.3820341560.21212013
140.1282051281000.0035211270.310344828052000.6375345830.5446864770.2145326450.3329763480.5905576790.7813771110.4834582550.065398320.4901977840.5455164590.3378343110.2653699680.4500577770.4567124680.55705705450.1579811690.1479457280.2945447430.0464876030.0092879260.0883089580.1263531820.0651439060

三、模型训练与验证

ML之R:通过数据预处理利用LiR/XGBoost等(特征重要性/交叉训练曲线可视化/线性和非线性算法对比/三种模型调参/三种模型融合)实现二手汽车产品交易价格回归预测之详细攻略

https://yunyaniu.blog.csdn.net/article/details/129280091

这篇关于ML之R:通过数据预处理(缺失值/异常值/特殊值的处理/长尾转正态分布/目标log变换/柱形图-箱形图-小提琴图可视化/构造特征/特征筛选+数据降内)利用算法实现二手汽车产品交易价格回归预测之详细攻略的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/421403

相关文章

通俗易懂的Java常见限流算法具体实现

《通俗易懂的Java常见限流算法具体实现》:本文主要介绍Java常见限流算法具体实现的相关资料,包括漏桶算法、令牌桶算法、Nginx限流和Redis+Lua限流的实现原理和具体步骤,并比较了它们的... 目录一、漏桶算法1.漏桶算法的思想和原理2.具体实现二、令牌桶算法1.令牌桶算法流程:2.具体实现2.1

Python使用Pandas对比两列数据取最大值的五种方法

《Python使用Pandas对比两列数据取最大值的五种方法》本文主要介绍使用Pandas对比两列数据取最大值的五种方法,包括使用max方法、apply方法结合lambda函数、函数、clip方法、w... 目录引言一、使用max方法二、使用apply方法结合lambda函数三、使用np.maximum函数

Redis的数据过期策略和数据淘汰策略

《Redis的数据过期策略和数据淘汰策略》本文主要介绍了Redis的数据过期策略和数据淘汰策略,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录一、数据过期策略1、惰性删除2、定期删除二、数据淘汰策略1、数据淘汰策略概念2、8种数据淘汰策略

轻松上手MYSQL之JSON函数实现高效数据查询与操作

《轻松上手MYSQL之JSON函数实现高效数据查询与操作》:本文主要介绍轻松上手MYSQL之JSON函数实现高效数据查询与操作的相关资料,MySQL提供了多个JSON函数,用于处理和查询JSON数... 目录一、jsON_EXTRACT 提取指定数据二、JSON_UNQUOTE 取消双引号三、JSON_KE

Python给Excel写入数据的四种方法小结

《Python给Excel写入数据的四种方法小结》本文主要介绍了Python给Excel写入数据的四种方法小结,包含openpyxl库、xlsxwriter库、pandas库和win32com库,具有... 目录1. 使用 openpyxl 库2. 使用 xlsxwriter 库3. 使用 pandas 库

SpringBoot定制JSON响应数据的实现

《SpringBoot定制JSON响应数据的实现》本文主要介绍了SpringBoot定制JSON响应数据的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们... 目录前言一、如何使用@jsonView这个注解?二、应用场景三、实战案例注解方式编程方式总结 前言

使用Python在Excel中创建和取消数据分组

《使用Python在Excel中创建和取消数据分组》Excel中的分组是一种通过添加层级结构将相邻行或列组织在一起的功能,当分组完成后,用户可以通过折叠或展开数据组来简化数据视图,这篇博客将介绍如何使... 目录引言使用工具python在Excel中创建行和列分组Python在Excel中创建嵌套分组Pyt

在Rust中要用Struct和Enum组织数据的原因解析

《在Rust中要用Struct和Enum组织数据的原因解析》在Rust中,Struct和Enum是组织数据的核心工具,Struct用于将相关字段封装为单一实体,便于管理和扩展,Enum用于明确定义所有... 目录为什么在Rust中要用Struct和Enum组织数据?一、使用struct组织数据:将相关字段绑

在Mysql环境下对数据进行增删改查的操作方法

《在Mysql环境下对数据进行增删改查的操作方法》本文介绍了在MySQL环境下对数据进行增删改查的基本操作,包括插入数据、修改数据、删除数据、数据查询(基本查询、连接查询、聚合函数查询、子查询)等,并... 目录一、插入数据:二、修改数据:三、删除数据:1、delete from 表名;2、truncate

Java实现Elasticsearch查询当前索引全部数据的完整代码

《Java实现Elasticsearch查询当前索引全部数据的完整代码》:本文主要介绍如何在Java中实现查询Elasticsearch索引中指定条件下的全部数据,通过设置滚动查询参数(scrol... 目录需求背景通常情况Java 实现查询 Elasticsearch 全部数据写在最后需求背景通常情况下