Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5853


Ignore:
Timestamp:
03/29/11 00:39:18 (14 years ago)
Author:
mkommend
Message:

#1455: Implemented first draft of ClusteringSolutionView.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
1 added
1 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionEstimatedClusterView.cs

    r5851 r5853  
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Views {
    31   [View("ClassificationSolution EstimatedClassValues")]
    32   [Content(typeof(IClassificationSolution))]
    33   public partial class ClassificationSolutionEstimatedClassValuesView : ItemView, IClassificationSolutionEvaluationView {
    34     private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
    35     private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedClassValues";
     31  [View("ClusteringSolution EstimatedCluster")]
     32  [Content(typeof(IClusteringSolution))]
     33  public partial class ClusteringSolutionEstimatedClusterView : ItemView, IClusteringSolutionEvaluationView {
     34    private const string CLUSTER_NAMES = "Cluster";
    3635
    37     public new IClassificationSolution Content {
    38       get { return (IClassificationSolution)base.Content; }
     36    public new IClusteringSolution Content {
     37      get { return (IClusteringSolution)base.Content; }
    3938      set {
    4039        base.Content = value;
     
    4443    private StringConvertibleMatrixView matrixView;
    4544
    46     public ClassificationSolutionEstimatedClassValuesView()
     45    public ClusteringSolutionEstimatedClusterView()
    4746      : base() {
    4847      InitializeComponent();
     
    7776    protected override void OnContentChanged() {
    7877      base.OnContentChanged();
    79       UpdateEstimatedValues();
     78      UpdateClusterValues();
    8079    }
    8180
    82     private void UpdateEstimatedValues() {
    83       if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
     81    private void UpdateClusterValues() {
     82      if (InvokeRequired) Invoke((Action)UpdateClusterValues);
    8483      else {
    8584        DoubleMatrix matrix = null;
    8685        if (Content != null) {
    87           double[,] values = new double[Content.ProblemData.Dataset.Rows, 2];
     86          int[] clusters = Content.Model.GetClusterValues(Content.ProblemData.Dataset, Enumerable.Range(0, Content.ProblemData.Dataset.Rows)).ToArray();
     87          var dataset = Content.ProblemData.Dataset;
     88          int columns = Content.ProblemData.AllowedInputVariables.Count() + 1;
     89          var columnsIndixes = Content.ProblemData.AllowedInputVariables.Select(x => dataset.GetVariableIndex(x)).ToList();
    8890
    89           double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
    90           double[] estimated = Content.EstimatedClassValues.ToArray();
    91           for (int row = 0; row < target.Length; row++) {
    92             values[row, 0] = target[row];
    93             values[row, 1] = estimated[row];
     91          double[,] values = new double[dataset.Rows, columns];
     92          for (int row = 0; row < dataset.Rows; row++) {
     93            values[row, 0] = clusters[row];
     94
     95            int column = 1;
     96            foreach (int columnIndex in columnsIndixes) {
     97              values[row, column] = dataset[row, columnIndex];
     98              column++;
     99            }
    94100          }
    95101
    96102          matrix = new DoubleMatrix(values);
    97           matrix.ColumnNames = new string[] { TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME };
     103          var columnNames = dataset.VariableNames.ToList();
     104          columnNames.Insert(0, CLUSTER_NAMES);
     105          matrix.ColumnNames = columnNames;
    98106        }
    99107        matrixView.Content = matrix;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ClusteringSolutionView.Designer.cs

    r5851 r5853  
    2121
    2222namespace HeuristicLab.Problems.DataAnalysis.Views {
    23   partial class RegressionSolutionView {
     23  partial class ClusteringSolutionView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ClusteringSolutionView.cs

    r5851 r5853  
    2727namespace HeuristicLab.Problems.DataAnalysis.Views {
    2828  [View("RegressionSolution View")]
    29   [Content(typeof(RegressionSolution), true)]
    30   public partial class RegressionSolutionView : DataAnalysisSolutionView {
    31     public RegressionSolutionView() {
     29  [Content(typeof(ClusteringSolution), true)]
     30  public partial class ClusteringSolutionView : DataAnalysisSolutionView {
     31    public ClusteringSolutionView() {
    3232      InitializeComponent();
    3333
    34       var regressionSolutionEvaluationViewTypes = ApplicationManager.Manager.GetTypes(typeof(IRegressionSolutionEvaluationView), true);
    35       foreach (Type viewType in regressionSolutionEvaluationViewTypes)
     34      var clusteringSolutionEvaluationViewTypes = ApplicationManager.Manager.GetTypes(typeof(IClusteringSolutionEvaluationView), true);
     35      foreach (Type viewType in clusteringSolutionEvaluationViewTypes)
    3636        AddViewListViewItem(viewType);
    3737    }
    3838
    39     public new RegressionSolution Content {
    40       get { return (RegressionSolution)base.Content; }
     39    public new ClusteringSolution Content {
     40      get { return (ClusteringSolution)base.Content; }
    4141      set { base.Content = value; }
    4242    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r5829 r5853  
    146146      <DependentUpon>DiscriminantFunctionClassificationSolutionThresholdView.cs</DependentUpon>
    147147    </Compile>
     148    <Compile Include="Clustering\ClusteringSolutionEstimatedClusterView.cs">
     149      <SubType>UserControl</SubType>
     150    </Compile>
     151    <Compile Include="Clustering\ClusteringSolutionEstimatedClusterView.Designer.cs">
     152      <DependentUpon>ClusteringSolutionEstimatedClusterView.cs</DependentUpon>
     153    </Compile>
     154    <Compile Include="ClusteringSolutionView.cs">
     155      <SubType>UserControl</SubType>
     156    </Compile>
     157    <Compile Include="ClusteringSolutionView.Designer.cs">
     158      <DependentUpon>ClusteringSolutionView.cs</DependentUpon>
     159    </Compile>
    148160    <Compile Include="DiscriminantFunctionClassificationSolutionView.cs">
    149161      <SubType>UserControl</SubType>
     
    296308    </BootstrapperPackage>
    297309  </ItemGroup>
    298   <ItemGroup>
    299     <Folder Include="Clustering\" />
    300   </ItemGroup>
     310  <ItemGroup />
    301311  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    302312  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset for help on using the changeset viewer.