public Metadata(string name, Attribute[] attributes, NominalAttribute target, bool isHierarchical) { this._name = name; this._attributes = attributes; this._target = target; this._isHierarchical = isHierarchical; }
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); }
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); }
public override Data.Attribute Clone() { Data.NominalAttribute clone = new NominalAttribute(this._name, this._index, this._values.Clone() as string[]); return(clone); }