- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
更新了我的问题。见下文。
我有一个散点图,有很多噪音。我只想绘制密度阈值以上的点。
我用gaussian_kde计算了点的密度,但我不知道如何实现阈值。我想过屏蔽这些点,但这行不通。
thresh = 10
x = x_data
y = y_data
xy = np.vstack([x,y])
z = gaussian_kde(xy)(xy)
x1 = np.ma.masked_where(z > thresh, x) # mask points above threshold
y1 = np.ma.masked_where(z > thresh, y) # mask points above threshold
fig, ax = plt.subplots()
ax.scatter(x, y, c=z, s=10)
我期望绘图的噪音较少,但当我绘制 x1 和 y1 时,没有任何变化。我只想看到密度高的点。
<小时/>为了减少噪音,我尝试根据点的密度对点进行聚类。密度是用 gausian_kde 计算的。
我制作了 3D 散点图来估计分离簇的阈值。
x = x_data
y = y_data
xy = np.vstack([x,y])
z = gaussian_kde(xy)(xy)
cI_t = 0.0000059
cI_x = np.ma.masked_where(z < cI_t, x).compressed()
cI_y = np.ma.masked_where(z < cI_t, y).compressed()
cII_t = 0.0000165
cII_x = np.ma.masked_where(z < cII_t, x).compressed()
cII_x_1 = cII_x[(cII_y <= 252)]
cII_y = np.ma.masked_where(z < cII_t, y).compressed()
cII_y_1 = cII_y[(cII_y >= 252)]
cIII_t = 0.0000048
cIII_x = np.ma.masked_where(z < cIII_t, x).compressed()
cIII_y = np.ma.masked_where(z < cIII_t, y).compressed()
cIV_t = 0.00003
cIV_x = np.ma.masked_where(z < cIV_t, x).compressed()
cIV_y = np.ma.masked_where(z < cIV_t, y).compressed()
# 3D Density plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z)
plt.show()
# Scatter plot cII and cIV
fig2, ax2 = plt.subplots()
#plt.scatter(cI_x, cI_y)
plt.scatter(cII_x, cII_y)
#plt.scatter(cIII_x, cIII_y)
plt.scatter(cIV_x, cIV_y)
plt.axhline(y=255)
ax2.set_xlim(0,360)
ax2.set_ylim(0,360)
plt.show()
但知道我只需要从 cII 簇中选择顶部的蓝色点。有没有办法只选择蓝线上方的点。 (忽略橙色点,这是 cIV 簇。)
最佳答案
解决方案:
集群 cII 的示例:我根据 x 和 y 数据制作了一个 pandas 数据框,然后根据散点图中的值选择了点。
cII_t = 0.0000165
cII_x = np.ma.masked_where(z < cII_t, x).compressed()
cII_y = np.ma.masked_where(z < cII_t, y).compressed()
cII_df = pd.DataFrame({"x" : cII_x, "y" : c2II_y})
cII_df = cII_df[(cII_df["x"] >= 166) & (cII_df["x"] <= 227) & (cII_df["y"] >= 252) & (c2II_df["y"] <= 336)]
cII_x = cII_df["x"]
cII_y = cII_df["y"]
最终情节:
关于python - 基于密度阈值的聚类点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57216113/
我正在用 R 编写程序。我卡在这里。 我有像这样的矢量 X=c(84.05, 108.04, 13.95, -194.05, 64.03, 208.05, 84.13, 57.04) 我想在用 180
我正在编写一个应用程序,该应用程序涉及使用手指或手写笔在屏幕上书写。我有那部分工作。在 ACTION_DOWN 上,开始绘制;在 ACTION_MOVE 上,添加线段;在 ACTION_UP 上,完成
我正在尝试构建 OCR 以从图像中提取文本,我正在使用轮廓来形成文本字符的边界, 经过几次更改 cv2.threshold 的试验后,我在形成文本字符的边界时得到了最适合的轮廓。 #files = o
我正在尝试使用 OpenCV 的 cv::threshold函数(更具体 THRESH_OTSU ),只是我想用蒙版(任何形状)来做,以便在计算过程中忽略外部(背景)。 图像是单 channel (必
对于学校项目,我试图用 Python 编写一个程序来跟踪学生的运动。为了做到这一点,我正在使用 OpenCV。 在互联网上查找了一些教程后,我注意到几乎每个人都使用阈值来实现这一点,因为几乎每一步都需
我使用 jest 来驱动 selenium 测试,它报告一个需要 12 秒的测试缓慢(持续时间以红色突出显示)。在这种情况下,12 秒就可以了。 如何将阈值配置为 30 秒? 最佳答案 Jest is
我想找到 list1 中与 list2 中的值足够接近的值(基于指定的阈值),即与下面的代码类似的功能。然而,与 pyhton 的 set 交集相比,下面的 intersect_with_thresh
我正在尝试创建一张图表上有两个系列并带有阈值选项的浮线图。我知道当我只有 1 个系列时如何启用阈值(就像这里 http://people.iola.dk/olau/flot/examples/thre
我已正确应用 d3 (v 4.0) 直方图函数对数据数组进行分箱。我的代码如下所示: var bins = d3.histogram() .domain([data_points_min,
我正在使用带有自然语言全文的 Mysql FULLTEXT 搜索,不幸的是,我遇到了 FULLTEXT 50% 阈值,如果给定的关键字出现在总行数的 50% 时间,则不允许我搜索行。 我搜索并找到了一
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
这是我的绘图数据 var data = [{ data: [[4, 80], [8, 50], [9, 130]], color: "r
是否可以制作Canny忽略短边还是忽略低梯度边?在我的例子中,我将卡片放在木头上,并在 canny 之后看到木结构的许多边缘 canny 函数中的两个阈值有什么用? 最佳答案 Large intens
我正在尝试使用 OpenCV 的 cv::threshold 函数(更具体的 THRESH_OTSU),只是我想使用掩码(任何形状) ), 以便在计算过程中忽略外部(背景)。 图像是单 channel
我正在寻找根据提供的音频、频率范围(例如 20hz-1000hz)和阈值缩放 PNG 文件,以获得平滑的效果。 例如,当有脚踢时,比例平滑到 120%,我想让那些音频可视化器,如 dubstep 等.
我正在尝试找到最佳阈值,以使我的逻辑回归具有最高的 f1 分数。但是,当我写下以下几行时: val f1Score = metrics.fMeasureByThreshold f1Score.fore
我使用 Flot 创建了一个实时(每 10 毫秒更新一次)垂直样条图。图表可见here on Codepen 。我包括了 Flot multiple threshold plugin ,但我希望阈值使
我有一个数据框,其中包含从第 1 天到第 7 天的三个人(John、Terry、Henry)的分数。 1 2 3 4 5 6 7
我正在尝试实现多级 Otsu 阈值,更具体地说,我需要 3 个阈值/4 个类。 我知道关于 SO 的 2 个类似问题:#34856019 和 #22706742。问题是我没有得到好的结果:我已经阅读了
The documentation在 THRESH_BINARY 上说: dst(x,y) = maxval if src(x,y) > thresh else 0 这对我来说并不意味着这不适用于彩色
我是一名优秀的程序员,十分优秀!