- Timestamp:
- 12/23/18 09:16:37 (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj
r15124 r16449 142 142 <Compile Include="OneFactorClassificationModelView.Designer.cs"> 143 143 <DependentUpon>OneFactorClassificationModelView.cs</DependentUpon> 144 </Compile> 145 <Compile Include="LinearRegressionModelView.cs"> 146 <SubType>UserControl</SubType> 147 </Compile> 148 <Compile Include="LinearRegressionModelView.Designer.cs"> 149 <DependentUpon>LinearRegressionModelView.cs</DependentUpon> 144 150 </Compile> 145 151 <Compile Include="RandomForestModelView.cs"> -
trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegressionModel.cs
r16448 r16449 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using HeuristicLab.Common; … … 35 36 [Item("Linear Regression Model", "Represents a linear regression model.")] 36 37 public sealed class LinearRegressionModel : RegressionModel, IConfidenceRegressionModel { 38 public static new Image StaticItemImage { 39 get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; } 40 } 37 41 38 42 [Storable] … … 51 55 52 56 public override IEnumerable<string> VariablesUsedForPrediction { 53 get { return allowedInputVariables.Union(factorVariables.Select(f => f.Key)); }57 get { return doubleVariables.Union(factorVariables.Select(f => f.Key)); } 54 58 } 55 59 56 60 [Storable] 57 private string[] allowedInputVariables;61 private string[] doubleVariables; 58 62 [Storable] 59 63 private List<KeyValuePair<string, IEnumerable<string>>> factorVariables; 64 65 /// <summary> 66 /// Enumerable of variable names used by the model including one-hot-encoded of factor variables. 67 /// </summary> 68 public IEnumerable<string> ParameterNames { 69 get { 70 return factorVariables.SelectMany(kvp => kvp.Value.Select(factorVal => $"{kvp.Key}={factorVal}")) 71 .Concat(doubleVariables) 72 .Concat(new[] { "<const>" }); 73 } 74 } 60 75 61 76 [StorableConstructor] … … 69 84 this.NoiseSigma = original.NoiseSigma; 70 85 71 allowedInputVariables = (string[])original.allowedInputVariables.Clone();86 doubleVariables = (string[])original.doubleVariables.Clone(); 72 87 this.factorVariables = original.factorVariables.Select(kvp => new KeyValuePair<string, IEnumerable<string>>(kvp.Key, new List<string>(kvp.Value))).ToList(); 73 88 } … … 81 96 Array.Copy(covariance, C, covariance.Length); 82 97 this.NoiseSigma = noiseSigma; 83 var stringInputVariables = factorVariables.Select(f => f.Key).Distinct();84 this.allowedInputVariables = doubleInputVariables.ToArray();98 this.doubleVariables = doubleInputVariables.ToArray(); 99 // clone 85 100 this.factorVariables = factorVariables.Select(kvp => new KeyValuePair<string, IEnumerable<string>>(kvp.Key, new List<string>(kvp.Value))).ToList(); 86 101 } … … 95 110 96 111 public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 97 double[,] inputData = dataset.ToArray( allowedInputVariables, rows);112 double[,] inputData = dataset.ToArray(doubleVariables, rows); 98 113 double[,] factorData = dataset.ToArray(factorVariables, rows); 99 114 … … 114 129 115 130 public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) { 116 double[,] inputData = dataset.ToArray( allowedInputVariables, rows);131 double[,] inputData = dataset.ToArray(doubleVariables, rows); 117 132 double[,] factorData = dataset.ToArray(factorVariables, rows); 118 133
Note: See TracChangeset
for help on using the changeset viewer.