资源简介
#coding=utf-8
"""
#演示目的:利用鸢尾花数据集画出P-R曲线
"""
print(__doc__)
import matplotlib.pyplot as plt
import numpy as np
from sklearn import svm, datasets
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import average_precision_score
from sklearn.preprocessing import label_binarize
from sklearn.multiclass import OneVsRestClassifier
#from sklearn.cross_validation import train_test_split #适用于anaconda 3.6及以前版本
from sklearn.model_selection import train_test_split#适用于anaconda 3.7
#以iris数据为例,画出P-R曲线
iris = datasets.load_iris()
X = iris.data
y = iris.target
# 标签二值化,将三个类转为001, 010, 100的格式.因为这是个多类分类问题,后面将要采用
#OneVsRestClassifier策略转为二类分类问题
y = label_binarize(y, classes=[0, 1, 2])
n_classes = y.shape[1]
print (y)
"""
#演示目的:利用鸢尾花数据集画出P-R曲线
"""
print(__doc__)
import matplotlib.pyplot as plt
import numpy as np
from sklearn import svm, datasets
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import average_precision_score
from sklearn.preprocessing import label_binarize
from sklearn.multiclass import OneVsRestClassifier
#from sklearn.cross_validation import train_test_split #适用于anaconda 3.6及以前版本
from sklearn.model_selection import train_test_split#适用于anaconda 3.7
#以iris数据为例,画出P-R曲线
iris = datasets.load_iris()
X = iris.data
y = iris.target
# 标签二值化,将三个类转为001, 010, 100的格式.因为这是个多类分类问题,后面将要采用
#OneVsRestClassifier策略转为二类分类问题
y = label_binarize(y, classes=[0, 1, 2])
n_classes = y.shape[1]
print (y)
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Wed Mar 18 10:36:21 2020
@author: Administrator
“““
#coding=utf-8
“““
#演示目的:利用鸢尾花数据集画出P-R曲线
“““
print(__doc__)
import matplotlib.pyplot as plt
import numpy as np
from sklearn import svm datasets
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import average_precision_score
from sklearn.preprocessing import label_binarize
from sklearn.multiclass import OneVsRestClassifier
#from sklearn.cross_validation import train_test_split #适用于anaconda 3.6及以前版本
from sklearn.model_selection import train_test_split#适用于anaconda 3.7
#以iris数据为例,画出P-R曲线
iris = datasets.load_iris()
X = iris.data
y = iris.target
# 标签二值化将三个类转为001 010 100的格式.因为这是个多类分类问题,后面将要采用
#OneVsRestClassifier策略转为二类分类问题
y = label_binarize(y classes=[0 1 2])
n_classes = y.shape[1]
print (y)
# 增加了800维的噪声特征
random_state = np.random.RandomState(0)
n_samples n_features = X.shape
X = np.c_[X random_state.randn(n_samples 200 * n_features)]
# Split into training and test
X_train X_test y_train y_test = train_test_split(X y test_size=.5 random_state=random_state) #随机数,填0或不填,每次都会不一样
# Run classifier probability : boolean optional (default=False)Whether to enable probability estimates. This must be enabled prior to calling fit and will slow down that method.
classifier = OneVsRestClassifier(svm.SVC(kernel=‘linear‘ probability=True random_state=random_state))
y_score = classifier.fit(X_train y_train).decision_function(X_test)
# Compute P
- 上一篇:zabbix微信告警脚本
- 下一篇:python写的旅游网站源码
相关资源
- 7.图像风格迁移 基于深度学习 pyt
- 机器学习(周志华)配套代码
- 机器学习-岭回归实现
- dronet源码+论文(深度学习)
- 012345手势识别神经网络代码
- 猫-非猫图二分类识别
- 深度学习(SPOT-RNA)
- 机器学习k means算法实现图像分割
- kmeans聚类算法的python实现程序
- Python100经典练习题
- 南瓜书(PumpkinBook)
- 深度学习YOLOv3分类算法
- 机器学习numpy和pandas基础
- python机器学习Sebastian Raschka中文最新完
- Python-DeepMoji模型的pyTorch实现
- Deep Learning Cookbook_ practical recipes to g
- 《机器学习实战》源代码Python3
- 深度学习视频中的行为识别
- Python-使用DeepFakes实现YouTube视频自动换
- deep learning with python 中文版
- Introduction to machine learning with python (
- python新浪微博爬虫,爬取微博和用户
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- 非线性回归Python代码
- 093 2018北风网人工智能视频(完结)转
- python的色情图片识别
- 贝叶斯网络程序
- 吴恩达深度学习超参数调制完整程序
- 《机器学习实战》Python3代码
评论
共有 条评论