Changeset 312
- Timestamp:
- 06/10/08 16:21:36 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.DataAnalysis
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataAnalysis/Dataset.cs
r237 r312 42 42 private Dictionary<int, Dictionary<int, double>>[] cachedRanges; 43 43 private double[] scalingFactor; 44 45 public double[] ScalingFactor { 46 get { return scalingFactor; } 47 } 44 48 private double[] scalingOffset; 49 50 public double[] ScalingOffset { 51 get { return scalingOffset; } 52 } 45 53 46 54 public int Rows { … … 296 304 297 305 internal void ScaleVariable(int column) { 298 if(scalingFactor[column] == 1.0 ) {306 if(scalingFactor[column] == 1.0 && scalingOffset[column] == 0.0) { 299 307 double min = GetMinimum(column); 300 308 double max = GetMaximum(column); 301 309 double range = max - min; 302 scalingFactor[column] = range; 303 scalingOffset[column] = min; 304 for(int i = 0; i < Rows; i++) { 305 double origValue = samples[i * columns + column]; 306 samples[i * columns + column] = (origValue - min) / range; 307 } 310 if(range == 0) ScaleVariable(column, 1.0, -min); 311 else ScaleVariable(column, 1.0 / range, -min); 308 312 } 309 313 CreateDictionaries(); … … 311 315 } 312 316 317 internal void ScaleVariable(int column, double factor, double offset) { 318 scalingFactor[column] = factor; 319 scalingOffset[column] = offset; 320 for(int i = 0; i < Rows; i++) { 321 double origValue = samples[i * columns + column]; 322 samples[i * columns + column] = (origValue + offset) * factor; 323 } 324 CreateDictionaries(); 325 FireChanged(); 326 } 327 313 328 internal void UnscaleVariable(int column) { 314 if(scalingFactor[column] != 1.0 ) {329 if(scalingFactor[column] != 1.0 || scalingOffset[column]!=0.0) { 315 330 for(int i = 0; i < rows; i++) { 316 331 double scaledValue = samples[i * columns + column]; 317 samples[i * columns + column] = scaledValue * scalingFactor[column] +scalingOffset[column];332 samples[i * columns + column] = scaledValue / scalingFactor[column] - scalingOffset[column]; 318 333 } 319 334 scalingFactor[column] = 1.0; -
trunk/sources/HeuristicLab.DataAnalysis/DatasetView.cs
r276 r312 131 131 } 132 132 } 133 134 private void showScalingToolStripMenuItem_Click(object sender, EventArgs e) { 135 ManualScalingControl scalingControl = new ManualScalingControl(false); 136 double[,] scalingParameters = new double[2, Dataset.Columns]; 137 for(int i = 0; i < Dataset.Columns; i++) { 138 scalingParameters[0, i] = Dataset.ScalingFactor[i]; 139 scalingParameters[1, i] = Dataset.ScalingOffset[i]; 140 } 141 scalingControl.Data = scalingParameters; 142 scalingControl.ShowDialog(); 143 } 144 145 private void scaleValuesmanuallyToolStripMenuItem_Click(object sender, EventArgs e) { 146 ManualScalingControl scalingControl = new ManualScalingControl(true); 147 double[,] scalingParameters = new double[2, Dataset.Columns]; 148 for(int i = 0; i < Dataset.Columns; i++) { 149 scalingParameters[0, i] = Dataset.ScalingFactor[i]; 150 scalingParameters[1, i] = Dataset.ScalingOffset[i]; 151 } 152 scalingControl.Data = scalingParameters; 153 if(scalingControl.ShowDialog() == DialogResult.OK) { 154 for(int i = 0; i < Dataset.Columns; i++) { 155 Dataset.ScaleVariable(i, scalingControl.Data[0, i], scalingControl.Data[1, i]); 156 } 157 } 158 Refresh(); 159 } 133 160 } 134 161 } -
trunk/sources/HeuristicLab.DataAnalysis/DatasetView.designer.cs
r233 r312 49 49 this.columnsTextBox = new System.Windows.Forms.TextBox(); 50 50 this.dataGridView = new System.Windows.Forms.DataGridView(); 51 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 52 this.scaleValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 this.originalValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 54 this.rowsLabel = new System.Windows.Forms.Label(); 52 55 this.columnsLabel = new System.Windows.Forms.Label(); 53 56 this.nameLabel = new System.Windows.Forms.Label(); 54 57 this.nameTextBox = new System.Windows.Forms.TextBox(); 55 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 56 this.scaleValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 57 this.originalValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 58 this.showScalingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 59 this.scaleValuesmanuallyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 58 60 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 59 61 this.contextMenuStrip.SuspendLayout(); … … 91 93 this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating); 92 94 // 95 // contextMenuStrip 96 // 97 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 98 this.scaleValuesToolStripMenuItem, 99 this.scaleValuesmanuallyToolStripMenuItem, 100 this.showScalingToolStripMenuItem, 101 this.originalValuesToolStripMenuItem}); 102 this.contextMenuStrip.Name = "contextMenuStrip"; 103 this.contextMenuStrip.Size = new System.Drawing.Size(198, 114); 104 // 105 // scaleValuesToolStripMenuItem 106 // 107 this.scaleValuesToolStripMenuItem.Name = "scaleValuesToolStripMenuItem"; 108 this.scaleValuesToolStripMenuItem.Size = new System.Drawing.Size(197, 22); 109 this.scaleValuesToolStripMenuItem.Text = "Scale values [0..1]"; 110 this.scaleValuesToolStripMenuItem.Click += new System.EventHandler(this.scaleValuesToolStripMenuItem_Click); 111 // 112 // originalValuesToolStripMenuItem 113 // 114 this.originalValuesToolStripMenuItem.Name = "originalValuesToolStripMenuItem"; 115 this.originalValuesToolStripMenuItem.Size = new System.Drawing.Size(197, 22); 116 this.originalValuesToolStripMenuItem.Text = "Unscale values"; 117 this.originalValuesToolStripMenuItem.Click += new System.EventHandler(this.originalValuesToolStripMenuItem_Click); 118 // 93 119 // rowsLabel 94 120 // … … 126 152 this.nameTextBox.TabIndex = 7; 127 153 // 128 // contextMenuStrip 129 // 130 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 131 this.scaleValuesToolStripMenuItem, 132 this.originalValuesToolStripMenuItem}); 133 this.contextMenuStrip.Name = "contextMenuStrip"; 134 this.contextMenuStrip.Size = new System.Drawing.Size(146, 48); 135 // 136 // scaleValuesToolStripMenuItem 137 // 138 this.scaleValuesToolStripMenuItem.Name = "scaleValuesToolStripMenuItem"; 139 this.scaleValuesToolStripMenuItem.Size = new System.Drawing.Size(145, 22); 140 this.scaleValuesToolStripMenuItem.Text = "Scale values"; 141 this.scaleValuesToolStripMenuItem.Click += new System.EventHandler(this.scaleValuesToolStripMenuItem_Click); 142 // 143 // originalValuesToolStripMenuItem 144 // 145 this.originalValuesToolStripMenuItem.Name = "originalValuesToolStripMenuItem"; 146 this.originalValuesToolStripMenuItem.Size = new System.Drawing.Size(145, 22); 147 this.originalValuesToolStripMenuItem.Text = "Unscale values"; 148 this.originalValuesToolStripMenuItem.Click += new System.EventHandler(this.originalValuesToolStripMenuItem_Click); 154 // showScalingToolStripMenuItem 155 // 156 this.showScalingToolStripMenuItem.Name = "showScalingToolStripMenuItem"; 157 this.showScalingToolStripMenuItem.Size = new System.Drawing.Size(197, 22); 158 this.showScalingToolStripMenuItem.Text = "Show scaling..."; 159 this.showScalingToolStripMenuItem.Click += new System.EventHandler(this.showScalingToolStripMenuItem_Click); 160 // 161 // scaleValuesmanuallyToolStripMenuItem 162 // 163 this.scaleValuesmanuallyToolStripMenuItem.Name = "scaleValuesmanuallyToolStripMenuItem"; 164 this.scaleValuesmanuallyToolStripMenuItem.Size = new System.Drawing.Size(197, 22); 165 this.scaleValuesmanuallyToolStripMenuItem.Text = "Scale values (manually)"; 166 this.scaleValuesmanuallyToolStripMenuItem.Click += new System.EventHandler(this.scaleValuesmanuallyToolStripMenuItem_Click); 149 167 // 150 168 // DatasetView … … 180 198 private System.Windows.Forms.ToolStripMenuItem scaleValuesToolStripMenuItem; 181 199 private System.Windows.Forms.ToolStripMenuItem originalValuesToolStripMenuItem; 200 private System.Windows.Forms.ToolStripMenuItem scaleValuesmanuallyToolStripMenuItem; 201 private System.Windows.Forms.ToolStripMenuItem showScalingToolStripMenuItem; 182 202 } 183 203 } -
trunk/sources/HeuristicLab.DataAnalysis/HeuristicLab.DataAnalysis.csproj
r273 r312 62 62 <Compile Include="HeuristicLabDataAnalysisPlugin.cs" /> 63 63 <Compile Include="IDatasetManipulator.cs" /> 64 <Compile Include="ManualScalingControl.cs"> 65 <SubType>Form</SubType> 66 </Compile> 67 <Compile Include="ManualScalingControl.Designer.cs"> 68 <DependentUpon>ManualScalingControl.cs</DependentUpon> 69 </Compile> 64 70 <Compile Include="Properties\AssemblyInfo.cs" /> 65 71 <Compile Include="Regression.cs" /> … … 92 98 <SubType>Designer</SubType> 93 99 </EmbeddedResource> 100 <EmbeddedResource Include="ManualScalingControl.resx"> 101 <DependentUpon>ManualScalingControl.cs</DependentUpon> 102 </EmbeddedResource> 94 103 <EmbeddedResource Include="SvmExporter.resx"> 95 104 <DependentUpon>SvmExporter.cs</DependentUpon>
Note: See TracChangeset
for help on using the changeset viewer.