Changeset 8877 for trunk/sources
- Timestamp:
- 11/07/12 16:28:33 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 17 edited
- 11 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis (added) merged: 8713,8715,8842,8875
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r8802 r8877 304 304 } 305 305 306 p rivatestatic IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) {306 public static IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) { 307 307 int maxSamples = Math.Min(InspectedRowsToDetermineTargets, dataset.Rows); 308 308 var validTargetVariables = (from v in dataset.DoubleVariables -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views
-
Property
svn:mergeinfo
set to
/branches/DataAnalysisCSVImport/HeuristicLab.Problems.Instances.DataAnalysis.Views merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.Designer.cs
r8693 r8877 1 namespace HeuristicLab.Problems.Instances.DataAnalysis.Views { 1 2 namespace HeuristicLab.Problems.Instances.DataAnalysis.Views { 2 3 partial class DataAnalysisImportTypeDialog { 3 4 /// <summary> … … 24 25 /// </summary> 25 26 private void InitializeComponent() { 27 this.components = new System.ComponentModel.Container(); 28 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataAnalysisImportTypeDialog)); 26 29 this.ShuffleDataCheckbox = new System.Windows.Forms.CheckBox(); 27 30 this.OkButton = new System.Windows.Forms.Button(); 28 31 this.TrainingTestTrackBar = new System.Windows.Forms.TrackBar(); 29 this.TrainingTestGroupBox = new System.Windows.Forms.GroupBox();30 32 this.TestLabel = new System.Windows.Forms.Label(); 31 33 this.TrainingLabel = new System.Windows.Forms.Label(); 32 34 this.CancelButton = new System.Windows.Forms.Button(); 33 this. openFileButton = new System.Windows.Forms.Button();35 this.OpenFileButton = new System.Windows.Forms.Button(); 34 36 this.ProblemFileLabel = new System.Windows.Forms.Label(); 35 37 this.ProblemTextBox = new System.Windows.Forms.TextBox(); 36 38 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 39 this.DateTimeFormatComboBox = new System.Windows.Forms.ComboBox(); 40 this.DecimalSeparatorComboBox = new System.Windows.Forms.ComboBox(); 41 this.DateTimeFormatLabel = new System.Windows.Forms.Label(); 42 this.DecimalSeperatorLabel = new System.Windows.Forms.Label(); 43 this.SeparatorLabel = new System.Windows.Forms.Label(); 44 this.SeparatorComboBox = new System.Windows.Forms.ComboBox(); 45 this.CSVSettingsGroupBox = new System.Windows.Forms.GroupBox(); 46 this.DateTimeFormatInfoLabel = new System.Windows.Forms.Label(); 47 this.DecimalSeparatorInfoLabel = new System.Windows.Forms.Label(); 48 this.SeparatorInfoLabel = new System.Windows.Forms.Label(); 49 this.ProblemDataSettingsGroupBox = new System.Windows.Forms.GroupBox(); 50 this.ErrorTextBox = new System.Windows.Forms.TextBox(); 51 this.ShuffelInfoLabel = new System.Windows.Forms.Label(); 52 this.PreviewLabel = new System.Windows.Forms.Label(); 53 this.PreviewDatasetMatrix = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); 54 this.ToolTip = new System.Windows.Forms.ToolTip(this.components); 37 55 ((System.ComponentModel.ISupportInitialize)(this.TrainingTestTrackBar)).BeginInit(); 38 this.TrainingTestGroupBox.SuspendLayout(); 56 this.CSVSettingsGroupBox.SuspendLayout(); 57 this.ProblemDataSettingsGroupBox.SuspendLayout(); 39 58 this.SuspendLayout(); 40 59 // … … 42 61 // 43 62 this.ShuffleDataCheckbox.AutoSize = true; 44 this.ShuffleDataCheckbox.Location = new System.Drawing.Point(12, 38); 63 this.ShuffleDataCheckbox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 64 this.ShuffleDataCheckbox.Location = new System.Drawing.Point(9, 20); 45 65 this.ShuffleDataCheckbox.Name = "ShuffleDataCheckbox"; 46 66 this.ShuffleDataCheckbox.Size = new System.Drawing.Size(91, 17); … … 51 71 // OkButton 52 72 // 73 this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 53 74 this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK; 54 75 this.OkButton.Enabled = false; 55 this.OkButton.Location = new System.Drawing.Point( 61, 147);76 this.OkButton.Location = new System.Drawing.Point(87, 407); 56 77 this.OkButton.Name = "OkButton"; 57 78 this.OkButton.Size = new System.Drawing.Size(75, 23); … … 64 85 this.TrainingTestTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 65 86 | System.Windows.Forms.AnchorStyles.Right))); 66 this.TrainingTestTrackBar.Location = new System.Drawing.Point(6, 19);87 this.TrainingTestTrackBar.Location = new System.Drawing.Point(6, 43); 67 88 this.TrainingTestTrackBar.Maximum = 100; 68 89 this.TrainingTestTrackBar.Minimum = 1; 69 90 this.TrainingTestTrackBar.Name = "TrainingTestTrackBar"; 70 this.TrainingTestTrackBar.Size = new System.Drawing.Size( 303, 45);91 this.TrainingTestTrackBar.Size = new System.Drawing.Size(435, 45); 71 92 this.TrainingTestTrackBar.TabIndex = 4; 72 93 this.TrainingTestTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; … … 74 95 this.TrainingTestTrackBar.ValueChanged += new System.EventHandler(this.TrainingTestTrackBar_ValueChanged); 75 96 // 76 // TrainingTestGroupBox77 //78 this.TrainingTestGroupBox.Controls.Add(this.TestLabel);79 this.TrainingTestGroupBox.Controls.Add(this.TrainingLabel);80 this.TrainingTestGroupBox.Controls.Add(this.TrainingTestTrackBar);81 this.TrainingTestGroupBox.Location = new System.Drawing.Point(12, 61);82 this.TrainingTestGroupBox.Name = "TrainingTestGroupBox";83 this.TrainingTestGroupBox.Size = new System.Drawing.Size(315, 80);84 this.TrainingTestGroupBox.TabIndex = 5;85 this.TrainingTestGroupBox.TabStop = false;86 this.TrainingTestGroupBox.Text = "Training/Test";87 //88 97 // TestLabel 89 98 // 99 this.TestLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 90 100 this.TestLabel.AutoSize = true; 91 this.TestLabel.Location = new System.Drawing.Point( 188, 51);101 this.TestLabel.Location = new System.Drawing.Point(303, 68); 92 102 this.TestLabel.Name = "TestLabel"; 93 103 this.TestLabel.Size = new System.Drawing.Size(57, 13); … … 98 108 // 99 109 this.TrainingLabel.AutoSize = true; 100 this.TrainingLabel.Location = new System.Drawing.Point( 50, 51);110 this.TrainingLabel.Location = new System.Drawing.Point(76, 68); 101 111 this.TrainingLabel.Name = "TrainingLabel"; 102 112 this.TrainingLabel.Size = new System.Drawing.Size(74, 13); … … 106 116 // CancelButton 107 117 // 118 this.CancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 108 119 this.CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 109 this.CancelButton.Location = new System.Drawing.Point( 182, 147);120 this.CancelButton.Location = new System.Drawing.Point(318, 407); 110 121 this.CancelButton.Name = "CancelButton"; 111 122 this.CancelButton.Size = new System.Drawing.Size(75, 23); … … 114 125 this.CancelButton.UseVisualStyleBackColor = true; 115 126 // 116 // openFileButton 117 // 118 this.openFileButton.Location = new System.Drawing.Point(303, 12); 119 this.openFileButton.Name = "openFileButton"; 120 this.openFileButton.Size = new System.Drawing.Size(24, 24); 121 this.openFileButton.TabIndex = 8; 122 this.openFileButton.UseVisualStyleBackColor = true; 123 this.openFileButton.Click += new System.EventHandler(this.openFileButton_Click); 127 // OpenFileButton 128 // 129 this.OpenFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 130 this.OpenFileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 131 this.OpenFileButton.Location = new System.Drawing.Point(429, 3); 132 this.OpenFileButton.Name = "OpenFileButton"; 133 this.OpenFileButton.Size = new System.Drawing.Size(24, 24); 134 this.OpenFileButton.TabIndex = 8; 135 this.OpenFileButton.UseVisualStyleBackColor = true; 136 this.OpenFileButton.Click += new System.EventHandler(this.OpenFileButtonClick); 124 137 // 125 138 // ProblemFileLabel 126 139 // 127 140 this.ProblemFileLabel.AutoSize = true; 128 this.ProblemFileLabel.Location = new System.Drawing.Point(1 2, 15);141 this.ProblemFileLabel.Location = new System.Drawing.Point(18, 9); 129 142 this.ProblemFileLabel.Name = "ProblemFileLabel"; 130 143 this.ProblemFileLabel.Size = new System.Drawing.Size(67, 13); … … 134 147 // ProblemTextBox 135 148 // 136 this.ProblemTextBox.Location = new System.Drawing.Point(85, 12); 149 this.ProblemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 150 | System.Windows.Forms.AnchorStyles.Right))); 151 this.ProblemTextBox.Location = new System.Drawing.Point(91, 6); 137 152 this.ProblemTextBox.Name = "ProblemTextBox"; 138 153 this.ProblemTextBox.ReadOnly = true; 139 this.ProblemTextBox.Size = new System.Drawing.Size( 212, 20);154 this.ProblemTextBox.Size = new System.Drawing.Size(332, 20); 140 155 this.ProblemTextBox.TabIndex = 9; 141 156 // … … 143 158 // 144 159 this.openFileDialog.Filter = "CSV files (*.csv)|*.csv|Text files (*.txt)|*.txt|All files (*.*)|*.*"; 160 // 161 // DateTimeFormatComboBox 162 // 163 this.DateTimeFormatComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 164 | System.Windows.Forms.AnchorStyles.Right))); 165 this.DateTimeFormatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 166 this.DateTimeFormatComboBox.FormattingEnabled = true; 167 this.DateTimeFormatComboBox.Location = new System.Drawing.Point(111, 73); 168 this.DateTimeFormatComboBox.Name = "DateTimeFormatComboBox"; 169 this.DateTimeFormatComboBox.Size = new System.Drawing.Size(300, 21); 170 this.DateTimeFormatComboBox.TabIndex = 15; 171 this.DateTimeFormatComboBox.SelectionChangeCommitted += new System.EventHandler(this.CSVFormatComboBoxSelectionChangeCommitted); 172 // 173 // DecimalSeparatorComboBox 174 // 175 this.DecimalSeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 176 | System.Windows.Forms.AnchorStyles.Right))); 177 this.DecimalSeparatorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 178 this.DecimalSeparatorComboBox.FormattingEnabled = true; 179 this.DecimalSeparatorComboBox.Location = new System.Drawing.Point(111, 46); 180 this.DecimalSeparatorComboBox.Name = "DecimalSeparatorComboBox"; 181 this.DecimalSeparatorComboBox.Size = new System.Drawing.Size(300, 21); 182 this.DecimalSeparatorComboBox.TabIndex = 14; 183 this.DecimalSeparatorComboBox.SelectionChangeCommitted += new System.EventHandler(this.CSVFormatComboBoxSelectionChangeCommitted); 184 // 185 // DateTimeFormatLabel 186 // 187 this.DateTimeFormatLabel.AutoSize = true; 188 this.DateTimeFormatLabel.Location = new System.Drawing.Point(6, 76); 189 this.DateTimeFormatLabel.Name = "DateTimeFormatLabel"; 190 this.DateTimeFormatLabel.Size = new System.Drawing.Size(91, 13); 191 this.DateTimeFormatLabel.TabIndex = 13; 192 this.DateTimeFormatLabel.Text = "DateTime Format:"; 193 // 194 // DecimalSeperatorLabel 195 // 196 this.DecimalSeperatorLabel.AutoSize = true; 197 this.DecimalSeperatorLabel.Location = new System.Drawing.Point(6, 49); 198 this.DecimalSeperatorLabel.Name = "DecimalSeperatorLabel"; 199 this.DecimalSeperatorLabel.Size = new System.Drawing.Size(97, 13); 200 this.DecimalSeperatorLabel.TabIndex = 12; 201 this.DecimalSeperatorLabel.Text = "Decimal Separator:"; 202 // 203 // SeparatorLabel 204 // 205 this.SeparatorLabel.AutoSize = true; 206 this.SeparatorLabel.Location = new System.Drawing.Point(6, 22); 207 this.SeparatorLabel.Name = "SeparatorLabel"; 208 this.SeparatorLabel.Size = new System.Drawing.Size(56, 13); 209 this.SeparatorLabel.TabIndex = 11; 210 this.SeparatorLabel.Text = "Separator:"; 211 // 212 // SeparatorComboBox 213 // 214 this.SeparatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 215 | System.Windows.Forms.AnchorStyles.Right))); 216 this.SeparatorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 217 this.SeparatorComboBox.FormattingEnabled = true; 218 this.SeparatorComboBox.Location = new System.Drawing.Point(111, 19); 219 this.SeparatorComboBox.Name = "SeparatorComboBox"; 220 this.SeparatorComboBox.Size = new System.Drawing.Size(300, 21); 221 this.SeparatorComboBox.TabIndex = 10; 222 this.SeparatorComboBox.SelectionChangeCommitted += new System.EventHandler(this.CSVFormatComboBoxSelectionChangeCommitted); 223 // 224 // CSVSettingsGroupBox 225 // 226 this.CSVSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 227 | System.Windows.Forms.AnchorStyles.Right))); 228 this.CSVSettingsGroupBox.Controls.Add(this.DateTimeFormatInfoLabel); 229 this.CSVSettingsGroupBox.Controls.Add(this.DecimalSeparatorInfoLabel); 230 this.CSVSettingsGroupBox.Controls.Add(this.SeparatorInfoLabel); 231 this.CSVSettingsGroupBox.Controls.Add(this.SeparatorComboBox); 232 this.CSVSettingsGroupBox.Controls.Add(this.DateTimeFormatComboBox); 233 this.CSVSettingsGroupBox.Controls.Add(this.SeparatorLabel); 234 this.CSVSettingsGroupBox.Controls.Add(this.DecimalSeparatorComboBox); 235 this.CSVSettingsGroupBox.Controls.Add(this.DecimalSeperatorLabel); 236 this.CSVSettingsGroupBox.Controls.Add(this.DateTimeFormatLabel); 237 this.CSVSettingsGroupBox.Location = new System.Drawing.Point(12, 32); 238 this.CSVSettingsGroupBox.Name = "CSVSettingsGroupBox"; 239 this.CSVSettingsGroupBox.Size = new System.Drawing.Size(447, 105); 240 this.CSVSettingsGroupBox.TabIndex = 16; 241 this.CSVSettingsGroupBox.TabStop = false; 242 this.CSVSettingsGroupBox.Text = "CSV Settings"; 243 // 244 // DateTimeFormatInfoLabel 245 // 246 this.DateTimeFormatInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 247 this.DateTimeFormatInfoLabel.Location = new System.Drawing.Point(421, 76); 248 this.DateTimeFormatInfoLabel.Name = "DateTime Format Info"; 249 this.DateTimeFormatInfoLabel.Size = new System.Drawing.Size(16, 16); 250 this.DateTimeFormatInfoLabel.TabIndex = 23; 251 this.DateTimeFormatInfoLabel.Tag = "Select the date time format used in the csv file"; 252 this.DateTimeFormatInfoLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Information; 253 this.DateTimeFormatInfoLabel.DoubleClick += new System.EventHandler(this.ControlToolTip_DoubleClick); 254 // 255 // DecimalSeparatorInfoLabel 256 // 257 this.DecimalSeparatorInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 258 this.DecimalSeparatorInfoLabel.Location = new System.Drawing.Point(421, 49); 259 this.DecimalSeparatorInfoLabel.Name = "Decimal Separator Info"; 260 this.DecimalSeparatorInfoLabel.Size = new System.Drawing.Size(16, 16); 261 this.DecimalSeparatorInfoLabel.TabIndex = 22; 262 this.DecimalSeparatorInfoLabel.Tag = "Select the decimal separator used to for double values"; 263 this.DecimalSeparatorInfoLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Information; 264 this.DecimalSeparatorInfoLabel.DoubleClick += new System.EventHandler(this.ControlToolTip_DoubleClick); 265 // 266 // SeparatorInfoLabel 267 // 268 this.SeparatorInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 269 this.SeparatorInfoLabel.Location = new System.Drawing.Point(421, 22); 270 this.SeparatorInfoLabel.Name = "Separator Info"; 271 this.SeparatorInfoLabel.Size = new System.Drawing.Size(16, 16); 272 this.SeparatorInfoLabel.TabIndex = 21; 273 this.SeparatorInfoLabel.Tag = "Select the separator used to separate columns in the csv file."; 274 this.SeparatorInfoLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Information; 275 this.SeparatorInfoLabel.DoubleClick += new System.EventHandler(this.ControlToolTip_DoubleClick); 276 // 277 // ProblemDataSettingsGroupBox 278 // 279 this.ProblemDataSettingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 280 | System.Windows.Forms.AnchorStyles.Left) 281 | System.Windows.Forms.AnchorStyles.Right))); 282 this.ProblemDataSettingsGroupBox.Controls.Add(this.ErrorTextBox); 283 this.ProblemDataSettingsGroupBox.Controls.Add(this.ShuffelInfoLabel); 284 this.ProblemDataSettingsGroupBox.Controls.Add(this.PreviewLabel); 285 this.ProblemDataSettingsGroupBox.Controls.Add(this.TestLabel); 286 this.ProblemDataSettingsGroupBox.Controls.Add(this.PreviewDatasetMatrix); 287 this.ProblemDataSettingsGroupBox.Controls.Add(this.TrainingLabel); 288 this.ProblemDataSettingsGroupBox.Controls.Add(this.TrainingTestTrackBar); 289 this.ProblemDataSettingsGroupBox.Controls.Add(this.ShuffleDataCheckbox); 290 this.ProblemDataSettingsGroupBox.Location = new System.Drawing.Point(12, 143); 291 this.ProblemDataSettingsGroupBox.Name = "ProblemDataSettingsGroupBox"; 292 this.ProblemDataSettingsGroupBox.Size = new System.Drawing.Size(447, 258); 293 this.ProblemDataSettingsGroupBox.TabIndex = 17; 294 this.ProblemDataSettingsGroupBox.TabStop = false; 295 this.ProblemDataSettingsGroupBox.Text = "ProblemData Settings"; 296 // 297 // ErrorTextBox 298 // 299 this.ErrorTextBox.Location = new System.Drawing.Point(6, 15); 300 this.ErrorTextBox.Multiline = true; 301 this.ErrorTextBox.Name = "ErrorTextBox"; 302 this.ErrorTextBox.Size = new System.Drawing.Size(435, 73); 303 this.ErrorTextBox.TabIndex = 0; 304 this.ErrorTextBox.Visible = false; 305 // 306 // ShuffelInfoLabel 307 // 308 this.ShuffelInfoLabel.Location = new System.Drawing.Point(111, 20); 309 this.ShuffelInfoLabel.Name = "Shuffle Info"; 310 this.ShuffelInfoLabel.Size = new System.Drawing.Size(16, 16); 311 this.ShuffelInfoLabel.TabIndex = 8; 312 this.ShuffelInfoLabel.Tag = "Check, if the importat data should be shuffled"; 313 this.ShuffelInfoLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Information; 314 this.ShuffelInfoLabel.DoubleClick += new System.EventHandler(this.ControlToolTip_DoubleClick); 315 // 316 // PreviewLabel 317 // 318 this.PreviewLabel.AutoSize = true; 319 this.PreviewLabel.Location = new System.Drawing.Point(9, 89); 320 this.PreviewLabel.Name = "PreviewLabel"; 321 this.PreviewLabel.Size = new System.Drawing.Size(45, 13); 322 this.PreviewLabel.TabIndex = 7; 323 this.PreviewLabel.Text = "Preview"; 324 // 325 // PreviewDatasetMatrix 326 // 327 this.PreviewDatasetMatrix.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 328 | System.Windows.Forms.AnchorStyles.Left) 329 | System.Windows.Forms.AnchorStyles.Right))); 330 this.PreviewDatasetMatrix.Caption = "Dataset Preview"; 331 this.PreviewDatasetMatrix.Content = null; 332 this.PreviewDatasetMatrix.Location = new System.Drawing.Point(6, 108); 333 this.PreviewDatasetMatrix.Name = "PreviewDatasetMatrix"; 334 this.PreviewDatasetMatrix.ReadOnly = true; 335 this.PreviewDatasetMatrix.ShowRowsAndColumnsTextBox = false; 336 this.PreviewDatasetMatrix.ShowStatisticalInformation = false; 337 this.PreviewDatasetMatrix.Size = new System.Drawing.Size(435, 144); 338 this.PreviewDatasetMatrix.TabIndex = 0; 145 339 // 146 340 // DataAnalysisImportTypeDialog … … 149 343 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 150 344 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 151 this.ClientSize = new System.Drawing.Size( 339, 179);345 this.ClientSize = new System.Drawing.Size(471, 442); 152 346 this.ControlBox = false; 347 this.Controls.Add(this.ProblemDataSettingsGroupBox); 348 this.Controls.Add(this.CSVSettingsGroupBox); 153 349 this.Controls.Add(this.ProblemTextBox); 154 this.Controls.Add(this. openFileButton);350 this.Controls.Add(this.OpenFileButton); 155 351 this.Controls.Add(this.ProblemFileLabel); 156 352 this.Controls.Add(this.CancelButton); 157 353 this.Controls.Add(this.OkButton); 158 this.Controls.Add(this.ShuffleDataCheckbox);159 this.Controls.Add(this.TrainingTestGroupBox);160 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;161 354 this.MaximizeBox = false; 162 355 this.MinimizeBox = false; … … 166 359 this.Text = "CSV Import"; 167 360 ((System.ComponentModel.ISupportInitialize)(this.TrainingTestTrackBar)).EndInit(); 168 this.TrainingTestGroupBox.ResumeLayout(false); 169 this.TrainingTestGroupBox.PerformLayout(); 361 this.CSVSettingsGroupBox.ResumeLayout(false); 362 this.CSVSettingsGroupBox.PerformLayout(); 363 this.ProblemDataSettingsGroupBox.ResumeLayout(false); 364 this.ProblemDataSettingsGroupBox.PerformLayout(); 170 365 this.ResumeLayout(false); 171 366 this.PerformLayout(); … … 178 373 protected System.Windows.Forms.Button OkButton; 179 374 protected System.Windows.Forms.TrackBar TrainingTestTrackBar; 180 protected System.Windows.Forms.GroupBox TrainingTestGroupBox;181 375 protected System.Windows.Forms.Label TestLabel; 182 376 protected System.Windows.Forms.Label TrainingLabel; … … 184 378 protected System.Windows.Forms.OpenFileDialog openFileDialog; 185 379 protected System.Windows.Forms.Label ProblemFileLabel; 186 protected System.Windows.Forms.Button openFileButton;380 protected System.Windows.Forms.Button OpenFileButton; 187 381 protected System.Windows.Forms.TextBox ProblemTextBox; 188 382 protected System.Windows.Forms.ComboBox DateTimeFormatComboBox; 383 protected System.Windows.Forms.ComboBox DecimalSeparatorComboBox; 384 protected System.Windows.Forms.Label DateTimeFormatLabel; 385 protected System.Windows.Forms.Label DecimalSeperatorLabel; 386 protected System.Windows.Forms.Label SeparatorLabel; 387 protected System.Windows.Forms.ComboBox SeparatorComboBox; 388 protected System.Windows.Forms.GroupBox CSVSettingsGroupBox; 389 protected System.Windows.Forms.GroupBox ProblemDataSettingsGroupBox; 390 protected System.Windows.Forms.TextBox ErrorTextBox; 391 protected HeuristicLab.Data.Views.StringConvertibleMatrixView PreviewDatasetMatrix; 392 protected System.Windows.Forms.Label PreviewLabel; 393 protected System.Windows.Forms.Label SeparatorInfoLabel; 394 protected System.Windows.Forms.Label DateTimeFormatInfoLabel; 395 protected System.Windows.Forms.Label DecimalSeparatorInfoLabel; 396 protected System.Windows.Forms.Label ShuffelInfoLabel; 397 protected System.Windows.Forms.ToolTip ToolTip; 189 398 } 190 399 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.cs
r8693 r8877 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.ComponentModel; 25 using System.Globalization; 26 using System.Linq; 22 27 using System.Windows.Forms; 28 using HeuristicLab.Core.Views; 29 using HeuristicLab.Problems.DataAnalysis; 23 30 24 31 namespace HeuristicLab.Problems.Instances.DataAnalysis.Views { 25 32 public partial class DataAnalysisImportTypeDialog : Form { 33 34 public static readonly BindingList<KeyValuePair<DateTimeFormatInfo, string>> dateTimeFormats = new BindingList<KeyValuePair<DateTimeFormatInfo, string>>{ 35 new KeyValuePair<DateTimeFormatInfo, string>(DateTimeFormatInfo.GetInstance(new CultureInfo("de-DE")), "dd/mm/yyyy hh:MM:ss" ), 36 new KeyValuePair<DateTimeFormatInfo, string>(DateTimeFormatInfo.InvariantInfo, "mm/dd/yyyy hh:MM:ss" ), 37 new KeyValuePair<DateTimeFormatInfo, string>(DateTimeFormatInfo.InvariantInfo, "yyyy/mm/dd hh:MM:ss" ), 38 new KeyValuePair<DateTimeFormatInfo, string>(DateTimeFormatInfo.InvariantInfo, "mm/yyyy/dd hh:MM:ss" ) 39 }; 40 41 public static readonly BindingList<KeyValuePair<char, string>> POSSIBLE_SEPARATORS = new BindingList<KeyValuePair<char, string>>{ 42 new KeyValuePair<char, string>(',', ", (Comma)" ), 43 new KeyValuePair<char, string>(';', "; (Semicolon)" ), 44 new KeyValuePair<char, string>('\t', "\\t (Tab)") 45 }; 46 47 public static readonly BindingList<KeyValuePair<NumberFormatInfo, string>> POSSIBLE_DECIMAL_SEPARATORS = new BindingList<KeyValuePair<NumberFormatInfo, string>>{ 48 new KeyValuePair<NumberFormatInfo, string>(NumberFormatInfo.InvariantInfo, ". (Period)" ), 49 new KeyValuePair<NumberFormatInfo, string>(NumberFormatInfo.GetInstance(new CultureInfo("de-DE")), ", (Comma)" ) 50 }; 26 51 27 52 public string Path { … … 38 63 } 39 64 65 public DataAnalysisCSVFormat CSVFormat { 66 get { 67 return new DataAnalysisCSVFormat() { 68 Separator = (char)SeparatorComboBox.SelectedValue, 69 NumberFormatInfo = (NumberFormatInfo)DecimalSeparatorComboBox.SelectedValue, 70 DateTimeFormatInfo = (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue 71 }; 72 } 73 } 74 40 75 public DataAnalysisImportTypeDialog() { 41 76 InitializeComponent(); 77 ToolTip.SetToolTip(SeparatorInfoLabel, (string)SeparatorInfoLabel.Tag); 78 ToolTip.SetToolTip(DecimalSeparatorInfoLabel, (string)DecimalSeparatorInfoLabel.Tag); 79 ToolTip.SetToolTip(DateTimeFormatInfoLabel, (string)DateTimeFormatInfoLabel.Tag); 80 ToolTip.SetToolTip(ShuffelInfoLabel, (string)ShuffelInfoLabel.Tag); 81 82 SeparatorComboBox.DataSource = POSSIBLE_SEPARATORS; 83 SeparatorComboBox.ValueMember = "Key"; 84 SeparatorComboBox.DisplayMember = "Value"; 85 DecimalSeparatorComboBox.DataSource = POSSIBLE_DECIMAL_SEPARATORS; 86 DecimalSeparatorComboBox.ValueMember = "Key"; 87 DecimalSeparatorComboBox.DisplayMember = "Value"; 88 DateTimeFormatComboBox.DataSource = dateTimeFormats; 89 DateTimeFormatComboBox.ValueMember = "Key"; 90 DateTimeFormatComboBox.DisplayMember = "Value"; 42 91 } 43 92 … … 47 96 } 48 97 49 private void openFileButton_Click(object sender, System.EventArgs e) { 50 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 51 ProblemTextBox.Text = openFileDialog.FileName; 98 protected virtual void OpenFileButtonClick(object sender, System.EventArgs e) { 99 if (openFileDialog.ShowDialog(this) != DialogResult.OK) return; 100 101 ProblemTextBox.Text = openFileDialog.FileName; 102 ParseCSVFile(); 103 } 104 105 protected virtual void CSVFormatComboBoxSelectionChangeCommitted(object sender, EventArgs e) { 106 if (string.IsNullOrEmpty(ProblemTextBox.Text)) return; 107 108 ParseCSVFile(); 109 } 110 111 protected void ParseCSVFile() { 112 PreviewDatasetMatrix.Content = null; 113 try { 114 TableFileParser csvParser = new TableFileParser(); 115 csvParser.Parse(ProblemTextBox.Text, 116 (NumberFormatInfo)DecimalSeparatorComboBox.SelectedValue, 117 (DateTimeFormatInfo)DateTimeFormatComboBox.SelectedValue, 118 (char)SeparatorComboBox.SelectedValue); 119 IEnumerable<string> variableNamesWithType = GetVariableNamesWithType(csvParser); 120 PreviewDatasetMatrix.Content = new Dataset(variableNamesWithType, csvParser.Values); 121 122 CheckAdditionalConstraints(csvParser); 123 124 ErrorTextBox.Text = String.Empty; 125 ErrorTextBox.Visible = false; 52 126 OkButton.Enabled = true; 127 } 128 catch (Exception ex) { 129 OkButton.Enabled = false; 130 ErrorTextBox.Text = ex.Message; 131 ErrorTextBox.Visible = true; 132 } 133 } 134 135 protected virtual void CheckAdditionalConstraints(TableFileParser csvParser) { 136 if (!csvParser.Values.Any(x => x is List<double>)) { 137 throw new ArgumentException("No double column could be found!"); 138 } 139 } 140 141 private IEnumerable<string> GetVariableNamesWithType(TableFileParser csvParser) { 142 IList<string> variableNamesWithType = csvParser.VariableNames.ToList(); 143 for (int i = 0; i < csvParser.Values.Count; i++) { 144 if (csvParser.Values[i] is List<double>) { 145 variableNamesWithType[i] += " (Double)"; 146 } else if (csvParser.Values[i] is List<string>) { 147 variableNamesWithType[i] += " (String)"; 148 } else if (csvParser.Values[i] is List<DateTime>) { 149 variableNamesWithType[i] += " (DateTime)"; 150 } else { 151 throw new ArgumentException("The variable values must be of type List<double>, List<string> or List<DateTime>"); 152 } 153 } 154 return variableNamesWithType; 155 } 156 157 protected void ControlToolTip_DoubleClick(object sender, EventArgs e) { 158 Control control = sender as Control; 159 if (control != null) { 160 using (TextDialog dialog = new TextDialog(control.Name, (string)control.Tag, true)) { 161 dialog.ShowDialog(this); 162 } 53 163 } 54 164 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisInstanceConsumerView.cs
r8693 r8877 30 30 [View("DataAnalysis InstanceProvider View")] 31 31 [Content(typeof(IProblemInstanceConsumer<IDataAnalysisProblemData>), IsDefaultView = true)] 32 [Content(typeof(IProblemInstanceConsumer<IClassificationProblemData>), IsDefaultView = true)]33 [Content(typeof(IProblemInstanceConsumer<IRegressionProblemData>), IsDefaultView = true)]34 32 [Content(typeof(IProblemInstanceConsumer<IClusteringProblemData>), IsDefaultView = true)] 35 33 public partial class DataAnalysisInstanceConsumerView<T> : ProblemInstanceConsumerViewGeneric<T> … … 42 40 public DataAnalysisInstanceConsumerView() { 43 41 InitializeComponent(); 42 44 43 } 45 44 46 45 protected override void importButton_Click(object sender, EventArgs e) { 47 var provider = SelectedProvider as DataAnalysisInstanceProvider<T >;46 var provider = SelectedProvider as DataAnalysisInstanceProvider<T, DataAnalysisImportType>; 48 47 if (provider != null) { 49 48 DataAnalysisImportTypeDialog importTypeDialog = new DataAnalysisImportTypeDialog(); … … 51 50 T instance = default(T); 52 51 try { 53 instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType );52 instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat); 54 53 55 54 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.csproj
r8781 r8877 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="ClassificationImportTypeDialog.cs"> 84 <SubType>Form</SubType> 85 </Compile> 86 <Compile Include="ClassificationImportTypeDialog.Designer.cs"> 87 <DependentUpon>ClassificationImportTypeDialog.cs</DependentUpon> 88 </Compile> 89 <Compile Include="ClassificationInstanceConsumerView.cs"> 90 <SubType>UserControl</SubType> 91 </Compile> 92 <Compile Include="ClassificationInstanceConsumerView.Designer.cs"> 93 <DependentUpon>ClassificationInstanceConsumerView.cs</DependentUpon> 94 </Compile> 83 95 <Compile Include="DataAnalysisImportTypeDialog.cs"> 84 96 <SubType>Form</SubType> … … 94 106 </Compile> 95 107 <Compile Include="Plugin.cs" /> 108 <Compile Include="RegressionImportTypeDialog.cs"> 109 <SubType>Form</SubType> 110 </Compile> 111 <Compile Include="RegressionImportTypeDialog.Designer.cs"> 112 <DependentUpon>RegressionImportTypeDialog.cs</DependentUpon> 113 </Compile> 114 <Compile Include="RegressionInstanceConsumerView.cs"> 115 <SubType>UserControl</SubType> 116 </Compile> 117 <Compile Include="RegressionInstanceConsumerView.Designer.cs"> 118 <DependentUpon>RegressionInstanceConsumerView.cs</DependentUpon> 119 </Compile> 96 120 <None Include="HeuristicLab.snk" /> 97 121 <None Include="Plugin.cs.frame" /> … … 100 124 </ItemGroup> 101 125 <ItemGroup> 126 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj"> 127 <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project> 128 <Name>HeuristicLab.Common.Resources-3.3</Name> 129 </ProjectReference> 102 130 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> 103 131 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 104 132 <Name>HeuristicLab.Common-3.3</Name> 105 133 </ProjectReference> 134 <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj"> 135 <Project>{e226881d-315f-423d-b419-a766fe0d8685}</Project> 136 <Name>HeuristicLab.Core.Views-3.3</Name> 137 </ProjectReference> 106 138 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 107 139 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 108 140 <Name>HeuristicLab.Core-3.3</Name> 141 </ProjectReference> 142 <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj"> 143 <Project>{72104a0b-90e7-42f3-9abe-9bbbadd4b943}</Project> 144 <Name>HeuristicLab.Data.Views-3.3</Name> 109 145 </ProjectReference> 110 146 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/Plugin.cs.frame
r8598 r8877 25 25 [Plugin("HeuristicLab.Problems.Instances.DataAnalysis.Views", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 28 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 29 [PluginDependency("HeuristicLab.Data", "3.3")] 30 [PluginDependency("HeuristicLab.Data.Views", "3.3")] 27 31 [PluginDependency("HeuristicLab.MainForm", "3.3")] 32 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 28 33 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 29 34 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV/ClassifiactionCSVInstanceProvider.cs
r8693 r8877 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization;26 25 using System.IO; 27 26 using System.Linq; 28 using System.Text;29 27 using HeuristicLab.Common; 30 28 using HeuristicLab.Problems.DataAnalysis; … … 76 74 } 77 75 } else { 78 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));76 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar))); 79 77 } 80 78 … … 92 90 } 93 91 94 public override IClassificationProblemData ImportData(string path, DataAnalysisImportType type) { 95 TableFileParser csvFileParser = new TableFileParser(); 96 csvFileParser.Parse(path); 97 92 protected override IClassificationProblemData ImportData(string path, ClassificationImportType type, TableFileParser csvFileParser) { 98 93 int trainingPartEnd = (csvFileParser.Rows * type.Training) / 100; 99 94 List<IList> values = csvFileParser.Values; 100 95 if (type.Shuffle) { 101 values = Shuffle(values); 96 values = Shuffle(values, csvFileParser.VariableNames.ToList().FindIndex(x => x.Equals(type.TargetVariable)), 97 type.Training, out trainingPartEnd); 102 98 } 103 99 104 100 Dataset dataset = new Dataset(csvFileParser.VariableNames, values); 105 string targetVar = dataset.DoubleVariables.Last();106 101 107 102 // turn of input variables that are constant in the training partition 108 103 var allowedInputVars = new List<string>(); 109 104 var trainingIndizes = Enumerable.Range(0, trainingPartEnd); 110 foreach (var variableName in dataset.DoubleVariables) { 111 if (trainingIndizes.Count() >= 2 && dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 112 variableName != targetVar) 113 allowedInputVars.Add(variableName); 105 if (trainingIndizes.Count() >= 2) { 106 foreach (var variableName in dataset.DoubleVariables) { 107 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 108 variableName != type.TargetVariable) 109 allowedInputVars.Add(variableName); 110 } 111 } else { 112 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(type.TargetVariable))); 114 113 } 115 114 116 ClassificationProblemData classificationData = new ClassificationProblemData(dataset, allowedInputVars, t argetVar);115 ClassificationProblemData classificationData = new ClassificationProblemData(dataset, allowedInputVars, type.TargetVariable); 117 116 118 117 classificationData.TrainingPartition.Start = 0; … … 126 125 } 127 126 128 public override bool CanExportData { 129 get { return true; } 130 } 131 public override void ExportData(IClassificationProblemData instance, string path) { 132 var strBuilder = new StringBuilder(); 133 var colSep = CultureInfo.CurrentCulture.TextInfo.ListSeparator; 134 foreach (var variable in instance.Dataset.VariableNames) { 135 strBuilder.Append(variable.Replace(colSep, String.Empty) + colSep); 136 } 137 strBuilder.Remove(strBuilder.Length - colSep.Length, colSep.Length); 138 strBuilder.AppendLine(); 139 140 var dataset = instance.Dataset; 141 142 for (int i = 0; i < dataset.Rows; i++) { 143 for (int j = 0; j < dataset.Columns; j++) { 144 if (j > 0) strBuilder.Append(colSep); 145 strBuilder.Append(dataset.GetValue(i, j)); 146 } 147 strBuilder.AppendLine(); 127 protected List<IList> Shuffle(List<IList> values, int target, int trainingPercentage, out int trainingPartEnd) { 128 IList targetValues = values[target]; 129 var group = targetValues.Cast<double>().GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); 130 Dictionary<double, double> taken = new Dictionary<double, double>(); 131 foreach (var classCount in group) { 132 taken[classCount.Key] = (classCount.Count * trainingPercentage) / 100.0; 148 133 } 149 134 150 using (var writer = new StreamWriter(path)) { 151 writer.Write(strBuilder); 135 List<IList> training = GetListOfIListCopy(values); 136 List<IList> test = GetListOfIListCopy(values); 137 138 for (int i = 0; i < targetValues.Count; i++) { 139 if (taken[(double)targetValues[i]] > 0) { 140 AddRow(training, values, i); 141 taken[(double)targetValues[i]]--; 142 } else { 143 AddRow(test, values, i); 144 } 152 145 } 146 147 trainingPartEnd = training.First().Count; 148 149 training = Shuffle(training); 150 test = Shuffle(test); 151 for (int i = 0; i < training.Count; i++) { 152 for (int j = 0; j < test[i].Count; j++) { 153 training[i].Add(test[i][j]); 154 } 155 } 156 157 return training; 158 } 159 160 private void AddRow(List<IList> destination, List<IList> source, int index) { 161 for (int i = 0; i < source.Count; i++) { 162 destination[i].Add(source[i][index]); 163 } 164 } 165 166 private List<IList> GetListOfIListCopy(List<IList> values) { 167 List<IList> newList = new List<IList>(values.Count); 168 foreach (IList t in values) { 169 if (t is List<double>) 170 newList.Add(new List<double>()); 171 else if (t is List<DateTime>) 172 newList.Add(new List<DateTime>()); 173 else if (t is List<string>) 174 newList.Add(new List<string>()); 175 else 176 throw new InvalidOperationException(); 177 } 178 return newList; 153 179 } 154 180 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs
r8598 r8877 23 23 24 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 25 public abstract class ClassificationInstanceProvider : DataAnalysisInstanceProvider<IClassificationProblemData > {25 public abstract class ClassificationInstanceProvider : DataAnalysisInstanceProvider<IClassificationProblemData, ClassificationImportType> { 26 26 } 27 27 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs
r8685 r8877 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization;26 25 using System.IO; 27 26 using System.Linq; 28 using System.Text;29 27 using HeuristicLab.Common; 30 28 using HeuristicLab.Problems.DataAnalysis; … … 75 73 } 76 74 } else { 77 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));75 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar))); 78 76 } 79 77 … … 91 89 } 92 90 93 public override IClusteringProblemData ImportData(string path, DataAnalysisImportType type) { 94 TableFileParser csvFileParser = new TableFileParser(); 95 csvFileParser.Parse(path); 96 91 protected override IClusteringProblemData ImportData(string path, DataAnalysisImportType type, TableFileParser csvFileParser) { 97 92 List<IList> values = csvFileParser.Values; 98 93 if (type.Shuffle) { … … 107 102 int trainingPartEnd = (csvFileParser.Rows * type.Training) / 100; 108 103 var trainingIndizes = Enumerable.Range(0, trainingPartEnd); 109 foreach (var variableName in dataset.DoubleVariables) { 110 if (trainingIndizes.Count() >= 2 && dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 111 variableName != targetVar) 112 allowedInputVars.Add(variableName); 104 if (trainingIndizes.Count() >= 2) { 105 foreach (var variableName in dataset.DoubleVariables) { 106 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 107 variableName != targetVar) 108 allowedInputVars.Add(variableName); 109 } 110 } else { 111 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar))); 113 112 } 114 113 … … 124 123 return clusteringData; 125 124 } 126 127 public override bool CanExportData {128 get { return true; }129 }130 public override void ExportData(IClusteringProblemData instance, string path) {131 var strBuilder = new StringBuilder();132 var colSep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;133 foreach (var variable in instance.Dataset.VariableNames) {134 strBuilder.Append(variable.Replace(colSep, String.Empty) + colSep);135 }136 strBuilder.Remove(strBuilder.Length - colSep.Length, colSep.Length);137 strBuilder.AppendLine();138 139 var dataset = instance.Dataset;140 141 for (int i = 0; i < dataset.Rows; i++) {142 for (int j = 0; j < dataset.Columns; j++) {143 if (j > 0) strBuilder.Append(colSep);144 strBuilder.Append(dataset.GetValue(i, j));145 }146 strBuilder.AppendLine();147 }148 149 using (var writer = new StreamWriter(path)) {150 writer.Write(strBuilder);151 }152 }153 125 } 154 126 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/ClusteringInstanceProvider.cs
r8598 r8877 23 23 24 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 25 public abstract class ClusteringInstanceProvider : DataAnalysisInstanceProvider<IClusteringProblemData > {25 public abstract class ClusteringInstanceProvider : DataAnalysisInstanceProvider<IClusteringProblemData, DataAnalysisImportType> { 26 26 } 27 27 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisInstanceProvider.cs
r8598 r8877 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization; 26 using System.IO; 25 27 using System.Linq; 28 using System.Text; 26 29 using HeuristicLab.Problems.DataAnalysis; 30 using HeuristicLab.Random; 27 31 28 32 namespace HeuristicLab.Problems.Instances.DataAnalysis { 29 public abstract class DataAnalysisInstanceProvider<TData> : ProblemInstanceProvider<TData> 30 where TData : class, IDataAnalysisProblemData { 33 public abstract class DataAnalysisInstanceProvider<TData, ImportType> : ProblemInstanceProvider<TData> 34 where TData : class, IDataAnalysisProblemData 35 where ImportType : DataAnalysisImportType { 31 36 32 37 // has to be implemented, if CanImportData is true 33 public virtual TData ImportData(string path, DataAnalysisImportType type) { 34 throw new NotSupportedException(); 38 public TData ImportData(string path, ImportType type) { 39 TableFileParser csvFileParser = new TableFileParser(); 40 csvFileParser.Parse(path); 41 return ImportData(path, type, csvFileParser); 35 42 } 43 public TData ImportData(string path, ImportType type, DataAnalysisCSVFormat csvFormat) { 44 TableFileParser csvFileParser = new TableFileParser(); 45 csvFileParser.Parse(path, csvFormat.NumberFormatInfo, csvFormat.DateTimeFormatInfo, csvFormat.Separator); 46 return ImportData(path, type, csvFileParser); 47 } 48 49 protected abstract TData ImportData(string path, ImportType type, TableFileParser csvFileParser); 36 50 37 51 protected List<IList> Shuffle(List<IList> values) { 38 52 int count = values.First().Count; 39 int[] indices = GetRandomIndices(count);53 int[] indices = Enumerable.Range(0, count).Shuffle(new FastRandom()).ToArray(); 40 54 List<IList> shuffeledValues = new List<IList>(values.Count); 41 55 for (int col = 0; col < values.Count; col++) { … … 57 71 } 58 72 59 //Fisher–Yates shuffle 60 private int[] GetRandomIndices(int amount) { 61 int[] randomIndices = Enumerable.Range(0, amount).ToArray(); 62 System.Random rand = new System.Random(); 63 int n = amount; 64 while (n > 1) { 65 n--; 66 int k = rand.Next(n + 1); 67 int value = randomIndices[k]; 68 randomIndices[k] = randomIndices[n]; 69 randomIndices[n] = value; 73 public override bool CanExportData { 74 get { return true; } 75 } 76 public override void ExportData(TData instance, string path) { 77 var strBuilder = new StringBuilder(); 78 var colSep = CultureInfo.CurrentCulture.TextInfo.ListSeparator; 79 foreach (var variable in instance.Dataset.VariableNames) { 80 strBuilder.Append(variable.Replace(colSep, String.Empty) + colSep); 70 81 } 71 return randomIndices; 82 strBuilder.Remove(strBuilder.Length - colSep.Length, colSep.Length); 83 strBuilder.AppendLine(); 84 85 var dataset = instance.Dataset; 86 87 for (int i = 0; i < dataset.Rows; i++) { 88 for (int j = 0; j < dataset.Columns; j++) { 89 if (j > 0) strBuilder.Append(colSep); 90 strBuilder.Append(dataset.GetValue(i, j)); 91 } 92 strBuilder.AppendLine(); 93 } 94 95 using (var writer = new StreamWriter(path)) { 96 writer.Write(strBuilder); 97 } 72 98 } 73 99 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj
r8841 r8877 115 115 <Compile Include="Classification\ArtificialClassificationDataDescriptor.cs" /> 116 116 <Compile Include="Classification\ArtificialClassificationInstanceProvider.cs" /> 117 <Compile Include="Classification\ClassificationImportType.cs" /> 117 118 <Compile Include="Classification\ClassificationInstanceProvider.cs" /> 118 119 <Compile Include="Classification\CSV\ClassifiactionCSVInstanceProvider.cs" /> … … 126 127 <Compile Include="Clustering\ClusteringInstanceProvider.cs" /> 127 128 <Compile Include="Clustering\CSV\ClusteringCSVInstanceProvider.cs" /> 129 <Compile Include="DataAnalysisCSVFormat.cs" /> 128 130 <Compile Include="DataAnalysisImportType.cs" /> 129 131 <Compile Include="DataAnalysisInstanceProvider.cs" /> … … 179 181 <Compile Include="Regression\Nguyen\NguyenInstanceProvider.cs" /> 180 182 <Compile Include="Regression\RealWorld\RegressionRealWorldInstanceProvider.cs" /> 183 <Compile Include="Regression\RegressionImportType.cs" /> 181 184 <Compile Include="Regression\RegressionInstanceProvider.cs" /> 182 185 <Compile Include="Regression\ResourceRegressionDataDescriptor.cs" /> -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs
r8685 r8877 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization;26 25 using System.IO; 27 26 using System.Linq; 28 using System.Text;29 27 using HeuristicLab.Common; 30 28 using HeuristicLab.Problems.DataAnalysis; … … 67 65 var allowedInputVars = new List<string>(); 68 66 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 69 foreach (var variableName in dataset.DoubleVariables) { 70 if (trainingIndizes.Count() >= 2 && dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 71 variableName != targetVar) 72 allowedInputVars.Add(variableName); 67 if (trainingIndizes.Count() >= 2) { 68 foreach (var variableName in dataset.DoubleVariables) { 69 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 70 variableName != targetVar) 71 allowedInputVars.Add(variableName); 72 } 73 } else { 74 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar))); 73 75 } 74 76 … … 86 88 } 87 89 88 public override IRegressionProblemData ImportData(string path, DataAnalysisImportType type) { 89 TableFileParser csvFileParser = new TableFileParser(); 90 csvFileParser.Parse(path); 91 90 protected override IRegressionProblemData ImportData(string path, RegressionImportType type, TableFileParser csvFileParser) { 92 91 List<IList> values = csvFileParser.Values; 93 92 if (type.Shuffle) { … … 95 94 } 96 95 Dataset dataset = new Dataset(csvFileParser.VariableNames, values); 97 string targetVar = dataset.DoubleVariables.Last();98 96 99 97 // turn of input variables that are constant in the training partition … … 105 103 foreach (var variableName in dataset.DoubleVariables) { 106 104 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 107 variableName != t argetVar)105 variableName != type.TargetVariable) 108 106 allowedInputVars.Add(variableName); 109 107 } 110 108 } else { 111 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));109 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(type.TargetVariable))); 112 110 } 113 111 114 RegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, t argetVar);112 RegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, type.TargetVariable); 115 113 116 114 regressionData.TrainingPartition.Start = 0; … … 123 121 return regressionData; 124 122 } 125 126 public override bool CanExportData {127 get { return true; }128 }129 public override void ExportData(IRegressionProblemData instance, string path) {130 var strBuilder = new StringBuilder();131 var colSep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;132 foreach (var variable in instance.Dataset.VariableNames) {133 strBuilder.Append(variable.Replace(colSep, String.Empty) + colSep);134 }135 strBuilder.Remove(strBuilder.Length - colSep.Length, colSep.Length);136 strBuilder.AppendLine();137 138 var dataset = instance.Dataset;139 140 for (int i = 0; i < dataset.Rows; i++) {141 for (int j = 0; j < dataset.Columns; j++) {142 if (j > 0) strBuilder.Append(colSep);143 strBuilder.Append(dataset.GetValue(i, j));144 }145 strBuilder.AppendLine();146 }147 148 using (var writer = new StreamWriter(path)) {149 writer.Write(strBuilder);150 }151 }152 123 } 153 124 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs
r8598 r8877 23 23 24 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 25 public abstract class RegressionInstanceProvider : DataAnalysisInstanceProvider<IRegressionProblemData > {25 public abstract class RegressionInstanceProvider : DataAnalysisInstanceProvider<IRegressionProblemData, RegressionImportType> { 26 26 } 27 27 }
Note: See TracChangeset
for help on using the changeset viewer.