Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

neural network - How to get y_true, when working with keras flow_from_dataframe?

I am trying to plot ROC AUC curve of a multilable classification problem. For that I need 'y_true' and 'y_pred'. see the following code line.

fpr, tpr, tresholds = roc_curve(y_true,y_pred)

I am using keras flow_from_dataframe and model.predict_generator. The model.predict_generator gives the y_pred, but how can I get the y_true. I have gone through simillar problems here, proposed solutions say, use test_generator.classes or test_generator.class_indices. But when try to use them I get this error message

AttributeError: 'DataFrameIterator' object has no attribute 'class_indices'

Please see code below.

pred=model.predict_generator(test_generator,steps=STEP_SIZE_TEST,verbose=2)

Here is the code for test_generator.

test_generator=test_datagen.flow_from_dataframe(
    dataframe=validation_labels[159:],
    directory="D:/data",
    x_col="Path",
    batch_size=1,
    seed=42,
    shuffle=False,
    class_mode=None,
    target_size=(224,224))
question from:https://stackoverflow.com/questions/66062698/how-to-get-y-true-when-working-with-keras-flow-from-dataframe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...