wagpa / embedding-eval-framework

0 stars 0 forks source link

Use model to recreate graph and display #14

Closed wagpa closed 1 year ago

wagpa commented 1 year ago

Use to check, that model does nothing funny like always saying, that points are not connected.

wagpa commented 1 year ago

Test 1

args = Map(
    batch_size = 64,
    epochs = 10,
    random_seed = None,
    graph_size = 20,
    graph_average_degree = 5,
    layers = 3,
    layer_size = 16
)

Generated

image

Predicted

With accuracy: 0.7900 image

wagpa commented 1 year ago

Test 2

args = Map( batch_size = 64, epochs = 100, random_seed = None, graph_size = 100, graph_average_degree = 10, layers = 3, layer_size = 16 )

image

accuracy: 0.9911

image

wagpa commented 1 year ago

Test 1 and 2 used the following code to generate the predicted graph

pred_graph = nx.create_empty_copy(nx_graph, with_data=True)

pairs = [ (x, y) for x in range(nx_graph.number_of_nodes()) for y in range(nx_graph.number_of_nodes()) ]
predictions = probability_model.predict([[nodes[pair[0]]['pos'][0], nodes[pair[0]]['pos'][1], nodes[pair[1]]['pos'][0], nodes[pair[1]]['pos'][1]] for pair in pairs ])
#predictions = probability_model.predict([np.append((nodes[pair[0]]['pos']), (nodes[pair[1]]['pos'])) for pair in pairs ])
edges = [ pair for pair, prediction in zip(pairs, predictions) if prediction[0] ]
pred_graph.add_edges_from(edges)

nx.draw(pred_graph, pos, node_size=10)
wagpa commented 1 year ago

The above hidden tests 1 and 2 used an badly chosen prob model. With a better one: (e027c732ee9c6c459747416feb9a62aeacae7beb)

image loss: 0.0409 - accuracy: 0.9848 - recall_16: 1.0000 - auc_13: 0.9990 image Where from blue to red means higher prediction. Prediction means here probHasConnection - probHasNoConnection where positive.

colors = np.array([ (prediction[0] - prediction[1], 1 - (prediction[0] - prediction[1]), 1) for prediction in predictions if (prediction[0] >= prediction[1]) ])

wagpa commented 1 year ago

With same code as above

image loss: 0.0108 - accuracy: 0.9956 - recall_17: 1.0000 - auc_14: 0.9999 image

Without loops image

wagpa commented 1 year ago

image loss: 0.0070 - accuracy: 0.9968 - recall_4: 1.0000 - auc_4: 0.9240 image