Code Monkey home page Code Monkey logo

Comments (3)

RobinL avatar RobinL commented on June 5, 2024

Num bridges = 1 seems to only occur with cluster size = 2 in the synthetic data. Is there something wrong with the calculation?

from splink_graph.

RobinL avatar RobinL commented on June 5, 2024

This problem relates to the use of weight and distance in the graph calculation.

In particular, if you set the distance colname = 'weight' you get incorrect results:

from splink_graph.cluster_metrics import number_of_bridges
    
from pyspark.sql import Row
from pyspark.sql import functions as f 
data_list = [
    {"src": 1, "dst": 2, "weight":0.9, "cluster_id": 1},
    {"src": 2, "dst": 3, "weight":0.9, "cluster_id": 1},
    {"src": 3, "dst": 1, "weight":0.9, "cluster_id": 1},
        ]

data = spark.createDataFrame(Row(**x) for x in data_list)
cluster_num_bridges = number_of_bridges(data, distance_colname="weight")

cluster_num_bridges.toPandas()

Whilst my use of distance colname = 'weight' with the default weight_colname="weight" is illogical, we can avoid this problem altogether because the bridges calculation uses neither weight nor distance.

So we can simplify the function by removing both from the function signature

from splink_graph.

RobinL avatar RobinL commented on June 5, 2024

In the example code the problem is introduced here:
https://github.com/moj-analytical-services/splink_examples_synthetic_data/blob/4e649ac359a290a4749bf35b9ec58e7e20e2fe16/graph_analytics/person/uk_citizens_max_groupsize_20/basic/01_graph_analytics/job.py#L109

from splink_graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.