Skip to content

Fix PFI issue in binary classification #4587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change to always call EvaluateNonCalibrated
  • Loading branch information
yaeldMS committed Jan 5, 2020
commit 2d53161efc9543f50fcd51da1398cd87472154d6
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,5 @@ internal CalibratedBinaryClassificationMetrics(IHost host, DataViewRow overallRe
LogLossReduction = Fetch(BinaryClassifierEvaluator.LogLossReduction);
Entropy = Fetch(BinaryClassifierEvaluator.Entropy);
}

[BestFriend]
internal CalibratedBinaryClassificationMetrics(double auc, double accuracy, double positivePrecision, double positiveRecall,
double negativePrecision, double negativeRecall, double f1Score, double auprc, double logLoss, double logLossReduction, double entropy)
: base(auc, accuracy, positivePrecision, positiveRecall, negativePrecision, negativeRecall, f1Score, auprc)
{
LogLoss = logLoss;
LogLossReduction = logLossReduction;
Entropy = entropy;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,6 @@ public static ImmutableArray<BinaryClassificationMetricsStatistics>
int? numberOfExamplesToUse = null,
int permutationCount = 1) where TModel : class
{
bool isCalibratedModel = false;
var type = predictionTransformer.Model.GetType();
if (type.IsGenericType)
{
var genArgs = type.GetGenericArguments();
if (Utils.Size(genArgs) == 2)
{
var calibratedModelType = typeof(CalibratedModelParametersBase<,>).MakeGenericType(genArgs);
if (calibratedModelType.IsAssignableFrom(type))
isCalibratedModel = true;
}
}
if (isCalibratedModel)
{
return PermutationFeatureImportance<TModel, BinaryClassificationMetrics, BinaryClassificationMetricsStatistics>.GetImportanceMetricsMatrix(
catalog.GetEnvironment(),
predictionTransformer,
data,
() => new BinaryClassificationMetricsStatistics(),
idv => catalog.Evaluate(idv, labelColumnName),
BinaryClassifierDelta,
predictionTransformer.FeatureColumnName,
permutationCount,
useFeatureWeightFilter,
numberOfExamplesToUse);
}
return PermutationFeatureImportance<TModel, BinaryClassificationMetrics, BinaryClassificationMetricsStatistics>.GetImportanceMetricsMatrix(
catalog.GetEnvironment(),
predictionTransformer,
Expand Down Expand Up @@ -199,23 +173,6 @@ private static BinaryClassificationMetrics BinaryClassifierDelta(
auprc: a.AreaUnderPrecisionRecallCurve - b.AreaUnderPrecisionRecallCurve);
}

private static CalibratedBinaryClassificationMetrics CalibratedBinaryClassifierDelta(
CalibratedBinaryClassificationMetrics a, CalibratedBinaryClassificationMetrics b)
{
return new CalibratedBinaryClassificationMetrics(
auc: a.AreaUnderRocCurve - b.AreaUnderRocCurve,
accuracy: a.Accuracy - b.Accuracy,
positivePrecision: a.PositivePrecision - b.PositivePrecision,
positiveRecall: a.PositiveRecall - b.PositiveRecall,
negativePrecision: a.NegativePrecision - b.NegativePrecision,
negativeRecall: a.NegativeRecall - b.NegativeRecall,
f1Score: a.F1Score - b.F1Score,
auprc: a.AreaUnderPrecisionRecallCurve - b.AreaUnderPrecisionRecallCurve,
logLoss: a.LogLoss - b.LogLoss,
logLossReduction: a.LogLossReduction - b.LogLossReduction,
entropy: a.Entropy - b.Entropy);
}

#endregion Binary Classification

#region Multiclass Classification
Expand Down