Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.Designer.cs	(revision 8435)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.Designer.cs	(revision 8435)
@@ -0,0 +1,116 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+  partial class ClusteringSolutionVisualizationView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.splitContainer = new System.Windows.Forms.SplitContainer();
+      this.rangeComboBox = new System.Windows.Forms.ComboBox();
+      this.rangeLabel = new System.Windows.Forms.Label();
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
+      this.splitContainer.Panel1.SuspendLayout();
+      this.splitContainer.SuspendLayout();
+      this.SuspendLayout();
+      // 
+      // splitContainer
+      // 
+      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
+      this.splitContainer.IsSplitterFixed = true;
+      this.splitContainer.Location = new System.Drawing.Point(0, 0);
+      this.splitContainer.Name = "splitContainer";
+      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
+      // 
+      // splitContainer.Panel1
+      // 
+      this.splitContainer.Panel1.Controls.Add(this.rangeComboBox);
+      this.splitContainer.Panel1.Controls.Add(this.rangeLabel);
+      this.splitContainer.Size = new System.Drawing.Size(438, 198);
+      this.splitContainer.SplitterDistance = 27;
+      this.splitContainer.TabIndex = 1;
+      // 
+      // rangeComboBox
+      // 
+      this.rangeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.rangeComboBox.FormattingEnabled = true;
+      this.rangeComboBox.Items.AddRange(new object[] {
+            "Training samples",
+            "Test samples",
+            "All samples"});
+      this.rangeComboBox.Location = new System.Drawing.Point(56, 3);
+      this.rangeComboBox.Name = "rangeComboBox";
+      this.rangeComboBox.Size = new System.Drawing.Size(146, 21);
+      this.rangeComboBox.TabIndex = 1;
+      this.rangeComboBox.SelectedIndexChanged += new System.EventHandler(this.rangeComboBox_SelectedIndexChanged);
+      // 
+      // rangeLabel
+      // 
+      this.rangeLabel.AutoSize = true;
+      this.rangeLabel.Location = new System.Drawing.Point(3, 6);
+      this.rangeLabel.Name = "rangeLabel";
+      this.rangeLabel.Size = new System.Drawing.Size(47, 13);
+      this.rangeLabel.TabIndex = 0;
+      this.rangeLabel.Text = "Samples";
+      // 
+      // ClusteringSolutionVisualizationView
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.splitContainer);
+      this.Name = "ClusteringSolutionVisualizationView";
+      this.Size = new System.Drawing.Size(438, 198);
+      this.splitContainer.Panel1.ResumeLayout(false);
+      this.splitContainer.Panel1.PerformLayout();
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+      this.splitContainer.ResumeLayout(false);
+      this.ResumeLayout(false);
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.SplitContainer splitContainer;
+    private System.Windows.Forms.ComboBox rangeComboBox;
+    private System.Windows.Forms.Label rangeLabel;
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.cs	(revision 8435)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.cs	(revision 8435)
@@ -0,0 +1,133 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+  [View("Cluster Visualization")]
+  [Content(typeof(IClusteringSolution), IsDefaultView = false)]
+  public partial class ClusteringSolutionVisualizationView : DataAnalysisSolutionEvaluationView {
+    private ViewHost viewHost = new ViewHost();
+    private ScatterPlot scatterPlot = new ScatterPlot();
+
+    public new IClusteringSolution Content {
+      get { return (IClusteringSolution)base.Content; }
+      set { base.Content = value; }
+    }
+
+    public ClusteringSolutionVisualizationView() {
+      InitializeComponent();
+      viewHost.Dock = DockStyle.Fill;
+      splitContainer.Panel2.Controls.Add(viewHost);
+      rangeComboBox.SelectedIndex = 0;
+    }
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        viewHost.Content = null;
+        scatterPlot.Rows.Clear();
+      } else {
+        UpdateScatterPlot();
+        viewHost.Content = scatterPlot;
+      }
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      rangeComboBox.Enabled = Content != null;
+    }
+
+    private void UpdateScatterPlot() {
+      scatterPlot.Rows.Clear();
+
+      IEnumerable<int> range = null;
+      if (rangeComboBox.SelectedIndex == 0) range = Content.ProblemData.TrainingIndices;
+      else if (rangeComboBox.SelectedIndex == 1) range = Content.ProblemData.TestIndices;
+      else range = Enumerable.Range(0, Content.ProblemData.Dataset.Rows);
+
+      IDictionary<int, Tuple<double, string>> classes = Content.Model.GetClusterValues(Content.ProblemData.Dataset, Enumerable.Range(0, Content.ProblemData.Dataset.Rows))
+          .Select((v, i) => new { Row = i, Cluster = (double)v })
+          .ToDictionary(x => x.Row, y => Tuple.Create(y.Cluster, "Cluster " + y.Cluster));
+
+      var rows = classes.Values.Select(x => x.Item2).Distinct().ToDictionary(c => c, c => new ScatterPlotDataRow(c, string.Empty, Enumerable.Empty<Point2D<double>>()));
+
+      var reduced = PCAReduce(Content.ProblemData.Dataset, range, Content.ProblemData.AllowedInputVariables, Content.Model);
+
+      int idx = 0;
+      foreach (var r in range) {
+        rows[classes[r].Item2].Points.Add(new Point2D<double>(reduced[idx, 0], reduced[idx, 1]));
+        idx++;
+      }
+
+      scatterPlot.Rows.AddRange(rows.Values);
+    }
+
+    private static double[,] PCAReduce(Dataset dataset, IEnumerable<int> rows, IEnumerable<string> variables, IDataAnalysisModel model) {
+      var clusteringModel = model as IClusteringModel;
+      if (clusteringModel == null) return new double[0, 0];
+
+      var instances = rows.ToArray();
+      var attributes = variables.ToArray();
+      var data = new double[instances.Length, attributes.Length + 1];
+
+      for (int j = 0; j < attributes.Length; j++) {
+        int i = 0;
+        var values = dataset.GetDoubleValues(attributes[j], instances);
+        foreach (var v in values) {
+          data[i++, j] = v;
+        }
+      }
+      int info;
+      double[] variances;
+      var matrix = new double[0, 0];
+      alglib.pcabuildbasis(data, instances.Length, attributes.Length, out info, out variances, out matrix);
+
+      var result = new double[instances.Length, 2];
+      int r = 0;
+      foreach (var inst in instances) {
+        int i = 0;
+        foreach (var attrib in attributes) {
+          double val = dataset.GetDoubleValue(attrib, inst);
+          for (int j = 0; j < result.GetLength(1); j++)
+            result[r, j] += val * matrix[i, j];
+          i++;
+        }
+        r++;
+      }
+
+      return result;
+    }
+
+    #region Event Handlers
+    private void rangeComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
+      if (Content != null) UpdateScatterPlot();
+    }
+    #endregion
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj	(revision 8434)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj	(revision 8435)
@@ -93,4 +93,8 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="ALGLIB-3.6.0, Version=3.6.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <HintPath>..\..\bin\ALGLIB-3.6.0.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
@@ -122,4 +126,10 @@
       <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon>
     </Compile>
