https://github.com/scikit-learn/scikit-learn/blob/2cce02414d4a7161f0d105450c196d94b1182220/sklearn/datasets/__init__.py Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} scikit-learn / scikit-learn Public * * Notifications * Fork 23.8k * Star 52.5k * Code * Issues 1.5k * Pull requests 589 * Discussions * Actions * Projects 17 * Wiki * Security * Insights More * Code * Issues * Pull requests * Discussions * Actions * Projects * Wiki * Security * Insights Permalink 2cce02414d Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create scikit-learn/sklearn/datasets/__init__.py / Jump to Code definitions [ ] __getattr__ Function Code navigation index up-to-date Go to file * Go to file T * Go to line L * Go to definition R * * Copy path * Copy permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. @jeremiedbb jeremiedbb MAINT Clean deprecation for 1.2: load_boston (#24603) ... Latest commit 8a86e21 Oct 10, 2022 History Co-authored-by: Thomas J. Fan 19 contributors Users who have contributed to this file 161 lines (144 sloc) 5.78 KB Raw Blame Edit this file E Open in GitHub Desktop * * View raw * * View blame This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters """ The :mod:`sklearn.datasets` module includes utilities to load datasets, including methods to load and fetch popular reference datasets. It also features some artificial data generators. """ import textwrap from ._base import load_breast_cancer from ._base import load_diabetes from ._base import load_digits from ._base import load_files from ._base import load_iris from ._base import load_linnerud from ._base import load_sample_images from ._base import load_sample_image from ._base import load_wine from ._base import get_data_home from ._base import clear_data_home from ._covtype import fetch_covtype from ._kddcup99 import fetch_kddcup99 from ._lfw import fetch_lfw_pairs from ._lfw import fetch_lfw_people from ._twenty_newsgroups import fetch_20newsgroups from ._twenty_newsgroups import fetch_20newsgroups_vectorized from ._openml import fetch_openml from ._samples_generator import make_classification from ._samples_generator import make_multilabel_classification from ._samples_generator import make_hastie_10_2 from ._samples_generator import make_regression from ._samples_generator import make_blobs from ._samples_generator import make_moons from ._samples_generator import make_circles from ._samples_generator import make_friedman1 from ._samples_generator import make_friedman2 from ._samples_generator import make_friedman3 from ._samples_generator import make_low_rank_matrix from ._samples_generator import make_sparse_coded_signal from ._samples_generator import make_sparse_uncorrelated from ._samples_generator import make_spd_matrix from ._samples_generator import make_swiss_roll from ._samples_generator import make_s_curve from ._samples_generator import make_sparse_spd_matrix from ._samples_generator import make_gaussian_quantiles from ._samples_generator import make_biclusters from ._samples_generator import make_checkerboard from ._svmlight_format_io import load_svmlight_file from ._svmlight_format_io import load_svmlight_files from ._svmlight_format_io import dump_svmlight_file from ._olivetti_faces import fetch_olivetti_faces from ._species_distributions import fetch_species_distributions from ._california_housing import fetch_california_housing from ._rcv1 import fetch_rcv1 __all__ = [ "clear_data_home", "dump_svmlight_file", "fetch_20newsgroups", "fetch_20newsgroups_vectorized", "fetch_lfw_pairs", "fetch_lfw_people", "fetch_olivetti_faces", "fetch_species_distributions", "fetch_california_housing", "fetch_covtype", "fetch_rcv1", "fetch_kddcup99", "fetch_openml", "get_data_home", "load_diabetes", "load_digits", "load_files", "load_iris", "load_breast_cancer", "load_linnerud", "load_sample_image", "load_sample_images", "load_svmlight_file", "load_svmlight_files", "load_wine", "make_biclusters", "make_blobs", "make_circles", "make_classification", "make_checkerboard", "make_friedman1", "make_friedman2", "make_friedman3", "make_gaussian_quantiles", "make_hastie_10_2", "make_low_rank_matrix", "make_moons", "make_multilabel_classification", "make_regression", "make_s_curve", "make_sparse_coded_signal", "make_sparse_spd_matrix", "make_sparse_uncorrelated", "make_spd_matrix", "make_swiss_roll", ] def __getattr__(name): if name == "load_boston": msg = textwrap.dedent( """ `load_boston` has been removed from scikit-learn since version 1.2. The Boston housing prices dataset has an ethical problem: as investigated in [1], the authors of this dataset engineered a non-invertible variable "B" assuming that racial self-segregation had a positive impact on house prices [2]. Furthermore the goal of the research that led to the creation of this dataset was to study the impact of air quality but it did not give adequate demonstration of the validity of this assumption. The scikit-learn maintainers therefore strongly discourage the use of this dataset unless the purpose of the code is to study and educate about ethical issues in data science and machine learning. In this special case, you can fetch the dataset from the original source:: import pandas as pd import numpy as np data_url = "http://lib.stat.cmu.edu/datasets/boston" raw_df = pd.read_csv(data_url, sep="\\s+", skiprows=22, header=None) data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) target = raw_df.values[1::2, 2] Alternative datasets include the California housing dataset and the Ames housing dataset. You can load the datasets as follows:: from sklearn.datasets import fetch_california_housing housing = fetch_california_housing() for the California housing dataset and:: from sklearn.datasets import fetch_openml housing = fetch_openml(name="house_prices", as_frame=True) for the Ames housing dataset. [1] M Carlisle. "Racist data destruction?" [2] Harrison Jr, David, and Daniel L. Rubinfeld. "Hedonic housing prices and the demand for clean air." Journal of environmental economics and management 5.1 (1978): 81-102. """ ) raise ImportError(msg) try: return globals()[name] except KeyError: # This is turned into the appropriate ImportError raise AttributeError * Copy lines * Copy permalink * View git blame * Reference in new issue [ ] Go Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.