예제 #1
0
        public Runtime[] Partition(params int[] points)
        {
            if (points == null || points.Length == 0)
            {
                throw new ArgumentNullException("points");
            }

            var ends        = points.Concat(new [] { NumInstances }).ToArray();
            var atts        = EnumerateAttributes.Select(a => a.Impl).ToArrayList();
            var start       = 0;
            var cumm        = 0;
            var partitioned = ends.
                              Select(end => {
                var name     = String.Format("partition-{0}-{1}", start, end);
                var instance = new Instances(name, atts, end - start);
                instance.setClassIndex(ClassIndex);
                for (int i = start; i < end; i++)
                {
                    cumm++; instance.add(Instance(i).Impl);
                }
                start = end;
                return(new Runtime(instance));
            }).
                              ToArray();

            if (cumm != NumInstances)
            {
                throw new ApplicationException("Partition did not work as expected.  Expected " + NumInstances + " instances to be copied, actually got: " + cumm);
            }
            return(partitioned);
        }
예제 #2
0
        // weka.core.converters.CSVSaver throws exception
        public void SaveToCsvFile(string filename)
        {
            var headings = String.Join(",", EnumerateAttributes.Select(a => a.Name));
            var idxs     = Enumerable.Range(0, NumAttributes);
            var lines    = this.Select(i => String.Join(",", idxs.Select(i.StringValue))).ToList();

            lines.Insert(0, headings);
            File.WriteAllLines(filename, lines);
        }
예제 #3
0
 public IEnumerator <PmlAttribute> GetEnumerator()
 {
     return(EnumerateAttributes.GetEnumerator());
 }