NumPy Data Set

Source: Internet
Author: User

#安装scipy, Numpy,sklearn bagImportNumPy as np# reading the iris DataSet from the Sklearn packet's own data set Datafrom sklearn.datasetsImportLoad_irisdata=Load_iris () # Look at the data type, which print is included ("Data type:", type (data) print ("Data Category:", Data.keys ()) # Remove the iris feature and Iris category data to see its shape and data type Iris_feature=Data.feature_names,data.dataprint ("Iris Characteristics:", iris_feature) print ("Iris_feature Data Type", type (iris_feature)) Iris_target=Data.targetprint ("Iris Data Category:", Iris_target) print ("Iris_target Data type:", type (iris_target)) # Remove All the flowers of the calyx length (cm) of the data Sepal_len= Np.array (List (len[0) forlen in Data.data)) Print ("Calyx Length:", Sepal_len) # Remove all flower petals length (cm)+petal Width (cm) data Pental_len= Np.array (List (len[2) forlen in Data.data)) Pental_len.resize (2,50) #重新分配花瓣长度内存pental_wid= Np.array (List (len[3) forlen in Data.data)) Pental_wid.resize (2,50) #重新分配花瓣宽度内存iris_lens=(pental_len,pental_wid) print ("Petal Length width:", Iris_lens) # Take out four features of a flower and its category print ("Features:", data.data[1]) print ("Category:", data.target[1] # divides the characteristics and categories of all flowers into three groups, each set of 50 # establishes 3 corresponding lists to hold the data iris_set=[]iris_ver=[]iris_vir= [] forI in range (0,150):    ifData.target[i] = = 0: Data=data.data[i].tolist () data.append (' Setosa ') iris_set.append (Data) elif Data.target[i]==1: Data=data.data[i].tolist () data.append (' Versicolor ') iris_ver.append (Data)Else: Data=data.data[i].tolist () data.append (' Virginica ') Iris_vir.append (Data) # generates a new array with four features per element+category Datas=(iris_set,iris_ver,iris_vir) print ("New array:", datas)

NumPy Data Set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.