- Timestamp:
- 04/19/19 08:43:51 (6 years ago)
- Location:
- branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis (added) merged: 12212-12213,12416,12448-12449,13401 /trunk/HeuristicLab.Problems.DataAnalysis merged: 16788,16796,16820
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis/3.4 (added) merged: 12213,12416,12448-12449,13401 /trunk/HeuristicLab.Problems.DataAnalysis/3.4 merged: 16788,16796,16820
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r16644 r16824 25 25 using System.Collections.ObjectModel; 26 26 using System.Linq; 27 using HEAL.Attic; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Core; 29 30 using HeuristicLab.Data; 30 using HEAL.Attic;31 31 32 32 namespace HeuristicLab.Problems.DataAnalysis { … … 115 115 } 116 116 117 public static Dataset FromRowData(IEnumerable<string> variableNames, double[,] data) { 118 var colWise = new List<IList>(data.GetLength(1)); 119 for (var col = 0; col < data.GetLength(1); col++) { 120 var column = new List<double>(data.GetLength(0)); 121 for (var row = 0; row < data.GetLength(0); row++) { 122 column.Add(data[row, col]); 123 } 124 colWise.Add(column); 125 } 126 return new Dataset(variableNames, colWise); 127 } 128 129 public static Dataset FromRowData(IEnumerable<string> variableNames, IEnumerable<IList> data) { 130 var vnames = variableNames.ToList(); 131 var transposed = new List<IList>(); 132 var iter = data.GetEnumerator(); 133 if (!iter.MoveNext()) throw new ArgumentException("Data does not contain any rows", nameof(data)); 134 for (var i = 0; i < iter.Current.Count; i++) { 135 if (i >= vnames.Count) throw new ArgumentException("There are more variables in data, than variable names.", nameof(variableNames)); 136 if (iter.Current[i] == null) throw new ArgumentException("Null values are not supported.", nameof(data)); 137 if (!IsAllowedType(iter.Current[i].GetType())) throw new ArgumentException("Data contains types that are not allowed.", nameof(data)); 138 if (iter.Current[i] is double d) 139 transposed.Add(new List<double>() { d }); 140 else if (iter.Current[i] is DateTime dt) 141 transposed.Add(new List<DateTime>() { dt }); 142 else if (iter.Current[i] is string s) 143 transposed.Add(new List<string>() { s }); 144 else throw new NotSupportedException(string.Format("Variable {0} has type {1}. This is not supported when converting from row-wise data.", vnames[i], iter.Current[i].GetType())); 145 } 146 if (transposed.Count < vnames.Count) throw new ArgumentException("There are less variables in data, than variable names.", nameof(variableNames)); 147 while (iter.MoveNext()) { 148 for (var i = 0; i < iter.Current.Count; i++) 149 if (transposed[i].Add(iter.Current[i]) < 0) 150 throw new ArgumentException(string.Format("Variable {0} has invalid value ({1})", vnames[i], iter.Current[i]), nameof(data)); 151 } 152 return new Dataset(vnames, transposed); 153 } 154 117 155 public ModifiableDataset ToModifiable() { 118 156 return new ModifiableDataset(variableNames, variableNames.Select(v => variableValues[v]), true); … … 133 171 #region Backwards compatible code, remove with 3.5 134 172 private double[,] storableData; 135 //name alias used to supp port backwards compatibility136 [Storable( Name = "data", AllowOneWay = true)]173 //name alias used to support backwards compatibility 174 [Storable(OldName = "data")] 137 175 private double[,] StorableData { set { storableData = value; } } 138 176 -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r16800 r16824 300 300 <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" /> 301 301 <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" /> 302 <Compile Include="OnlineCalculators\OnlineWeightedClassificationMeanSquaredErrorCalculator.cs" /> 302 303 <Compile Include="ParsedConstraint.cs" /> 303 304 <Compile Include="Plugin.cs" /> -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs
r16644 r16824 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis { … … 121 121 122 122 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 123 var estimatedValues = GetEstimatedValues(dataset, rows); 124 return GetEstimatedClassValues(estimatedValues); 125 } 126 127 public virtual IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues) { 123 128 if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current classification model."); 124 foreach (var x in GetEstimatedValues(dataset, rows)) {129 foreach (var x in estimatedValues) { 125 130 int classIndex = 0; 126 131 // find first threshold value which is larger than x => class index = threshold index + 1 … … 132 137 } 133 138 } 139 134 140 #region events 135 141 public event EventHandler ThresholdsChanged; -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs
r16644 r16824 73 73 74 74 #region backwards compatiblity 3.3.5 75 [Storable( Name = "models", AllowOneWay = true)]75 [Storable(OldName = "models")] 76 76 private List<IRegressionModel> OldStorableModels { 77 77 set { models = value; } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationModel.cs
r16640 r16824 34 34 void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues); 35 35 IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows); 36 IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues); 36 37 37 38 event EventHandler ThresholdsChanged;
Note: See TracChangeset
for help on using the changeset viewer.