O2O优惠券预测

阿里云天池大赛-赛题解析
常见库导入缩写习惯:

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from datetime import date
import datetime as dt
from scipy import stats

1.数据探索

代码连接:https://tianchi.aliyun.com/notebook/129415

1.1.画箱形图示例

fig = plt.figure(figsize=(4, 6))  # 指定绘图对象宽度和高度
sns.boxplot(dftrain[(dftrain.label>=0)&(dftrain.distance>=0)]['distance'],orient="v", width=0.5)
plt.show()

1.2.直方图和QQ图

plt.figure(figsize=(10,5))
# ax=plt.subplot(1,2,1)
sns.distplot(
    dftrain[(dftrain.label>=0)&(dftrain.distance>=0)]['distance'],
    fit=stats.norm) # 拟合正态分布曲线
plt.show()

plt.figure(figsize=(10,5))
# ax=plt.subplot(1,2,2)
res = stats.probplot(dftrain[(dftrain.label>=0)&(dftrain.distance>=0)]['distance'], plot=plt)
plt.show()

1.3.概率图

stats.probplot 是 SciPy 库中用于生成概率图(Probability Plot)的核心函数,主要用于检验数据是否符合特定理论分布(如正态分布)。以下是其核心含义和使用方法的详细说明:

plt.figure(figsize=(10,5))
res = stats.probplot(dftrain[(dftrain.label>=0)&(dftrain.discount_rate>=0)]['discount_rate'], plot=plt)
plt.show()

1.4.对比分布

ax = sns.kdeplot(dftrain[(dftrain.label>=0)&(dftrain.discount_rate>=0)]['discount_rate'], color="Red", shade=True)
ax = sns.kdeplot(dftest[(dftest.discount_rate>=0)]['discount_rate'], color="Blue", shade=True)
ax.set_xlabel('discount_rate')
ax.set_ylabel("Frequency")
ax = ax.legend(["train","test"])
plt.show()

seaborn.kdeplot() 是 Seaborn 库中用于绘制核密度估计图(Kernel Density Estimate Plot)的核心函数。它通过平滑的曲线展示单变量或双变量数据的概率密度分布,是数据探索和统计建模中常用的可视化工具。以下是其核心含义、参数及使用场景的详细说明:

1.5.可视化线性关系

plt.figure(figsize=(8,4))
sns.regplot(x='distance', y='label', data=dftrain[(dftrain.label>=0)&(dftrain.distance>=0)][['distance','label']], ax=ax, 
            scatter_kws={'marker':'.','s':3,'alpha':0.3},
            line_kws={'color':'k'});
plt.xlabel('distance')
plt.ylabel('label')

seaborn.regplot() 是 Seaborn 库中用于绘制回归分析图的核心函数,它通过散点图展示两个变量之间的关系,并叠加一条回归线(默认线性回归)以量化这种关系的趋势。

2.特征工程

代码链接:https://tianchi.aliyun.com/notebook/129421

3.模型训练

代码链接:https://tianchi.aliyun.com/notebook/129424

4.模型验证

代码链接:https://tianchi.aliyun.com/notebook/129425

5.赛题实践

代码链接:https://tianchi.aliyun.com/notebook/129434

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值