- Timestamp:
- 07/15/17 10:29:40 (8 years ago)
- Location:
- stable
- Files:
-
- 1 deleted
- 4 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 14862-14863,14911,14936,15156-15158,15164,15169,15207-15209,15225,15227,15234,15248
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 14862-14863,14911,14936,15156-15158,15164,15169,15207-15209,15225,15227,15234,15248
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/CosineDistance.cs
r15209 r15249 30 30 31 31 /// <summary> 32 /// The angluar distance as defined as a normalized distance measure dependent on the angle between two vectors. 33 /// It is designed for vectors with all positive coordinates. 32 /// The angular distance as defined as a normalized distance measure dependent on the angle between two vectors. 34 33 /// </summary> 35 34 [StorableClass] 36 [Item("CosineDistance", "The ang luar distance as defined as a normalized distance measure dependent on the angle between two vectors.\nIt is designed for vectors with all positive coordinates")]35 [Item("CosineDistance", "The angular distance as defined as a normalized distance measure dependent on the angle between two vectors.")] 37 36 public class CosineDistance : DistanceBase<IEnumerable<double>> { 38 37 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/DistanceBase.cs
r14767 r15249 20 20 #endregion 21 21 22 using System.Collections; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; … … 29 30 public abstract class DistanceBase<T> : Item, IDistance<T> { 30 31 31 #region HLConstructors & Boilerplate32 #region HLConstructors & Cloning 32 33 [StorableConstructor] 33 34 protected DistanceBase(bool deserializing) : base(deserializing) { } … … 42 43 } 43 44 44 private class DistanceComparer : IComparer<T> { 45 public double Get(object x, object y) { 46 return Get((T)x, (T)y); 47 } 48 49 public IComparer GetDistanceComparer(object item) { 50 return new DistanceComparer((T)item, this); 51 } 52 53 private class DistanceComparer : IComparer<T>, IComparer { 45 54 private readonly T item; 46 55 private readonly IDistance<T> dist; … … 54 63 return dist.Get(x, item).CompareTo(dist.Get(y, item)); 55 64 } 65 66 public int Compare(object x, object y) { 67 return Compare((T)x, (T)y); 68 } 56 69 } 57 70 } -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/EuclideanDistance.cs
r14784 r15249 32 32 public class EuclideanDistance : DistanceBase<IEnumerable<double>> { 33 33 34 #region HLConstructors & Boilerplate34 #region HLConstructors & Cloning 35 35 [StorableConstructor] 36 36 protected EuclideanDistance(bool deserializing) : base(deserializing) { } … … 40 40 #endregion 41 41 42 public static double GetDistance(double[] point1, double[] point2) { 43 if (point1.Length != point2.Length) throw new ArgumentException("Euclidean distance not defined on vectors of different length"); 44 return Math.Sqrt(point1.Zip(point2, (a1, b1) => (a1 - b1) * (a1 - b1)).Sum()); 42 public static double GetDistance(IReadOnlyList<double> point1, IReadOnlyList<double> point2) { 43 if (point1.Count != point2.Count) throw new ArgumentException("Euclidean distance not defined on vectors of different length"); 44 var sum = 0.0; 45 for (var i = 0; i < point1.Count; i++) { 46 var d = point1[i] - point2[i]; 47 sum += d * d; 48 } 49 50 return Math.Sqrt(sum); 45 51 } 46 52 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/ManhattanDistance.cs
r14911 r15249 32 32 public class ManhattanDistance : DistanceBase<IEnumerable<double>> { 33 33 34 #region HLConstructors & Boilerplate34 #region HLConstructors & Cloning 35 35 [StorableConstructor] 36 36 protected ManhattanDistance(bool deserializing) : base(deserializing) { } … … 47 47 public static double GetDistance(double[] point1, double[] point2) { 48 48 if (point1.Length != point2.Length) throw new ArgumentException("Manhattan distance not defined on vectors of different length"); 49 return point1.Zip(point2, (a1, b1) => Math.Abs(a1 - b1)).Sum(); 49 var sum = 0.0; 50 for (var i = 0; i < point1.Length; i++) 51 sum += Math.Abs(point1[i] + point2[i]); 52 return sum; 50 53 } 51 54
Note: See TracChangeset
for help on using the changeset viewer.