如何解决数据集不是可解决的问题
我正在尝试估算NaN值,但首先,我想检查计算此值的最佳方法。我是使用这种方法的新手,所以我想使用我发现的代码来区分差异回归变量并选择最佳。原始代码是这样的:
from sklearn.experimental import enable_iterative_imputer # noqa
from sklearn.datasets import fetch_california_housing
from sklearn.impute import SimpleImputer
from sklearn.impute import IterativeImputer
from sklearn.linear_model import BayesianRidge
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import ExtraTreesRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import cross_val_score
N_SPLITS = 5
rng = np.random.RandomState(0)
X_full,y_full = fetch_california_housing(return_X_y=True)
# ~2k samples is enough for the purpose of the example.
Remove the following two lines for a slower run with different error bars.
X_full = X_full[::10]
y_full = y_full[::10]
n_samples,n_features = X_full.shape
fetch_california_housing是他的数据集。
因此,当我尝试使此代码适合我的情况时,我编写了以下代码:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from numpy import genfromtxt
data = genfromtxt('documents/datasets/df.csv',delimiter=',')
features = data[:,:2]
targets = data[:,2]
N_SPLITS = 5
rng = np.random.RandomState(0)
X_full,y_full = data(return_X_y= True)
# ~2k samples is enough for the purpose of the example.
# Remove the following two lines for a slower run with different error bars.
X_full = X_full[::10]
y_full = y_full[::10]
n_samples,n_features = X_full.shape
我总是遇到相同的错误:
AttributeError: 'numpy.ndarray' object is not callable
在我将DF用作csv(df.csv)之前,错误是相同的
AttributeError: 'Dataset' object is not callable
完整的错误是这样的:
ypeError Traceback (most recent call last) <ipython-input-8-3b63ca34361e> in <module>
3 rng = np.random.RandomState(0) 4
----> 5 X_full,y_full = df(return_X_y=True)
6 # ~2k samples is enough for the purpose of the example.
7 # Remove the following two lines for a slower run with different error bars.
TypeError: 'DataFrame' object is not callable
我不知道如何解决这两个错误之一
我希望能很好地解释我的问题,因为我的英语不太好
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。