public void Invalidate(ACO.DecisionComponent <DRComponent> component, ACO.Solution <DRComponent> solution, ACO.ConstructionGraph <DRComponent> graph) { int index = component.Index; if (component.Element.Include) { index += 2; } else { index += 1; } for (int i = index - 2; i < index; i++) { graph.Components[i].IsValid = false; } if (index < graph.Components.Length) { for (int i = index; i < index + 2; i++) { graph.Components[i].IsValid = true; } } }
private void InvalidateLoops(ACO.DecisionComponent <ConnectionDC> input, ACO.Solution <ConnectionDC> solution, ACO.ConstructionGraph <ConnectionDC> graph) { int dependencies = 0; int switchIndex = (InputUnitCount * HiddenUnitCount) + (InputUnitCount * OutputUnitCount) + (HiddenUnitCount * OutputUnitCount); int switchIndex2 = (InputUnitCount * HiddenUnitCount * 2) + (InputUnitCount * OutputUnitCount * 2) + (HiddenUnitCount * OutputUnitCount * 2); for (int index = switchIndex; index < solution.Components.Count; index++) { DecisionComponent <ConnectionDC> component = solution.Components[index]; if (input.Element.Connection.To == component.Element.Connection.To) { dependencies++; } } List <int> descendantIndexes = this.GetDescendantIndexes(input.Element, solution); List <int> ancestorIndexes = this.GetAncestorIndexes(input.Element, solution); List <DecisionComponent <ConnectionDC> > validComponents = graph.GetValidComponents(switchIndex2, graph.Components.Length - switchIndex2); foreach (DecisionComponent <ConnectionDC> component in validComponents) { if (component.Element.Connection.To == input.Element.Connection.To && component.Element.Connection.From == input.Element.Connection.From) { component.IsValid = false; continue; } if (component.Element.Connection.To == input.Element.Connection.To) { if (dependencies == MaxParents) { component.IsValid = false; continue; } } if (descendantIndexes.Contains(component.Element.Connection.From)) { if (ancestorIndexes.Contains(component.Element.Connection.To)) { component.IsValid = false; continue; } } if (ancestorIndexes.Contains(component.Element.Connection.To)) { if (descendantIndexes.Contains(component.Element.Connection.From)) { component.IsValid = false; continue; } } } }
public override void CalculateHeuristics(ACO.DecisionComponent <DRComponent> component) { if (component.Element.ElementType == DatasetElementType.Attribute) { this._entropyCalculator.CalculateHeuristics(component); } else { this._iblCalculator.CalculateHeuristics(component); } }
public override void CalculateHeuristics(ACO.DecisionComponent <DRComponent> component) { if (component.Element.Include) { component.Heuristic = this._probabilities[component.Element.ElemetIndex]; } else { component.Heuristic = 1 - this._probabilities[component.Element.ElemetIndex]; } }
public override void CalculateHeuristics(ACO.DecisionComponent <DRComponent> component) { if (component.Element.Include) { component.Heuristic = 0.66; } else { component.Heuristic = 0.33; } }
public override void CalculateHeuristics(ACO.DecisionComponent <DRComponent> component) { double entopy = this._entopy[component.Element.ElemetIndex]; if (component.Element.Include) { component.Heuristic = 1 - entopy; } //component.Heuristic = this._maxEntopy - entopy; else { component.Heuristic = entopy; } }
public void Invalidate(ACO.DecisionComponent <Edge> input, Solution <Edge> solution, ACO.ConstructionGraph <Edge> graph) { int dependencies = 0; foreach (DecisionComponent <Edge> solutionElement in solution.Components) { if (input.Element.ChildIndex == solutionElement.Element.ChildIndex) { dependencies++; } } List <int> descendantIndexes = this.GetDescendantIndexes(input.Element, solution); List <int> ancestorIndexes = this.GetAncestorIndexes(input.Element, solution); foreach (DecisionComponent <Edge> component in graph.GetValidComponents()) { if (component.Element.ChildIndex == input.Element.ChildIndex && component.Element.ParentIndex == input.Element.ParentIndex) { component.IsValid = false; } if (component.Element.ChildIndex == input.Element.ChildIndex) { if (dependencies == this._maxDependencies) { component.IsValid = false; } } if (descendantIndexes.Contains(component.Element.ParentIndex)) { if (ancestorIndexes.Contains(component.Element.ChildIndex)) { component.IsValid = false; } } if (ancestorIndexes.Contains(component.Element.ChildIndex)) { if (descendantIndexes.Contains(component.Element.ParentIndex)) { component.IsValid = false; } } } }
public void Invalidate(ACO.DecisionComponent <VariableTypeAssignment> component, ACO.Solution <VariableTypeAssignment> solution, ACO.ConstructionGraph <VariableTypeAssignment> graph) { int index = component.Element.VariableIndex; int elementIndex = (index + 1) * 3; for (int i = elementIndex - 3; i < elementIndex; i++) { graph.Components[i].IsValid = false; } if (elementIndex < graph.Components.Length) { for (int i = elementIndex; i < elementIndex + 3; i++) { graph.Components[i].IsValid = true; } } }
public void CalculateHeuristics(ACO.DecisionComponent <ConnectionDC> component) { if (component.Element.Connection.FromLayerType == NeuralNetworks.Model.LayerType.Input) { if (component.Element.Connection.ToLayerType == NeuralNetworks.Model.LayerType.Hidden) { if (component.Element.Include) { component.Heuristic = this._ratio; } else { component.Heuristic = 1 - _ratio; } } else { component.Heuristic = 1; } } else if (component.Element.Connection.FromLayerType == NeuralNetworks.Model.LayerType.Hidden) { if (component.Element.Connection.ToLayerType == NeuralNetworks.Model.LayerType.Output) { if (component.Element.Include) { component.Heuristic = this._ratio; } else { component.Heuristic = 1 - this._ratio; } } else { component.Heuristic = 1; } } else { component.Heuristic = 1; } }
public void Invalidate(ACO.DecisionComponent <ConnectionDC> component, ACO.Solution <ConnectionDC> solution, ACO.ConstructionGraph <ConnectionDC> graph) { int switchIndex = (InputUnitCount * HiddenUnitCount * 2) + (InputUnitCount * OutputUnitCount * 2) + (HiddenUnitCount * OutputUnitCount * 2); if (SecondPhase) { this.InvalidateLoops(component, solution, graph); } else { int index = component.Index; if (component.Element.Include) { index += 2; } else { index += 1; } for (int i = index - 2; i < index; i++) { graph.Components[i].IsValid = false; } if (index >= switchIndex) { this.SecondPhase = true; for (int i = index; i < graph.Components.Length; i++) { graph.Components[i].IsValid = true; } } else { for (int i = index; i < index + 2; i++) { graph.Components[i].IsValid = true; } } } }
public void Invalidate(ACO.DecisionComponent <ClusterExampleAssignment> component, ACO.Solution <ClusterExampleAssignment> solution, ACO.ConstructionGraph <ClusterExampleAssignment> graph) { int index = component.Element.ExampleID; int elementIndex = (index + 1) * this._clustersNumber; for (int i = elementIndex - this._clustersNumber; i < elementIndex; i++) { graph.Components[i].IsValid = false; } if (elementIndex < graph.Components.Length) { for (int i = elementIndex; i < elementIndex + this._clustersNumber; i++) { graph.Components[i].IsValid = true; } } }
public void CalculateHieristicValue(ACO.DecisionComponent <Edge> Element) { iFourmi.DataMining.Data.Attribute xAttribute = this._dataset.Metadata.Attributes[Element.Element.ParentIndex]; iFourmi.DataMining.Data.Attribute yAttribute = this._dataset.Metadata.Attributes[Element.Element.ChildIndex]; //iFourmi.DataMining.Data.Attribute zAttribute = this._dataset.Metadata.Target; double MI = 0; double size = this._dataset.Size; double xy = 0; double x = 0; double y = 0; List <int> attributeIndexes2 = new List <int>(); attributeIndexes2.Add(xAttribute.Index); attributeIndexes2.Add(yAttribute.Index); List <int> valueIndexes2 = new List <int>(); valueIndexes2.Add(0); valueIndexes2.Add(0); for (int xi = 0; xi < xAttribute.Values.Length; xi++) { x = xAttribute.ValueCounts[xi]; x = x / size; for (int yi = 0; yi < yAttribute.Values.Length; yi++) { y = yAttribute.ValueCounts[yi]; y = y / size; valueIndexes2[0] = xi; valueIndexes2[1] = yi; xy = this._dataset.Filter(attributeIndexes2, valueIndexes2).Count; xy = xy / size; double value = xy * Math.Log(xy / (x * y)); if (!double.IsNaN(value) && !double.IsInfinity(value)) { MI += value; } } } if (MI <= 0) { MI = 0; } Element.Heuristic = MI; }
public void CalculateHieristicValue(ACO.DecisionComponent <Edge> Element) { iFourmi.DataMining.Data.Attribute xAttribute = this._dataset.Metadata.Attributes[Element.Element.ParentIndex]; iFourmi.DataMining.Data.Attribute yAttribute = this._dataset.Metadata.Attributes[Element.Element.ChildIndex]; iFourmi.DataMining.Data.Attribute zAttribute = this._dataset.Metadata.Target; double CMI = 0; double size = this._dataset.Size; double xy_z = 0; double x_z = 0; double y_z = 0; double xyz = 0; double xz = 0; double yz = 0; double z = 0; List <int> attributeIndexes3 = new List <int>(); attributeIndexes3.Add(xAttribute.Index); attributeIndexes3.Add(yAttribute.Index); attributeIndexes3.Add(zAttribute.Index); List <int> valueIndexes3 = new List <int>(); valueIndexes3.Add(0); valueIndexes3.Add(0); valueIndexes3.Add(0); List <int> attributeIndexes2 = new List <int>(); attributeIndexes2.Add(xAttribute.Index); attributeIndexes2.Add(zAttribute.Index); List <int> valueIndexes2 = new List <int>(); valueIndexes2.Add(0); valueIndexes2.Add(0); for (int zi = 0; zi < zAttribute.Values.Length; zi++) { double _cmi = 0; for (int xi = 0; xi < xAttribute.Values.Length; xi++) { for (int yi = 0; yi < yAttribute.Values.Length; yi++) { z = zAttribute.ValueCounts[zi]; attributeIndexes2[0] = xAttribute.Index; attributeIndexes2[1] = zAttribute.Index; valueIndexes2[0] = xi; valueIndexes2[1] = zi; xz = this._dataset.Filter(attributeIndexes2, valueIndexes2).Count; x_z = xz / z; attributeIndexes2[0] = yAttribute.Index; attributeIndexes2[1] = zAttribute.Index; valueIndexes2[0] = yi; valueIndexes2[1] = zi; yz = this._dataset.Filter(attributeIndexes2, valueIndexes2).Count; y_z = yz / z; valueIndexes3[0] = xi; valueIndexes3[1] = yi; valueIndexes3[2] = zi; xyz = this._dataset.Filter(attributeIndexes3, valueIndexes3).Count; xy_z = xyz / z; double value = xy_z * Math.Log(xy_z / (x_z * y_z)); if (!double.IsNaN(value) && !double.IsInfinity(value)) { _cmi += value; } } } CMI += _cmi * (z / size); } Element.Heuristic = CMI; }
public void CalculateHeuristics(ACO.DecisionComponent <T> component) { component.Heuristic = 1; }
public void CalculateHieristicValue(ACO.DecisionComponent <T> Element) { Element.Heuristic = 1; }
public void CalculateHieristicValue(ACO.DecisionComponent <Edge> Element) { iFourmi.DataMining.Data.Attribute xAttribute = this._dataset.Metadata.Attributes[Element.Element.ParentIndex]; iFourmi.DataMining.Data.Attribute yAttribute = this._dataset.Metadata.Attributes[Element.Element.ChildIndex]; iFourmi.DataMining.Data.Attribute zAttribute = this._dataset.Metadata.Target; double InformationGain = 0; double size = this._dataset.Size; double xy_z = 0; double x_z = 0; double y_z = 0; double xyz = 0; double xz = 0; double yz = 0; double z = 0; List <int> attributeIndexes3 = new List <int>(); attributeIndexes3.Add(xAttribute.Index); attributeIndexes3.Add(yAttribute.Index); attributeIndexes3.Add(zAttribute.Index); List <int> valueIndexes3 = new List <int>(); valueIndexes3.Add(0); valueIndexes3.Add(0); valueIndexes3.Add(0); List <int> attributeIndexes2 = new List <int>(); attributeIndexes2.Add(xAttribute.Index); attributeIndexes2.Add(zAttribute.Index); List <int> valueIndexes2 = new List <int>(); valueIndexes2.Add(0); valueIndexes2.Add(0); for (int zi = 0; zi < zAttribute.Values.Length; zi++) { double baseEntropy = 0; double entropy = 0; double _information = 0; z = zAttribute.ValueCounts[zi]; for (int yi = 0; yi < yAttribute.Values.Length; yi++) { attributeIndexes2[0] = yAttribute.Index; attributeIndexes2[1] = zAttribute.Index; valueIndexes2[0] = yi; valueIndexes2[1] = zi; yz = this._dataset.Filter(attributeIndexes2, valueIndexes2).Count; y_z = yz / z; //baseEntropy -= (y_z) * Math.Log(y_z); baseEntropy -= (yz / size) * Math.Log(yz / size); if (double.IsNaN(baseEntropy) || double.IsInfinity(baseEntropy)) { baseEntropy = 1; } } for (int xi = 0; xi < xAttribute.Values.Length; xi++) { double x = xAttribute.ValueCounts[xi]; for (int yi = 0; yi < yAttribute.Values.Length; yi++) { attributeIndexes2[0] = xAttribute.Index; attributeIndexes2[1] = zAttribute.Index; valueIndexes2[0] = xi; valueIndexes2[1] = zi; xz = this._dataset.Filter(attributeIndexes2, valueIndexes2).Count; x_z = xz / z; valueIndexes3[0] = xi; valueIndexes3[1] = yi; valueIndexes3[2] = zi; xyz = this._dataset.Filter(attributeIndexes3, valueIndexes3).Count; xy_z = xyz / z; //double value = (xy_z / x_z) * Math.Log((xy_z / x_z)); double value = -(xyz / x) * Math.Log((xyz / x)); if (!double.IsNaN(value) && !double.IsInfinity(value)) { entropy += (xyz / z) * value; } } } _information = baseEntropy - entropy; InformationGain += _information * (z / size); } Element.Heuristic = InformationGain; }