当前位置:网站首页>matplotlib 简单逻辑回归可视化
matplotlib 简单逻辑回归可视化
2022-06-25 08:16:00 【郭庆汝】
matplotlib matplotlib中简单逻辑回归可视化
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
import numpy as np
import matplotlib.pyplot as plt
iris = load_iris()
X = iris.data[:,[2, 3]]
y = iris.target
clf = LogisticRegression()
clf.fit(X, y)
x_min, x_max = X[:,0].min() - 1, X[:,0].max() + 1
y_min, y_max = X[:,1].min() - 1, X[:,1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max,0.1),
np.arange(y_min,y_max, 0.1))
Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.plot()
plt.contourf(xx, yy, Z, alpha=0.4, cmap = plt.cm.RdYlBu)
plt.scatter(X[:, 0], X[:, 1], c=y, cmap = plt.cm.brg)
plt.title("Logistic Regression")
plt.xlabel("Petal.Length")
plt.ylabel("Petal.Width")
plt.show()

边栏推荐
- C language: count the number of words in a paragraph
- 《乔布斯传》英文原著重点词汇笔记(二)【 chapter one】
- Exchange: manage calendar permissions
- compiling stm32f4xx_ it. c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).
- 声纹技术(一):声纹技术的前世今生
- wav文件(波形文件)格式分析与详解
- How to choose an account opening broker? Is it safe to open an account online?
- OpenFOAM:底层
- EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化
- ICer必须知道的35个网站
猜你喜欢

compiling stm32f4xx_it.c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).

The city chain technology platform is realizing the real value Internet reconstruction!

UEFI:修复 EFI/GPT Bootloader

自定义注解之编译时注解(RetentionPolicy.CLASS)

Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an

C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large

C language: bubble sort

nodejs 使用Express框架demo

EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化

二、训练fashion_mnist数据集
随机推荐
SharePoint:SharePoint 2013 with SP1 简易安装
How annotation lib and processor lib reference
二、训练fashion_mnist数据集
C#启动程序传递参数丢失双引号,如何解决?
某视频网站m3u8非感知加密分析
[515. find the maximum value in each tree row]
故障:Outlook 收发邮件时的 0x800CCC1A 错误
Notes on key words in the original English work biography of jobs (V) [chapter three]
What is the file that tp6 automatically executes? What does the tp6 core class library do?
C language: bubble sort
Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being
C program termination problem clr20r3 solution
自定义注解之编译时注解(RetentionPolicy.CLASS)
进击的技术er,遇见实习岗位信息
Fault: 0x800ccc1a error when outlook sends and receives mail
Is it safe for Huatai Securities to open a stock account on it?
Notes on key vocabulary of the original English work biography of jobs (I) [introduction]
Object.defineProperty也能监听数组变化?
compiling stm32f4xx_ it. c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).
How to choose an account opening broker? Is it safe to open an account online?