[Python] Spatial clustering with two separate datasets

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    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()


    [​IMG]

    Continue reading...

Compartilhe esta Página