尝试重现《动手学习机器学习与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

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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