示例#1
0
        /// <summary>
        /// Connects a row classifier
        /// </summary>
        /// <param name="classifier"></param>
        /// <param name="dataTable"></param>
        /// <param name="analysis"></param>
        /// <param name="name">Optional name to give the node</param>
        /// <returns></returns>
        public WireBuilder AddClassifier(IRowClassifier classifier, IDataTable dataTable, IDataTableAnalysis analysis = null, string name = null)
        {
            var node = _factory.CreateClassifier(classifier, dataTable, analysis, name);

            _SetNode(node.RowClassifier);
            return(SetNewSize(node.OutputSize));
        }
示例#2
0
        /// <summary>
        /// Create a row classifier node
        /// </summary>
        /// <param name="classifier">The classifier for each row</param>
        /// <param name="dataTable">The data table that contains the rows to classify (linked by mini batch index)</param>
        /// <param name="analysis">Optional data table analysis data</param>
        /// <param name="name">Optional name to give the node</param>
        /// <returns></returns>
        public (INode RowClassifier, int OutputSize) CreateClassifier(IRowClassifier classifier,
                                                                      IDataTable dataTable, IDataTableAnalysis analysis = null, string name = null)
        {
            var ret = new RowClassifier(LinearAlgebraProvider, classifier, dataTable,
                                        analysis ?? dataTable.GetAnalysis(), name);

            return(ret, ret.OutputSize);
        }
示例#3
0
        //readonly List<IRow> _data = new List<IRow>();

        public RowClassifier(ILinearAlgebraProvider lap, IRowClassifier classifier,
                             IDataTable dataTable, IDataTableAnalysis analysis, string name = null) : base(name)
        {
            _lap         = lap;
            _dataTable   = dataTable;
            _classifier  = classifier;
            _targetLabel = analysis.ColumnInfo.First(ci => dataTable.Columns[ci.ColumnIndex].IsTarget).
                           DistinctValues.Select((v, i) => (v.ToString(), i)).ToDictionary(d => d.Item1, d => d.Item2);
        }
示例#4
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);
        }
示例#5
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);
        }
 /// <summary>
 /// Classifies each row of the data table
 /// </summary>
 /// <param name="classifier"></param>
 /// <param name="dataTable"></param>
 /// <returns>A list of rows with their corresponding classifications</returns>
 public static IReadOnlyList <(IRow Row, string Classification)> Classifiy(this IRowClassifier classifier, IDataTable dataTable)
 {
     return(dataTable.Classify(classifier, percentage => Console.Write("\r({0:P}) ", percentage)));
 }