2

This code is to load the housing data from the scikit-learn library.

>>> from sklearn.datasets import load_boston
>>> boston_dataset = load_boston()
>>> len(boston_dataset.data)
506

First feature is CRIM which means "per capita crime rate by town".

Does it indicate that there are 506 different towns in "Boston house prices dataset"?

4

TLDR: No, there are only 92 distinct towns. There are 506 Census Tracts.

You can run getattr(boston_dataset, "DESCR") to get the description of the dataset. While it does not directly contain the information that you want, it does tell you:

This dataset was taken from the StatLib library which is maintained at Carnegie Mellon University.

The Boston house-price data of Harrison, D. and Rubinfeld, D.L.
'Hedonic prices and the demand for clean air',
J. Environ. Economics & Management,
vol.5, 81-102, 1978.

If you can get a copy of the paper, you will find in it the line:

The physical changes in NOX concentrations in each of the 506 Boston SMSA census tracts were calculated for 1990 using the Transportation and Air Shed Simulation Model (TASSIM ).

If you go to the Statlib site: http://lib.stat.cmu.edu/datasets/ You will see datasets called boston and boston_corrected. It appears that the data in sklearn.datasets is the boston set. The boston_corrected data contains a field for the town. My count is that there are 92 distinct values in that field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.