util.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:skutil 作者: tgsmith61591 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号