Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8877


Ignore:
Timestamp:
11/07/12 16:28:33 (11 years ago)
Author:
mkommend
Message:

#1942: Reintegrated branch for CSV import.

Location:
trunk/sources
Files:
17 edited
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis

  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r8802 r8877  
    304304    }
    305305
    306     private static IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) {
     306    public static IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) {
    307307      int maxSamples = Math.Min(InspectedRowsToDetermineTargets, dataset.Rows);
    308308      var validTargetVariables = (from v in dataset.DoubleVariables
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis

  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views

  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.Designer.cs

    r8693 r8877  
    1 namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
     1
     2namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23  partial class DataAnalysisImportTypeDialog {
    34    /// <summary>
     
    2425    /// </summary>
    2526    private void InitializeComponent() {
     27      this.components = new System.ComponentModel.Container();
     28      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataAnalysisImportTypeDialog));
    2629      this.ShuffleDataCheckbox = new System.Windows.Forms.CheckBox();
    2730      this.OkButton = new System.Windows.Forms.Button();
    2831      this.TrainingTestTrackBar = new System.Windows.Forms.TrackBar();
    29       this.TrainingTestGroupBox = new System.Windows.Forms.GroupBox();
    3032      this.TestLabel = new System.Windows.Forms.Label();
    3133      this.TrainingLabel = new System.Windows.Forms.Label();
    3234      this.CancelButton = new System.Windows.Forms.Button();
    33       this.openFileButton = new System.Windows.Forms.Button();
     35      this.OpenFileButton = new System.Windows.Forms.Button();
    3436      this.ProblemFileLabel = new System.Windows.Forms.Label();
    3537      this.ProblemTextBox = new System.Windows.Forms.TextBox();
    3638      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);
    3755      ((System.ComponentModel.ISupportInitialize)(this.TrainingTestTrackBar)).BeginInit();
    38       this.TrainingTestGroupBox.SuspendLayout();
     56      this.CSVSettingsGroupBox.SuspendLayout();
     57      this.ProblemDataSettingsGroupBox.SuspendLayout();
    3958      this.SuspendLayout();
    4059      //
     
    4261      //
    4362      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);
    4565      this.ShuffleDataCheckbox.Name = "ShuffleDataCheckbox";
    4666      this.ShuffleDataCheckbox.Size = new System.Drawing.Size(91, 17);
     
    5171      // OkButton
    5272      //
     73      this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    5374      this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    5475      this.OkButton.Enabled = false;
    55       this.OkButton.Location = new System.Drawing.Point(61, 147);
     76      this.OkButton.Location = new System.Drawing.Point(87, 407);
    5677      this.OkButton.Name = "OkButton";
    5778      this.OkButton.Size = new System.Drawing.Size(75, 23);
     
    6485      this.TrainingTestTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    6586                  | 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);
    6788      this.TrainingTestTrackBar.Maximum = 100;
    6889      this.TrainingTestTrackBar.Minimum = 1;
    6990      this.TrainingTestTrackBar.Name = "TrainingTestTrackBar";
    70       this.TrainingTestTrackBar.Size = new System.Drawing.Size(303, 45);
     91      this.TrainingTestTrackBar.Size = new System.Drawing.Size(435, 45);
    7192      this.TrainingTestTrackBar.TabIndex = 4;
    7293      this.TrainingTestTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     
    7495      this.TrainingTestTrackBar.ValueChanged += new System.EventHandler(this.TrainingTestTrackBar_ValueChanged);
    7596      //
    76       // TrainingTestGroupBox
    77       //
    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       //
    8897      // TestLabel
    8998      //
     99      this.TestLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    90100      this.TestLabel.AutoSize = true;
    91       this.TestLabel.Location = new System.Drawing.Point(188, 51);
     101      this.TestLabel.Location = new System.Drawing.Point(303, 68);
    92102      this.TestLabel.Name = "TestLabel";
    93103      this.TestLabel.Size = new System.Drawing.Size(57, 13);
     
    98108      //
    99109      this.TrainingLabel.AutoSize = true;
    100       this.TrainingLabel.Location = new System.Drawing.Point(50, 51);
     110      this.TrainingLabel.Location = new System.Drawing.Point(76, 68);
    101111      this.TrainingLabel.Name = "TrainingLabel";
    102112      this.TrainingLabel.Size = new System.Drawing.Size(74, 13);
     
    106116      // CancelButton
    107117      //
     118      this.CancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    108119      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);
    110121      this.CancelButton.Name = "CancelButton";
    111122      this.CancelButton.Size = new System.Drawing.Size(75, 23);
     
    114125      this.CancelButton.UseVisualStyleBackColor = true;
    115126      //
    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);
    124137      //
    125138      // ProblemFileLabel
    126139      //
    127140      this.ProblemFileLabel.AutoSize = true;
    128       this.ProblemFileLabel.Location = new System.Drawing.Point(12, 15);
     141      this.ProblemFileLabel.Location = new System.Drawing.Point(18, 9);
    129142      this.ProblemFileLabel.Name = "ProblemFileLabel";
    130143      this.ProblemFileLabel.Size = new System.Drawing.Size(67, 13);
     
    134147      // ProblemTextBox
    135148      //
    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);
    137152      this.ProblemTextBox.Name = "ProblemTextBox";
    138153      this.ProblemTextBox.ReadOnly = true;
    139       this.ProblemTextBox.Size = new System.Drawing.Size(212, 20);
     154      this.ProblemTextBox.Size = new System.Drawing.Size(332, 20);
    140155      this.ProblemTextBox.TabIndex = 9;
    141156      //
     
    143158      //
    144159      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;
    145339      //
    146340      // DataAnalysisImportTypeDialog
     
    149343      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    150344      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);
    152346      this.ControlBox = false;
     347      this.Controls.Add(this.ProblemDataSettingsGroupBox);
     348      this.Controls.Add(this.CSVSettingsGroupBox);
    153349      this.Controls.Add(this.ProblemTextBox);
    154       this.Controls.Add(this.openFileButton);
     350      this.Controls.Add(this.OpenFileButton);
    155351      this.Controls.Add(this.ProblemFileLabel);
    156352      this.Controls.Add(this.CancelButton);
    157353      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;
    161354      this.MaximizeBox = false;
    162355      this.MinimizeBox = false;
     
    166359      this.Text = "CSV Import";
    167360      ((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();
    170365      this.ResumeLayout(false);
    171366      this.PerformLayout();
     
    178373    protected System.Windows.Forms.Button OkButton;
    179374    protected System.Windows.Forms.TrackBar TrainingTestTrackBar;
    180     protected System.Windows.Forms.GroupBox TrainingTestGroupBox;
    181375    protected System.Windows.Forms.Label TestLabel;
    182376    protected System.Windows.Forms.Label TrainingLabel;
     
    184378    protected System.Windows.Forms.OpenFileDialog openFileDialog;
    185379    protected System.Windows.Forms.Label ProblemFileLabel;
    186     protected System.Windows.Forms.Button openFileButton;
     380    protected System.Windows.Forms.Button OpenFileButton;
    187381    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;
    189398  }
    190399}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisImportTypeDialog.cs

    r8693 r8877  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.ComponentModel;
     25using System.Globalization;
     26using System.Linq;
    2227using System.Windows.Forms;
     28using HeuristicLab.Core.Views;
     29using HeuristicLab.Problems.DataAnalysis;
    2330
    2431namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    2532  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    };
    2651
    2752    public string Path {
     
    3863    }
    3964
     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
    4075    public DataAnalysisImportTypeDialog() {
    4176      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";
    4291    }
    4392
     
    4796    }
    4897
    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;
    52126        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        }
    53163      }
    54164    }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisInstanceConsumerView.cs

    r8693 r8877  
    3030  [View("DataAnalysis InstanceProvider View")]
    3131  [Content(typeof(IProblemInstanceConsumer<IDataAnalysisProblemData>), IsDefaultView = true)]
    32   [Content(typeof(IProblemInstanceConsumer<IClassificationProblemData>), IsDefaultView = true)]
    33   [Content(typeof(IProblemInstanceConsumer<IRegressionProblemData>), IsDefaultView = true)]
    3432  [Content(typeof(IProblemInstanceConsumer<IClusteringProblemData>), IsDefaultView = true)]
    3533  public partial class DataAnalysisInstanceConsumerView<T> : ProblemInstanceConsumerViewGeneric<T>
     
    4240    public DataAnalysisInstanceConsumerView() {
    4341      InitializeComponent();
     42
    4443    }
    4544
    4645    protected override void importButton_Click(object sender, EventArgs e) {
    47       var provider = SelectedProvider as DataAnalysisInstanceProvider<T>;
     46      var provider = SelectedProvider as DataAnalysisInstanceProvider<T, DataAnalysisImportType>;
    4847      if (provider != null) {
    4948        DataAnalysisImportTypeDialog importTypeDialog = new DataAnalysisImportTypeDialog();
     
    5150          T instance = default(T);
    5251          try {
    53             instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType);
     52            instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    5453
    5554          }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.csproj

    r8781 r8877  
    8181  </ItemGroup>
    8282  <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>
    8395    <Compile Include="DataAnalysisImportTypeDialog.cs">
    8496      <SubType>Form</SubType>
     
    94106    </Compile>
    95107    <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>
    96120    <None Include="HeuristicLab.snk" />
    97121    <None Include="Plugin.cs.frame" />
     
    100124  </ItemGroup>
    101125  <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>
    102130    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    103131      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    104132      <Name>HeuristicLab.Common-3.3</Name>
    105133    </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>
    106138    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    107139      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    108140      <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>
    109145    </ProjectReference>
    110146    <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  
    2525  [Plugin("HeuristicLab.Problems.Instances.DataAnalysis.Views", "3.3.7.$WCREV$")]
    2626  [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")]
    2731  [PluginDependency("HeuristicLab.MainForm", "3.3")]
     32  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    2833  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    2934  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV/ClassifiactionCSVInstanceProvider.cs

    r8693 r8877  
    2323using System.Collections;
    2424using System.Collections.Generic;
    25 using System.Globalization;
    2625using System.IO;
    2726using System.Linq;
    28 using System.Text;
    2927using HeuristicLab.Common;
    3028using HeuristicLab.Problems.DataAnalysis;
     
    7674        }
    7775      } else {
    78         allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));
     76        allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar)));
    7977      }
    8078
     
    9290    }
    9391
    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) {
    9893      int trainingPartEnd = (csvFileParser.Rows * type.Training) / 100;
    9994      List<IList> values = csvFileParser.Values;
    10095      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);
    10298      }
    10399
    104100      Dataset dataset = new Dataset(csvFileParser.VariableNames, values);
    105       string targetVar = dataset.DoubleVariables.Last();
    106101
    107102      // turn of input variables that are constant in the training partition
    108103      var allowedInputVars = new List<string>();
    109104      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)));
    114113      }
    115114
    116       ClassificationProblemData classificationData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);
     115      ClassificationProblemData classificationData = new ClassificationProblemData(dataset, allowedInputVars, type.TargetVariable);
    117116
    118117      classificationData.TrainingPartition.Start = 0;
     
    126125    }
    127126
    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;
    148133      }
    149134
    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        }
    152145      }
     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;
    153179    }
    154180  }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs

    r8598 r8877  
    2323
    2424namespace HeuristicLab.Problems.Instances.DataAnalysis {
    25   public abstract class ClassificationInstanceProvider : DataAnalysisInstanceProvider<IClassificationProblemData> {
     25  public abstract class ClassificationInstanceProvider : DataAnalysisInstanceProvider<IClassificationProblemData, ClassificationImportType> {
    2626  }
    2727}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r8685 r8877  
    2323using System.Collections;
    2424using System.Collections.Generic;
    25 using System.Globalization;
    2625using System.IO;
    2726using System.Linq;
    28 using System.Text;
    2927using HeuristicLab.Common;
    3028using HeuristicLab.Problems.DataAnalysis;
     
    7573        }
    7674      } else {
    77         allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));
     75        allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar)));
    7876      }
    7977
     
    9189    }
    9290
    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) {
    9792      List<IList> values = csvFileParser.Values;
    9893      if (type.Shuffle) {
     
    107102      int trainingPartEnd = (csvFileParser.Rows * type.Training) / 100;
    108103      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)));
    113112      }
    114113
     
    124123      return clusteringData;
    125124    }
    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     }
    153125  }
    154126}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/ClusteringInstanceProvider.cs

    r8598 r8877  
    2323
    2424namespace HeuristicLab.Problems.Instances.DataAnalysis {
    25   public abstract class ClusteringInstanceProvider : DataAnalysisInstanceProvider<IClusteringProblemData> {
     25  public abstract class ClusteringInstanceProvider : DataAnalysisInstanceProvider<IClusteringProblemData, DataAnalysisImportType> {
    2626  }
    2727}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisInstanceProvider.cs

    r8598 r8877  
    2323using System.Collections;
    2424using System.Collections.Generic;
     25using System.Globalization;
     26using System.IO;
    2527using System.Linq;
     28using System.Text;
    2629using HeuristicLab.Problems.DataAnalysis;
     30using HeuristicLab.Random;
    2731
    2832namespace 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 {
    3136
    3237    // 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);
    3542    }
     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);
    3650
    3751    protected List<IList> Shuffle(List<IList> values) {
    3852      int count = values.First().Count;
    39       int[] indices = GetRandomIndices(count);
     53      int[] indices = Enumerable.Range(0, count).Shuffle(new FastRandom()).ToArray();
    4054      List<IList> shuffeledValues = new List<IList>(values.Count);
    4155      for (int col = 0; col < values.Count; col++) {
     
    5771    }
    5872
    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);
    7081      }
    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      }
    7298    }
    7399  }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj

    r8841 r8877  
    115115    <Compile Include="Classification\ArtificialClassificationDataDescriptor.cs" />
    116116    <Compile Include="Classification\ArtificialClassificationInstanceProvider.cs" />
     117    <Compile Include="Classification\ClassificationImportType.cs" />
    117118    <Compile Include="Classification\ClassificationInstanceProvider.cs" />
    118119    <Compile Include="Classification\CSV\ClassifiactionCSVInstanceProvider.cs" />
     
    126127    <Compile Include="Clustering\ClusteringInstanceProvider.cs" />
    127128    <Compile Include="Clustering\CSV\ClusteringCSVInstanceProvider.cs" />
     129    <Compile Include="DataAnalysisCSVFormat.cs" />
    128130    <Compile Include="DataAnalysisImportType.cs" />
    129131    <Compile Include="DataAnalysisInstanceProvider.cs" />
     
    179181    <Compile Include="Regression\Nguyen\NguyenInstanceProvider.cs" />
    180182    <Compile Include="Regression\RealWorld\RegressionRealWorldInstanceProvider.cs" />
     183    <Compile Include="Regression\RegressionImportType.cs" />
    181184    <Compile Include="Regression\RegressionInstanceProvider.cs" />
    182185    <Compile Include="Regression\ResourceRegressionDataDescriptor.cs" />
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs

    r8685 r8877  
    2323using System.Collections;
    2424using System.Collections.Generic;
    25 using System.Globalization;
    2625using System.IO;
    2726using System.Linq;
    28 using System.Text;
    2927using HeuristicLab.Common;
    3028using HeuristicLab.Problems.DataAnalysis;
     
    6765      var allowedInputVars = new List<string>();
    6866      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)));
    7375      }
    7476
     
    8688    }
    8789
    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) {
    9291      List<IList> values = csvFileParser.Values;
    9392      if (type.Shuffle) {
     
    9594      }
    9695      Dataset dataset = new Dataset(csvFileParser.VariableNames, values);
    97       string targetVar = dataset.DoubleVariables.Last();
    9896
    9997      // turn of input variables that are constant in the training partition
     
    105103        foreach (var variableName in dataset.DoubleVariables) {
    106104          if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 &&
    107             variableName != targetVar)
     105            variableName != type.TargetVariable)
    108106            allowedInputVars.Add(variableName);
    109107        }
    110108      } else {
    111         allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => x.Equals(targetVar)));
     109        allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(type.TargetVariable)));
    112110      }
    113111
    114       RegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, targetVar);
     112      RegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, type.TargetVariable);
    115113
    116114      regressionData.TrainingPartition.Start = 0;
     
    123121      return regressionData;
    124122    }
    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     }
    152123  }
    153124}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs

    r8598 r8877  
    2323
    2424namespace HeuristicLab.Problems.Instances.DataAnalysis {
    25   public abstract class RegressionInstanceProvider : DataAnalysisInstanceProvider<IRegressionProblemData> {
     25  public abstract class RegressionInstanceProvider : DataAnalysisInstanceProvider<IRegressionProblemData, RegressionImportType> {
    2626  }
    2727}
Note: See TracChangeset for help on using the changeset viewer.