def load_boston_df(include_tgt=True, tgt_name="target", shuffle=False):
"""Loads the boston housing dataset into a dataframe with the
target set as the "target" feature or whatever name
is specified in ``tgt_name``.
Parameters
----------
include_tgt : bool, optional (default=True)
Whether to include the target
tgt_name : str, optional (default="target")
The name of the target feature
shuffle : bool, optional (default=False)
Whether to shuffle the rows
Returns
-------
X : Pandas ``DataFrame`` or ``H2OFrame``, shape=(n_samples, n_features)
The loaded dataset
"""
bo = load_boston()
X = pd.DataFrame.from_records(data=bo.data, columns=bo.feature_names)
if include_tgt:
X[tgt_name] = bo.target
return X if not shuffle else shuffle_dataframe(X)
评论列表
文章目录