pythonscikit-learndatabricks

how to display/view `sklearn.utils.Bunch` data set?


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?


Solution

  • 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)
    

    enter image description here

    Moreover, you can see attributes:

    df.keys()
    dict_keys(['data', 'target', 'feature_names', 'DESCR'])