def load_iris_df(include_tgt=True, tgt_name="Species", shuffle=False):
"""Loads the iris dataset into a dataframe with the
target set as the "Species" 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="Species")
The name of the target feature
shuffle : bool, optional (default=False)
Whether to shuffle the rows on return
Returns
-------
X : pd.DataFrame, shape=(n_samples, n_features)
The loaded dataset
"""
iris = load_iris()
X = pd.DataFrame.from_records(data=iris.data, columns=iris.feature_names)
if include_tgt:
X[tgt_name] = iris.target
return X if not shuffle else shuffle_dataframe(X)
评论列表
文章目录