当前位置: 首页 > news >正文

删除二维特征图中指定区域的样本

数据在df_renew中,特征分别是BlockadeDwell Time(ms),代码如下:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.path import Pathpolygon_vertices = [(0.87, 5.0),(0.88, 4.0),(0.882, 3),(0.9, 2.5),(0.92, 1),(0.95, 1),(0.9, 5),(0.87, 5.0),
]
polygon_path = Path(polygon_vertices)
points = np.column_stack((df_renew["Blockade"].values,df_renew["Dwell Time (ms)"].values))
inside_mask = polygon_path.contains_points(points)
#
plt.figure(figsize=(6, 6))
plt.scatter(df_renew["Blockade"], df_renew["Dwell Time (ms)"], s=10, alpha=0.5, label="All points")
plt.scatter(df_renew["Blockade"][inside_mask], df_renew["Dwell Time (ms)"][inside_mask],color='red', s=10, label="To be removed")
plt.plot(*zip(*polygon_vertices), color='black', linestyle='--', label='Polygon')
plt.fill(*zip(*polygon_vertices), alpha=0.1, color='gray')
plt.xlabel("Blockade")
plt.ylabel("Dwell Time (ms)")
plt.legend()
plt.title("Polygon-based removal")
plt.show()
#
df_renew = df_renew[~inside_mask] # 去除多边形内的点

在这里插入图片描述

http://www.dtcms.com/a/303096.html

相关文章:

  • linux系统----Ansible中的playbook简单应用
  • 【Java EE】多线程-初阶-线程的状态
  • java里List链式编程
  • 4、如何生成分布式ID?
  • Linux->模拟实现 fopen/fread/fwrite
  • Bruce Momjian 深圳 meetup 回顾
  • 大模型基础设施搭建 - 操作系统centos7
  • SDRAM
  • CTF-Web学习笔记:文件包含篇
  • 阿里给AI To C战略戴上眼镜
  • 4.应用层自定义协议与序列化
  • JUC线程池: ScheduledThreadPoolExecutor详解
  • VMWARE -ESXI-ntp时间同步无法启动异常处理
  • Go-Elasticsearch Typed Client 使用命名、结构与约定
  • Java 大视界 -- Java 大数据在智能安防入侵检测系统中的多源数据融合与误报率降低策略(369)
  • AI原生应用:从人机关系重构到数字空间革命
  • 【分布式版本控制系统】Git的使用
  • 力扣17:电话号码的字母组合
  • 若依【(前后端分离版)SpringBoot+Vue3】
  • Android通知(Notification)全面解析:从基础到高级应用
  • 数据结构:下三角矩阵(Lower Triangular Matrix)
  • Eigen 中矩阵的拼接(Concatenation)与 分块(Block Access)操作使用详解和示例演示
  • 秩为1的矩阵的特征和性质
  • WireShark 抓包
  • Spring Boot项目生产环境部署完整指南
  • 数学建模算法-day[13]
  • 判断回文链表【两种O(n)时间复杂度】
  • iOS WebView 调试实战,第三方脚本加载失败与内容安全策略冲突问题排查指南
  • 前端高级综合搜索组件 SearchBox 使用详解!
  • React中的合成事件解释和理解