I am going through a tutorial that uses sklearn.utils.Bunch as a data set:
cal_housing = fetch_california_housing()
I'm running this on a Databricks notebook.
I've read through the documentation that I can find like https://scikit-learn.org/stable/modules/generated/sklearn.utils.Bunch.html and search engines aren't yielding anything useful.
but how can I see/view what's in this data set?
If I understood correctly, you can convert it to pandas dataframe:
df = california_housing.fetch_california_housing()
calf_hous_df = pd.DataFrame(data= df.data, columns=df.feature_names)
calf_hous_df.sample(4)

Moreover, you can see attributes:
df.keys()
dict_keys(['data', 'target', 'feature_names', 'DESCR'])
You could read the data using method items() and keys() as referencing in sklearn.utils.Bunch.
But there is no method similar to head() in Pandas Dataframe. dataset.items() will show all data.
I've tried using iris dataset as follows.
import sklearn
from sklearn import datasets
# load iris dataset
iris = datasets.load_iris()
print('Data type:', type(iris))
iris.items()
print('Keys: ', iris.keys()) #show all the keys
iris.get('feature_names')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With