Skip to content

Commit

Permalink
Revert to using the native code (dotnet#413)
Browse files Browse the repository at this point in the history
Corrects an unintentional "typo" in FastTreeRanking.cs where there was mistakenly a USE_FASTTREENATIVE2 instead of USE_FASTTREENATIVE. This resulted in some obscure hidden ranking options (distance weighting, normalize query lambdas, and a few others) being unavailable. These are important for some applications.
  • Loading branch information
TomFinley authored Jun 26, 2018
1 parent 0d5e317 commit 93ecbb7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Microsoft.ML.FastTree/FastTreeRanking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
{
// calculates the permutation that orders "scores" in descending order, without modifying "scores"
Array.Copy(_oneTwoThree, permutation, numDocuments);
#if USE_FASTTREENATIVE2
#if USE_FASTTREENATIVE

PermutationSort(permutation, scoresToUse, labels, numDocuments, begin);
// Get how far about baseline our current
Expand Down Expand Up @@ -818,24 +818,26 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
if (!_trainDcg && (_costFunctionParam == 'c' || _useShiftedNdcg))
{
PermutationSort(permutation, scoresToUse, labels, numDocuments, begin);
inverseMaxDcg = 1.0 / DCGCalculator.MaxDCGQuery(labels, begin, numDocuments, numDocuments, _labelCounts[query]);
inverseMaxDcg = 1.0 / DcgCalculator.MaxDcgQuery(labels, begin, numDocuments, numDocuments, _labelCounts[query]);
}
C_GetDerivatives(numDocuments, begin, pPermutation, pLabels,
// A constant related to secondary labels, which does not exist in the current codebase.
const bool secondaryIsolabelExclusive = false;
GetDerivatives(numDocuments, begin, pPermutation, pLabels,
pScores, pLambdas, pWeights, pDiscount,
inverseMaxDcg, pGainLabels,
_secondaryMetricShare, _secondaryIsolabelExclusive, secondaryInverseMaxDcg, pSecondaryGains,
_secondaryMetricShare, secondaryIsolabelExclusive, secondaryInverseMaxDcg, pSecondaryGains,
pSigmoidTable, _minScore, _maxScore, _sigmoidTable.Length, _scoreToSigmoidTableFactor,
_costFunctionParam, _distanceWeight2, numActualResults, &lambdaSum, double.MinValue,
_baselineAlphaCurrent, baselineDcgGap);

// For computing the "ideal" case of the DCGs.
if (_baselineDcg != null)
{
if (scoresToUse == _scores)
Array.Copy(_scores, begin, _scoresCopy, begin, numDocuments);
if (scoresToUse == Scores)
Array.Copy(Scores, begin, _scoresCopy, begin, numDocuments);
for (int i = begin; i < begin + numDocuments; ++i)
{
_scoresCopy[i] += _gradient[i] / _weights[i];
_scoresCopy[i] += Gradient[i] / Weights[i];
}
Array.Copy(_oneTwoThree, permutation, numDocuments);
PermutationSort(permutation, _scoresCopy, labels, numDocuments, begin);
Expand Down

0 comments on commit 93ecbb7

Please sign in to comment.