Skip to content

GraphEvaluation

Overview

The GraphEval class is designed to evaluate two graphs by calculating the intersection and computing evaluation metrics such as precision, recall, and F1 score. This class is part of the Euler Graph Database and extends the GraphConfig class.

Arguments

  • retrival_graph (Graph): Provide a union of sparse connected graph for the retrieval of the chunks.
  • response_graph (Graph): Provide a graph of generated response.

Example Usage

Here's an example demonstrating how to use the GraphEval class:

from euler.graph_evaluation import GraphEval, GraphEvaluationResponse

Initialize the Knowledge Graphs

context_retrival_graph = retrival_graph
final_response_graph = response_graph

Convert to NetworkX Graphs and Visualize

context_retrival_graph_x = context_retrival_graph.graph.to_networkx()
final_response_graph_x = final_response_graph.graph.to_networkx()

final_response_graph.visualize_graph()

Evaluate the Graphs

result = GraphEval(context_retrival_graph_x, final_response_graph_x).get_evaluation()

print(f"Precision: {result.eval_score[0]:.4f}")
print(f"Recall: {result.eval_score[1]:.4f}")
print(f"F1 Score: {result.eval_score[2]:.4f}")

Example Output

Precision: 0.7500
Recall: 0.6000
F1 Score: 0.6667

This documentation provides an overview, argument details, and a complete example of how to use the GraphEval class for evaluating graph intersections and computing precision, recall, and F1 score metrics.