public double EuclDW(Item item) { int nCount = 0; int iIndex = 0; double nDistance = 0; // Iterating through the array of attributes and for each pair of either users or items // attributes computing the distance between those attributes. Then, each distance values // is added to the nDistance variable. During the computation we're also obtaining the // value of releavance between the lexicographical representations of those attributes while (iIndex < item.AttributeList.Count() && iIndex < AttributeList.Count()) { // Compute the relevance between names of the pair of attributes double nRel = Relevance(item.AttributeList[iIndex].Name, AttributeList[iIndex].Name); if (nRel == 1) { nCount++; } // Computing the Eucledean distance between the pair of current attributes nDistance += Math.Pow(item.AttributeList[iIndex].Value - AttributeList[iIndex].Value, 2.0) * ((double)((nRel > 0) ? nRel : 1)); iIndex++; } // Returning the value of the distance between two vectors of attributes return(Math.Sqrt(nDistance) * ((double)1 / ((nCount > 0) ? nCount : 0.01))); }
public object Clone() { IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attribute in AttributeList) { TargetAttributeList.Add(attribute); } return(TargetAttributeList.Count() > 0 ? (IAttributeList)TargetAttributeList.Clone() : null); }
public object Clone() { IItemsList TargetItems = new IItemsList(); foreach (Item item in ItemsList) { IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attrib in item.GetAttributeList()) { TargetAttributeList.Add(new Attribute(attrib.Name, attrib.Value)); } if (TargetAttributeList.Count() > 0) { TargetItems.Add(new Item(item.ItemText, TargetAttributeList, item.Distance, item.IsCentroid, item.Exists)); } } return(TargetItems); }
public object Clone() { Item TargetItem = (Item)this.MemberwiseClone(); IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attribute in this.AttributeList) { TargetAttributeList.Add(attribute); } if (TargetAttributeList.Count() > 0) { TargetItem.AttributeList = (IAttributeList)TargetAttributeList.Clone(); } TargetItem.IsCentroid = this.IsCentroid; TargetItem.Exists = this.Exists; TargetItem.ItemText = this.ItemText; TargetItem.Distance = this.Distance; return(TargetItem); }