コード例 #1
0
            private void ProcessRowSecondPass()
            {
                AssertValid(assertGetters: true);

                _featGetter(ref _features);
                _scoreGetter(ref _scores);
                Host.Check(_scores.Length == _scoresArr.Length);

                if (VBufferUtils.HasNaNs(ref _scores) || VBufferUtils.HasNonFinite(ref _scores))
                {
                    return;
                }
                _scores.CopyTo(_scoresArr);
                int j = 0;

                foreach (var index in Enumerable.Range(0, _scoresArr.Length).OrderBy(i => _scoresArr[i]))
                {
                    _indicesArr[j++] = index;
                }

                UnweightedCounters.UpdateSecondPass(ref _features, _indicesArr);
                if (WeightedCounters != null)
                {
                    WeightedCounters.UpdateSecondPass(ref _features, _indicesArr);
                }
            }
コード例 #2
0
            private void ProcessRowFirstPass()
            {
                AssertValid(assertGetters: true);

                Single label = 0;

                _labelGetter(ref label);
                if (Single.IsNaN(label))
                {
                    NumUnlabeledInstances++;
                    label = 0;
                }
                var intLabel = (int)label;

                if (intLabel != label || intLabel < 0)
                {
                    throw Host.Except("Invalid label: {0}", label);
                }

                _scoreGetter(ref _scores);
                Host.Check(_scores.Length == _scoresArr.Length);

                if (VBufferUtils.HasNaNs(ref _scores) || VBufferUtils.HasNonFinite(ref _scores))
                {
                    NumBadScores++;
                    return;
                }
                _scores.CopyTo(_scoresArr);
                Single weight = 1;

                if (_weightGetter != null)
                {
                    _weightGetter(ref weight);
                    if (!FloatUtils.IsFinite(weight))
                    {
                        NumBadWeights++;
                        weight = 1;
                    }
                }

                int j = 0;

                foreach (var index in Enumerable.Range(0, _scoresArr.Length).OrderBy(i => _scoresArr[i]))
                {
                    _indicesArr[j++] = index;
                }

                UnweightedCounters.UpdateFirstPass(intLabel, _scoresArr, 1, _indicesArr);
                if (WeightedCounters != null)
                {
                    WeightedCounters.UpdateFirstPass(intLabel, _scoresArr, weight, _indicesArr);
                }

                if (_clusterCentroids != null)
                {
                    _featGetter(ref _features);
                    VectorUtils.Add(ref _features, ref _clusterCentroids[_indicesArr[0]]);
                }
            }