尝试重现《动手学习机器学习与Sci-Kit Learn和Tensorflow》书中房屋数据集时无法显示

我试图使用下面的代码重现书中的房屋数据集/代码,但不知何故,我得到了最后显示的错误

In [32]:import osimport tarfilefrom six.moves import urllibIn [37]:DOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml/master/"HOUSING_PATH = "/home/isaac/Fundamentals of Data Science Certificate/3253 - Machine Learning/Code from book"HOUSING_URL = DOWNLOAD_ROOT + HOUSING_PATH + "/housing.tgz"In [41]:def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):    if not os.path.isdir(housing_path):        os.makedirs(housing_path)    tgz_path = os.path.join(housing_path, "housing.tgz")    urllib.request.urlretrieve(housing_url, tgz_path)    housing_tgz = tarfile.open(tgz_path)    housing_tgz.extractall(path=housing_path)    housing_tgz.close()In [42]:import pandas as pddef load_housing_data(housing_path=HOUSING_PATH):    csv_path = os.path.join(housing_path, "housing.csv")    return pd.read_csv(csv_path)In [43]:housing = load_housing_data()housing.head

FileNotFoundError: File b'/home/isaac/Fundamentals of Data Science Certificate/3253 - Machine Learning/Code from book/housing.csv' does not exist

我该如何解决这个问题?


回答:

你没有在任何地方调用fetch_housing_data来创建文件'housing.tgz'

(你还假设文件'housing.tgz'包含了文件"housing.csv"的压缩版本)

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注