Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python数据分析之数据缺失 #79

Open
hsipeng opened this issue Aug 23, 2019 · 0 comments
Open

python数据分析之数据缺失 #79

hsipeng opened this issue Aug 23, 2019 · 0 comments

Comments

@hsipeng
Copy link
Owner

hsipeng commented Aug 23, 2019

数据缺失

数据缺失的原因

  • 无意的
  • 有意的
  • 不存在的

数据缺失的类型

  • 完全随机缺失(missing completely at random, MCAR)
  • 随机缺失(missing at random, MAR)
  • 非随机缺失(missing not at random, MNAR)

数据缺失的处理方法

  • 删除记录
    • 优点
      最简单粗暴
    • 缺点
      牺牲大量数据
      缺失比例比较大时,导致数据发生偏离
    • Python
df.dropna(how=any’)
  • 数据填补
    • 替换缺失值
      • 均值插补
        • 对于定类数据, 使用众数(mode)
        • 对于定量(定比)数据:正太分布使用平均数(mean), 非正太使用中位数(median).
df['price'].fillna(df['price'].mean())
df['price'].fillna(df['price'].median())
	* 热卡填补
	相似对象的值
	* K最近距离邻法(K-means clustering)
	无监督机器学习的聚类方法
* 拟合缺失值
	* 回归预测
	基于完整的数据集,建立回归方程,通过方程求得缺失值

	* 极大似然估计
	* 多重插补
	* 随机森林
* 虚拟变量
通过判断特征值是否有缺失值来定义一个新的二分类变量
* 不处理
一些模型本身可以应对缺失值的数据,不需要处理
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant