admin管理员组文章数量:1356873
I'm hoping to get some advice on approaching a clustering problem. I have two separate spatial datasets, being real data and modelled data. The real data contains a binary output (0,1), which is displayed in the figure below. The green scatter points represent 1 and red is 0.
Is it possible to assign a probability (of being 1 attributed to real data) to the modelled data based on the binary output of the real data? On face value, a nearest neighbour approach makes the most sense but are there any other approaches that may be applicable?
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from itertools import cycle
real_data = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=['x1','y1'])
outcome = cycle([0,1])
real_data['Outcome'] = [next(outcome) for fruit in range(len(real_data))]
colors = np.where(real_data["Outcome"]==1,'green','red')
model_data = pd.DataFrame(np.random.randint(-25,125,size=(1000, 2)), columns=['x2','y2'])
fig, ax = plt.subplots()
ax.scatter(model_data['x2'], model_data['y2'], alpha=0.5, color = 'blue', zorder = -1)
ax.scatter(real_data['x1'], real_data['y1'], color = colors, s = 100, zorder = 0)
plt.show()
I'm hoping to get some advice on approaching a clustering problem. I have two separate spatial datasets, being real data and modelled data. The real data contains a binary output (0,1), which is displayed in the figure below. The green scatter points represent 1 and red is 0.
Is it possible to assign a probability (of being 1 attributed to real data) to the modelled data based on the binary output of the real data? On face value, a nearest neighbour approach makes the most sense but are there any other approaches that may be applicable?
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from itertools import cycle
real_data = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=['x1','y1'])
outcome = cycle([0,1])
real_data['Outcome'] = [next(outcome) for fruit in range(len(real_data))]
colors = np.where(real_data["Outcome"]==1,'green','red')
model_data = pd.DataFrame(np.random.randint(-25,125,size=(1000, 2)), columns=['x2','y2'])
fig, ax = plt.subplots()
ax.scatter(model_data['x2'], model_data['y2'], alpha=0.5, color = 'blue', zorder = -1)
ax.scatter(real_data['x1'], real_data['y1'], color = colors, s = 100, zorder = 0)
plt.show()
Share
Improve this question
edited Mar 28 at 4:36
Ken White
126k15 gold badges236 silver badges466 bronze badges
asked Mar 28 at 3:48
jonboyjonboy
3925 gold badges18 silver badges56 bronze badges
1 Answer
Reset to default 0If your data isn't governed by an underlying law involving regularities (which seems to be the case in your example), Knn is indeed what makes the most sense, and linear methods (Gaussian modeling, regression, etc.) won't help you.
The best is to use nonlinear methods. You could try using a random forest method. Decision trees create a tree structure that delineates areas and identifies clusters. You just need to limit the number of parameters to avoid overfitting (like max depth or min samples per leaf), especially on ambiguous data like the one you've shown.
本文标签: pythonSpatial clustering with two separate datasetsStack Overflow
版权声明:本文标题:python - Spatial clustering with two separate datasets - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744057946a2583595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论