handson-ml3
handson-ml3 copied to clipboard
Chapter 10 - Error using fetch_california_housing
I just installed everything using the related conda environment. Everything works fine, except for when using fetch_california_housing. As in the line
housing = fetch_california_housing()
The error I get is:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In [6], line 8
5 from sklearn.pipeline import make_pipeline
6 from sklearn.preprocessing import StandardScaler
----> 8 housing = fetch_california_housing()
9 X_train_full, X_test, y_train_full, y_test = train_test_split(
10 housing.data, housing.target, random_state=42)
11 X_train, X_valid, y_train, y_valid = train_test_split(
12 X_train_full, y_train_full, random_state=42)
File ~/.conda/envs/homl3/lib/python3.10/site-packages/sklearn/datasets/_california_housing.py:153, in fetch_california_housing(data_home, download_if_missing, return_X_y, as_frame)
150 remove(archive_path)
152 else:
--> 153 cal_housing = joblib.load(filepath)
155 feature_names = [
156 "MedInc",
157 "HouseAge",
(...)
163 "Longitude",
164 ]
166 target, data = cal_housing[:, 0], cal_housing[:, 1:]
File ~/.conda/envs/homl3/lib/python3.10/site-packages/joblib/numpy_pickle.py:587, in load(filename, mmap_mode)
581 if isinstance(fobj, str):
582 # if the returned file object is a string, this means we
583 # try to load a pickle file generated with an version of
584 # Joblib so we load it with joblib compatibility function.
585 return load_compatibility(fobj)
--> 587 obj = _unpickle(fobj, filename, mmap_mode)
588 return obj
File ~/.conda/envs/homl3/lib/python3.10/site-packages/joblib/numpy_pickle.py:506, in _unpickle(fobj, filename, mmap_mode)
504 obj = None
505 try:
--> 506 obj = unpickler.load()
507 if unpickler.compat_mode:
508 warnings.warn("The file '%s' has been generated with a "
509 "joblib version less than 0.10. "
510 "Please regenerate this pickle file."
511 % filename,
512 DeprecationWarning, stacklevel=3)
File ~/.conda/envs/homl3/lib/python3.10/pickle.py:1213, in _Unpickler.load(self)
1211 raise EOFError
1212 assert isinstance(key, bytes_types)
-> 1213 dispatch[key[0]](self)
1214 except _Stop as stopinst:
1215 return stopinst.value
KeyError: 194
I have executed the same code, but without activating the conda environment (so using the stuff as installed by my OS - I use Arch Linux) and everything works fine. But when using the conda env provided, I get the error above. I also tried updating sklearn to 1.2, but I receive the same error.