Changeset 16416 for branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs
- Timestamp:
- 12/20/18 11:11:37 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs
r16067 r16416 26 26 } 27 27 28 private static readonly double epsilon = 0.00001;29 28 30 29 [TestMethod] … … 48 47 ClassificationSolutionVariableImpactsCalculator.CalculateImpacts(solution); 49 48 Dictionary<string, double> expectedImpacts = GetExpectedValuesForIrisKNNModel(); 49 50 CheckDefaultAsserts(solution, expectedImpacts); 51 } 52 53 54 [TestMethod] 55 [TestCategory("Problems.DataAnalysis")] 56 [TestProperty("Time", "short")] 57 public void LDAIrisVariableImpactTest() { 58 IClassificationProblemData problemData = LoadIrisProblem(); 59 IClassificationSolution solution = LinearDiscriminantAnalysis.CreateLinearDiscriminantAnalysisSolution(problemData); 60 ClassificationSolutionVariableImpactsCalculator.CalculateImpacts(solution); 61 Dictionary<string, double> expectedImpacts = GetExpectedValuesForIrisLDAModel(); 50 62 51 63 CheckDefaultAsserts(solution, expectedImpacts); … … 85 97 [TestProperty("Time", "short")] 86 98 [ExpectedException(typeof(ArgumentException))] 87 public void WrongDataSet Test() {99 public void WrongDataSetVariableImpactClassificationTest() { 88 100 IClassificationProblemData problemData = LoadIrisProblem(); 89 101 IClassificationSolution solution = NearestNeighbourClassification.CreateNearestNeighbourClassificationSolution(problemData, 3); … … 99 111 [TestCategory("Problems.DataAnalysis")] 100 112 [TestProperty("Time", "medium")] 101 public void Performance Test() {113 public void PerformanceVariableImpactClassificationTest() { 102 114 int rows = 1500; 103 115 int columns = 77; … … 229 241 return expectedImpacts; 230 242 } 243 private Dictionary<string, double> GetExpectedValuesForIrisLDAModel() { 244 Dictionary<string, double> expectedImpacts = new Dictionary<string, double>(); 245 expectedImpacts.Add("sepal_width", 0.01); 246 expectedImpacts.Add("sepal_length", 0.03); 247 expectedImpacts.Add("petal_width", 0.2); 248 expectedImpacts.Add("petal_length", 0.5); 249 250 return expectedImpacts; 251 } 231 252 #endregion 232 253 … … 243 264 //Check if impacts are as expected 244 265 Assert.AreEqual(modelImpacts.Count(), expectedImpacts.Count); 245 Assert.IsTrue(modelImpacts.All(v => Math.Abs(expectedImpacts[v.Item1] - v.Item2) < epsilon));266 Assert.IsTrue(modelImpacts.All(v => v.Item2.IsAlmost(expectedImpacts[v.Item1]))); 246 267 } 247 268 }
Note: See TracChangeset
for help on using the changeset viewer.