Esempio n. 1
0
        public IReadOnlyList <RowClassification> Classify(IRowClassifier classifier)
        {
            var ret = new List <RowClassification>();

            _Iterate(row => {
                ret.Add(new RowClassification(row, classifier.Classify(row).First()));
                return(true);
            });
            return(ret);
        }
Esempio n. 2
0
        public IReadOnlyList <(IRow Row, string Classification)> Classify(IRowClassifier classifier, Action <float> progress = null)
        {
            var   ret   = new List <(IRow, string)>();
            float total = RowCount;

            _Iterate((row, i) => {
                var bestClassification = classifier.Classify(row).GetBestClassification();
                ret.Add((row, bestClassification));
                progress?.Invoke(i / total);
                return(true);
            });
            return(ret);
        }
Esempio n. 3
0
        public override void ExecuteForward(IContext context)
        {
            var rowList    = context.BatchSequence.MiniBatch.Rows.Select(i => _data[i]).ToList();
            var resultList = new List <Dictionary <int, float> >();

            foreach (var row in rowList)
            {
                var value = _classifier.Classify(row)
                            .Select(c => (_targetLabel[c.Label], c.Weight))
                            .ToDictionary(d => d.Item1, d => d.Item2)
                ;
                resultList.Add(value);
            }
            var output = _lap.CreateMatrix(resultList.Count, _targetLabel.Count, (i, j) => resultList[i].TryGetValue(j, out float temp) ? temp : 0f);

            _AddNextGraphAction(context, new MatrixGraphData(output), null);
        }