当前位置:网站首页>Matplotlib simple logistic regression visualization
Matplotlib simple logistic regression visualization
2022-06-25 08:59:00 【Guoqingru】
matplotlib matplotlib Visualization of simple logistic regression in
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()
边栏推荐
- WebGL谷歌提示内存不够(RuntimeError:memory access out of bounds,火狐提示索引超出界限(RuntimeError:index out of bounds)
- WebGL发布之后不可以输入中文解决方案
- Chinese solution cannot be entered after webgl is published
- How to choose an account opening broker? Is it safe to open an account online?
- How annotation lib and processor lib reference
- Notes on key words in the original English work biography of jobs (II) [chapter one]
- 三、自动终止训练
- [MySQL] understanding and use of indexes
- C language: bubble sort
- Object. Can defineproperty also listen for array changes?
猜你喜欢
Fault: 0x800ccc1a error when outlook sends and receives mail
How to solve the 10061 error of MySQL in Linux
C # startup program loses double quotation marks for parameters passed. How to solve it?
自定义注解之编译时注解(RetentionPolicy.CLASS)
cazy長安戰役八卦迷宮
【OpenCV】—离散傅里叶变换
C language "Recursion Series": recursively realizing the n-th power of X
Cazy eight trigrams maze of Chang'an campaign
matplotlib matplotlib中axvline()和axhline()函数
二、训练fashion_mnist数据集
随机推荐
C language "recursive series": recursive implementation of 1+2+3++ n
When unity released webgl, jsonconvert Serializeobject() conversion failed
Wechat applet_ 7. Project practice, local life
Various synchronous learning notes
Notes on key words in the original English work biography of jobs (IV) [chapter two]
Openfoam: bottom layer
In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
Is it safe to open a stock account online now?
Unity--Configurable Joint——简单教程,带你入门可配置关节
获取扫码的客户端是微信还是支付宝
Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed
【无标题】**数据库课设:三天完成学生信息管理系统**
Jmeter接口测试,关联接口实现步骤(token)
Hyper-v:hyper-v generation 1 or generation 2 virtual machines
106. simple chat room 9: use socket to transfer audio
[untitled] * * database course design: complete the student information management system in three days**
Are the top ten securities companies at great risk of opening accounts and safe and reliable?
flutter 多语言的intl: ^0.17.0导不进去
通过客户经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
六级易混词整理