Skip to content

Commit 93ecbb7

Browse files
authored
Revert to using the native code (dotnet#413)
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.
1 parent 0d5e317 commit 93ecbb7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Microsoft.ML.FastTree/FastTreeRanking.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
767767
{
768768
// calculates the permutation that orders "scores" in descending order, without modifying "scores"
769769
Array.Copy(_oneTwoThree, permutation, numDocuments);
770-
#if USE_FASTTREENATIVE2
770+
#if USE_FASTTREENATIVE
771771

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

831833
// For computing the "ideal" case of the DCGs.
832834
if (_baselineDcg != null)
833835
{
834-
if (scoresToUse == _scores)
835-
Array.Copy(_scores, begin, _scoresCopy, begin, numDocuments);
836+
if (scoresToUse == Scores)
837+
Array.Copy(Scores, begin, _scoresCopy, begin, numDocuments);
836838
for (int i = begin; i < begin + numDocuments; ++i)
837839
{
838-
_scoresCopy[i] += _gradient[i] / _weights[i];
840+
_scoresCopy[i] += Gradient[i] / Weights[i];
839841
}
840842
Array.Copy(_oneTwoThree, permutation, numDocuments);
841843
PermutationSort(permutation, _scoresCopy, labels, numDocuments, begin);

0 commit comments

Comments
 (0)