+    <Compile Include="Clustering\ClusteringSolutionVisualizationView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="Clustering\ClusteringSolutionVisualizationView.Designer.cs">
+      <DependentUpon>ClusteringSolutionVisualizationView.cs</DependentUpon>
+    </Compile>
     <Compile Include="DataAnalysisSolutionEvaluationView.cs">
       <SubType>UserControl</SubType>
@@ -263,4 +273,14 @@
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.Analysis.Views\3.3\HeuristicLab.Analysis.Views-3.3.csproj">
+      <Project>{76945D76-CA61-4147-9DC2-0ACDCDDF87F9}</Project>
+      <Name>HeuristicLab.Analysis.Views-3.3</Name>
+      <Private>False</Private>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
+      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
+      <Name>HeuristicLab.Analysis-3.3</Name>
+      <Private>False</Private>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame	(revision 8434)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame	(revision 8435)
@@ -28,4 +28,7 @@
   [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.3.$WCREV$")]
   [PluginFile("HeuristicLab.Problems.DataAnalysis.Views-3.4.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.ALGLIB", "3.6.0")]
+  [PluginDependency("HeuristicLab.Analysis", "3.3")]
+  [PluginDependency("HeuristicLab.Analysis.Views", "3.3")]
   [PluginDependency("HeuristicLab.Common", "3.3")]
   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
