sklearn学习-3-样本数据集

# -*- coding: utf-8 -*-
"""
Created on Mon Jul  2 16:02:56 2018

@author: GY
"""

#监督学习
#----------------------------------------------------------------------------------------------------------------------#
import mglearn
import matplotlib.pyplot as plt
from sklearn.datasets import load_breast_cancer
import numpy as np


#---------------------------------------------------------------------------------------------------------------
#二分类数据集
#数据,标签
X,y=mglearn.datasets.make_forge()
mglearn.discrete_scatter(X[:,0],X[:,1],y)#第一个特征-x,第二个特征-y
plt.legend(["Class 0","Class 1"],loc=4)
plt.xlabel('Frist feature')
plt.ylabel('Second feature')
print(X.shape)



#-------------------------------------------------------------------------------------------------------------
#回归数据集
X,y=mglearn.datasets.make_wave(n_samples=40)
plt.plot(X,y,'o')
plt.ylim(-3,3)
plt.xlabel('Feature')
plt.ylabel('Target')



#---------------------------------------------------------------------------------------------------------------------
#真实数据集
cancer=load_breast_cancer()
        #cancer.keys()
            #dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names'])
        #cancer.data.shape
            #(569, 30)
            
#建立特征的分类,dict
{n:v for n,v in zip(cancer.target_names,np.bincount(cancer.target)) }


全部评论

相关推荐

最近拿到了正浩的提前批offer感觉自己的实力得到了肯定,也给了我更多底气
搞机墨镜猫:正浩提前批官网好像就只有电力电子软硬件,哥们投的是这两个岗位吗
26届校招投递进展
点赞 评论 收藏
分享
认真搞学习:这么良心的老板真少见
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务