• sklearn.datasets


     sklearn.datasets.load_iris()

    参数:

    • return_X_y ;  bool, default=False   :If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
    • as_frame ;  bool, default=False  :If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (datatarget) will be pandas DataFrames or Series as described below.

    返回:

    • data{ndarray, dataframe} of shape (150, 4)

    The data matrix. If as_frame=Truedata will be a pandas DataFrame.

    • target: {ndarray, Series} of shape (150,)

    The classification target. If as_frame=Truetarget will be a pandas Series.

    • feature_names: list

    The names of the dataset columns.

    • target_names: list

    The names of target classes.

    • frame: DataFrame of shape (150, 5)

    Only present when as_frame=True. DataFrame with data and target.

    New in version 0.23.

    • DESCR: str

    The full description of the dataset.

    • filename: str

    The path to the location of the data.

    • (data, target)  tuple if return_X_y is True

    例子:

    from sklearn import  datasets
    
    iris_data = datasets.load_iris()
    print(iris_data.data) #返回样本数据
    print(iris_data.data.shape) #返回样本数据形状
    print(iris_data.target) #返回样本数据的label
    print(iris_data.target.shape) #返回样本数据lable形状
    print(iris_data.target[[0,50,149]]) #返回样本数据 x_0,x_50 ,x_149 的label
    print(iris_data.target_names) #返回lable 名称
    print(iris_data.target_names[0:4])
    print(iris_data.target_names[[0,1,2]])
    print(iris_data.feature_names) #返回特征名称
    print(iris_data.feature_names[0:2]) #返回特征名称
    print(iris_data.DESCR) #数据描述
    print(iris_data.filename) #返回数据存放位置
    X ,y = datasets.load_iris(return_X_y=True) 
    print(X.shape)
    print(y.shape)
    iris_data = datasets.load_iris(as_frame=True)
    print(type(iris_data))

     

  • 相关阅读:
    【转】36个经典的JQuery导航菜单演示+下载
    【转】ASP.NET 3.5 开发范例精讲精析读书笔记
    【转】js弹出框详解
    【转】谈谈三层架构中MODEL的作用
    【转】制作.net实体类生成器(1)
    ASP.NET开发实战宝典.pdf配套视频源码iso| 开发实战宝典pdf和配套视频源码iso
    【转】if (!IsPostBack)
    jquery
    取web.config 连接字符串
    js接收传递过来的参数
  • 原文地址:https://www.cnblogs.com/BlairGrowing/p/15852435.html
Copyright © 2020-2023  润新知