Hi , i am an undergrad student from Bangladesh. I am working on a project and trying to classify brain tumor using federated learning. I choose flower framework for this and developed a code. During evaluating the performance of the updated local model on the test dataset (X_test , y_test ) to determine its accuracy, its showing an error.
##HERE IS THE CODE THAT I AM USING FOR SIMULATION
Hi @sejan16, the History object indeed is not iterable. You’ll need to access one of its attributes that are iterable. For example, to access the centralized accuracy you’d do:
history = fl.simulation.start_simulation(...)
# extract centralized accuracy
cen_accuracy = history.metrics_centralized["accuracy"] # <-- this is a list of tuples
# then you can create a simple line plot like this
import matplotlib.pyplot as plt
round_index = [idx for idx, _ in cen_accuracy]
global_acc = [acc for _, acc in cen_accuracy]
plt.plot(round_index, global_acc)
I believe something like the above should do. Let me know if it works!
Hi @sejan16 , it’s great to hear that you got that working. About your new error, it seems that the last_round_metrics you are creating in line 44 is already of type float. With the ["accuracy"][-1] you are already getting the last round metrics, so i think the final [1] in line 44 might not be needed?
In case of doubt, the best is to add some print statements to see what’s wrong.