示例#1
0
 public Metadata(string name, Attribute[] attributes, NominalAttribute target, bool isHierarchical)
 {
     this._name           = name;
     this._attributes     = attributes;
     this._target         = target;
     this._isHierarchical = isHierarchical;
 }
示例#2
0
        public Dataset GetBinaryFlatLabelSubDataset(string positiveClassValue, string[] negativeClassValues)
        {
            string name       = this._metadata.DatasetName;
            int    classIndex = this._metadata.Target.GetIndex(positiveClassValue);


            DataMining.Data.Attribute[] attClone = new Attribute[this.Metadata.Attributes.Length];
            for (int attributeIndex = 0; attributeIndex < this.Metadata.Attributes.Length; attributeIndex++)
            {
                attClone[attributeIndex] = this.Metadata.Attributes[attributeIndex].Clone();
            }

            Data.NominalAttribute    target   = new NominalAttribute("class", this._metadata.Target.Index, new string[] { "Yes", "No" });
            DataMining.Data.Metadata metadata = new Data.Metadata(name, attClone, target, false);

            Dataset dsResult = new Dataset(metadata);


            int            positiveClassIndex = this._metadata.Target.GetIndex(positiveClassValue);
            List <Example> positive           = new List <Example>();

            int pcounter = 0;

            foreach (int exampleIndex in this.Filter(classIndex))
            {
                positive.Add(new Example(dsResult.Metadata, pcounter++, this[exampleIndex].Values, 0));
            }

            List <Example> negative = new List <Example>();

            int ncounter = 0;

            foreach (string negativeClassValue in negativeClassValues)
            {
                int negativeClassIndex = this._metadata.Target.GetIndex(negativeClassValue);
                foreach (int exampleIndex in this.Filter(negativeClassIndex))
                {
                    if (!negative.Exists(e => e.Index == exampleIndex))
                    {
                        negative.Add(new Example(dsResult.Metadata, ncounter++, this[exampleIndex].Values, 1));
                    }
                }
            }


            List <Example> examples = new List <Example>();

            examples.AddRange(positive);
            examples.AddRange(negative);
            dsResult.SetExamples(examples.ToArray());

            return(dsResult);
        }
示例#3
0
        public Metadata Clone()
        {
            NominalAttribute target = this._target.Clone() as NominalAttribute;

            DataMining.Data.Attribute [] attClone = new Attribute[this._attributes.Length];
            for (int attributeIndex = 0; attributeIndex < this._attributes.Length; attributeIndex++)
            {
                attClone[attributeIndex] = this._attributes[attributeIndex].Clone();
            }


            Metadata clone = new Metadata(_name, attClone, target, _isHierarchical);

            return(clone);
        }
示例#4
0
 public override Data.Attribute Clone()
 {
     Data.NominalAttribute clone = new NominalAttribute(this._name, this._index, this._values.Clone() as string[]);
     return(clone);
 }