欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

Chapter2:预测房价【原链接失效,没有任何数据】

时间:2023-06-01

import osimport tarfileimport urllibimport pandasimport pandas as pdimport urllib.request#fetch dataDOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml2/master/"HOUSING_PATH = os.path.join("datasets","housing")HOUSING_URL = DOWNLOAD_ROOT + "datasets/housing/housing.tgz"#set function fetchdatadef fetch_housing_data(housing_url= HOUSING_URL,housing_path=HOUSING_PATH): os.makedirs(housing_path,exist_ok=True) 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()#return dataframedef load_housing_data(housing_path = HOUSING_PATH): csv_path = os.path.join(housing_path,"housing.csv") return pd.read_csv(csv_path)housing = load_housing_data()housing_head = housing.head()

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。