- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
目前我正在尝试用 pandas 估算因变量。 (不要问为什么。)这是数据集
y.head(15)
Out[138]:
0 13495.0
1 16500.0
2 16500.0
3 13950.0
4 17450.0
5 15250.0
6 17710.0
7 18920.0
8 23875.0
9 NaN
10 16430.0
11 16925.0
12 20970.0
13 21105.0
14 24565.0
Name: price, dtype: float64
如果我尝试估算这个变量,会发生一些奇怪的事情:
len(y) # 15
from sklearn.preprocessing import Imputer,
mean_imputer_y = Imputer(strategy="mean", axis=0)
imputed_y = mean_imputer_y.fit_transform(y)
len(imputed_y) # 14
这显然与 Imputer 应该做的完全相反。我不想删除 NaN。我想归咎于他们。
对于这种行为是否有一些解释。我做错了什么?
感谢您的帮助!
最佳答案
您应该使用 axis=1 而不是 0 。
from sklearn.preprocessing import Imputer
mean_imputer_y = Imputer(strategy="mean", axis=1,missing_values=np.nan)
mean_imputer_y.fit_transform(df.Val)
array([[13495. , 16500. , 16500. , 13950. , 17450. , 15250. , 17710. ,
18920. , 23875. , 18117.5, 16430. , 16925. , 20970. , 21105. ,
24565. ]])
关于python - 防止 Imputer 丢失值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48235420/
我的代码无法正常工作,因为我从机器学习 A-Z™:数据科学中的 Python 和 R 实践教程类(class)中逐字复制。我使用的是 Python 3.7,我已经在我的环境中安装了 scikit-le
我正在尝试在 google cloud ai 平台上创建一个版本,但找不到 impute 模块 No module named 'sklearn.impute._base; 'sklearn.impu
我正在对数据集进行预处理,我得到了该行的错误原因 imputer = imputer.fit(X [:,1:3])。我不明白哪个?我理解imputer = Imputer(missing_values
问题是我无法从 sklearn 导入模块。 from sklearn.impute import SimpleImputer ModuleNotFoundError: No module named
print(np.shape(ar_fulldata_input_xx)) Output: (9027, 1443) 现在,我使用 Imputer 来估算数据帧 ar_fulldata_input_x
我目前正在学习 sklearn imputer我发现有一种策略没有被 imputers 实现。 我想构建一个管道,删除具有任何缺失值的列或删除所有具有缺失值的行。 我为什么要这个? 因为我想进行网格搜
我正在尝试使用 Imputer 来查找缺失值。我还想跟踪具有所有缺失值的列,但因为否则我不知道其中哪些(列)已被处理:是否还可以返回包含所有缺失值的列? Impute Notes When axis=
我有一个包含缺失值 NaN 的特征矩阵,因此我需要先初始化这些缺失值。但是,最后一行提示并抛出以下错误行:预期序列或类数组,得到 Imputer(axis=0, copy=True, missing_
目前我正在尝试用 pandas 估算因变量。 (不要问为什么。)这是数据集 y.head(15) Out[138]: 0 13495.0 1 16500.0 2 16500.0
我有以下问题:我有一个 pandas 数据框,其中缺失值由字符串 na 标记。我想在其上运行一个 Imputer 以用列中的平均值替换缺失值。根据 sklearn 文档,参数 missing_valu
我试图在数据框中填充我的 NA 数据。我做了简单的数据: library(mice) first <- c(1,2,3,4,5,NA,7,8,9,NA) second<- c(1,2,NA,4,5,6
我不确定为什么,但在应用 knn.impute 时出现以下错误: Error in storage.mode(use.data) <- "double" : (list) object canno
考虑 data其中包含以下一些 nan: Column-1 Column-2 Column-3 Column-4 Column-5 0 NaN 15.0 63.0
有没有办法让 Scikit-learn Imputer 查找并替换多个被视为“缺失值”的值? 例如,我想做类似的事情 imp = Imputer(missing_values=(7,8,9)) 但根据
我正在练习机器学习中的数据集,在获取缺失值时,我使用了 imputer 类,但它给了我一个错误:数组索引太多。对于这个错误,我只是查看了所有 numpy 模块,但我没有任何想法来解决它。 import
有没有办法使用 sklearn.preprocessing 对象来估算分类值?我想最终创建一个预处理对象,我可以将其应用于新数据并以与旧数据相同的方式对其进行转换。 我正在寻找一种方法来做到这一点,以
docs对于 scikit-learn 的 Imputation transformer 说 When axis=0, columns which only contained missing val
我有一个包含 332 列的数据框。我想估算值以便能够使用 scikit-learn 的决策树分类器。我的问题是 imputer 函数的结果数据列只有 330。 from sklearn.preproc
我想在数据帧的所有 float64 列上使用 DataFrameMapper Imputer+Scaler 映射。我的代码适用于 StandardScaler,但当我添加 Imputer 时,映射器仅
import numpy as np import matplotlib.pyplot as plt import pandas as pd #Import Data set dataset= pd.
我是一名优秀的程序员,十分优秀!