Search code examples
pythoncsvmachine-learningkerasroc

is it possible to log an ROC Curve onto a CSV file


I have generated an ROC curve using sklearn on python and was wondering if there was anyway to log the results onto a CSV file?

I was able to log model training data to CSV using the following CSV logger from keras

csv_logger = CSVLogger('training.log')
model.fit(X_train, Y_train, callbacks=[csv_logger])

If there was something similar to this for an ROC curve that would be perfect


Solution

  • Do you want it as a callback or post-fit is fine?

    post:

    import pandas as pd
    from sklearn import metrics
    ...
    fpr, tpr, thresholds = metrics.roc_curve(...)
    pd.DataFrame([fpr, tpr, thresholds]).to_csv("ROC.csv")
    ...
    roc = pd.read_csv("ROC.csv")