Closed prathyusha12345 closed 5 years ago
Does your test data contain negative labels? It's possible that your test data is too small so that AUC is not a well-defined metric (to compute AUC, we need at least one positive and one negative labels).
@wschin The data classes are as below
public class SentimentData
{
public bool Label { get; set; }
public string Text { get; set; }
//// Additional property for testing purpose
//public string Expected { get; set; }
}
public class SentimentPrediction
{
[ColumnName("PredictedLabel")]
public bool Prediction { get; set; }
public float Probability { get; set; }
public float Score { get; set; }
}
The training and test data is as below
public static List<SentimentData> GetTrainingData()
{
return new List<SentimentData>
{
new SentimentData
{
Label = true,
Text = "Good service."
},
new SentimentData
{
Label = true,
Text = "Very good service"
},
new SentimentData
{
Label = true,
Text = "Amazing service"
},
new SentimentData
{
Label = true,
Text = "Great staff, will visit again. thanks for the gift"
},
new SentimentData
{
Label = false,
Text = "Bad staff, bad service. Will never visit this hotel"
},
new SentimentData
{
Label = false,
Text = "The service was very bad"
},
new SentimentData
{
Label = false,
Text = "Hotel location is worst"
}
};
}
public static List<SentimentData> GetTestData()
{
return new List<SentimentData>
{
new SentimentData
{
Label = true,
Text = "Worst hotel in New York"
//Expected = "Negative"
},
new SentimentData
{
Label = true,
Text = "I ordered pizza and recieved Wine. Bad staff"
//,
//Expected = "Negative"
},
new SentimentData
{
Label = true,
Text = "The hotel was so amazing, and they givena bag to me on gift"
//,
//Expected = "Positive"
},
new SentimentData
{
Label = true,
Text = "The hotel staff was great, will visit again"
//,
//Expected = "Positive"
}
};
}
Don't apply MapValueToKey
for label column. Binary classification works on top of boolean labels.
In 0.12 (which should be out today, or tomorrow) boolean is only acceptable type for binary classification label.
@Ivanidzo4ka Ok. Actually there was an issue created in our samples repo here . while working on that I tried MapKeyToValue transformation to convert label values true,false to numeric values. If I remove that MapKeyValue() mapping and upgrade to v0.12 , does this sample works?
No, because your test data contains only positive examples and it's pointless to calculate metrics on data with only one class presented.
Try this test data and then you should get AUC.
public static List<SentimentData> GetTestData()
{
return new List<SentimentData>
{
new SentimentData
{
Label = true,
Text = "Worst hotel in New York"
//Expected = "Negative"
},
new SentimentData
{
Label = true,
Text = "I ordered pizza and recieved Wine. Bad staff"
//,
//Expected = "Negative"
},
new SentimentData
{
Label = true,
Text = "The hotel was so amazing, and they givena bag to me on gift"
//,
//Expected = "Positive"
},
new SentimentData
{
Label = false,
Text = "Sadly, a negative data point."
//,
//Expected = "Negative"
}
};
}
OK. Thanks for correcting...I am closing the issue.
I am getting below error when I am evaluating the model.
System.ArgumentOutOfRangeException: 'AUC is not definied when there is no negative class in the data Parameter name: NegSample'
Source code / logs
The values of label column are true/false. I applied transformation on label using MapValuetoKey to convert true to 1 and false to 0. But I still get the error while evaluating.
See the below code.