当前位置:网站首页>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()

边栏推荐
- atguigu----01-脚手架
- Notes on key words in the original English work biography of jobs (III) [chapter one]
- Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being
- Exchange: manage calendar permissions
- 自定义注解之编译时注解(RetentionPolicy.CLASS)
- socket编程——epoll模型
- C language: count the number of words in a paragraph
- flutter 获取顶部状态栏的高度
- ICer必须知道的35个网站
- 【操作教程】TSINGSEE青犀视频平台如何将旧数据库导入到新数据库?
猜你喜欢

Wechat applet_ 7. Project practice, local life

关掉一个线程

¥3000 | 录「TBtools」视频,交个朋友&拿现金奖!

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

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

【OpenCV】—输入输出XML和YAML文件

Fault: 0x800ccc1a error when outlook sends and receives mail

对常用I/O模型进行比较说明

某次比赛wp

How to become a software testing expert? From 3K to 17k a month, what have I done?
随机推荐
十大券商开户风险大吗,安全靠谱吗?
声纹技术(一):声纹技术的前世今生
What is the difference between TP5 and tp6?
声纹技术(二):音频信号处理基础
Object. Can defineproperty also listen for array changes?
如何设计测试用例
Notes on key words in the original English work biography of jobs (III) [chapter one]
《乔布斯传》英文原著重点词汇笔记(一)【 Introduction 】
2021 "Ai China" selection
Summary of NLP data enhancement methods
C#程序终止问题CLR20R3解决方法
《乔布斯传》英文原著重点词汇笔记(四)【 chapter two 】
Sampling strategy and decoding strategy based on seq2seq text generation
声纹技术(三):声纹识别技术
atguigu----17-生命周期
Stimulsoft ultimate presents reports and dashboards
Is it safe to open a stock account through the account opening QR code of the account manager? Or is it safe to open an account in a securities company?
华泰证券在上面开股票账户安全吗?
IC研发常用英文术语缩写
进击的技术er,遇见实习岗位信息