#region License Information /* HeuristicLab * Copyright (C) 2002-2010 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 . */ #endregion using System; using System.Windows.Forms; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; using HeuristicLab.PluginInfrastructure; using HeuristicLab.MainForm.WindowsForms; using System.Collections.Generic; using System.Linq; using System.Text; namespace HeuristicLab.Problems.DataAnalysis.Views { [View("Data-Analysis Problem Correlations View")] [Content(typeof(DataAnalysisProblemData))] public partial class DataAnalysisProblemDataCorrelationsView : AsynchronousContentView { private OpenFileDialog openFileDialog; public new DataAnalysisProblemData Content { get { return (DataAnalysisProblemData)base.Content; } set { base.Content = value; } } public DataAnalysisProblemDataCorrelationsView() { InitializeComponent(); } protected override void OnContentChanged() { base.OnContentChanged(); if (Content != null) { StringBuilder s = new StringBuilder(); Dataset ds = Content.Dataset; for (int i = 0; i < ds.Columns - 1; i++) { for (int j = i + 1; j < ds.Columns; j++) { string a = ds.GetVariableName(i); string b = ds.GetVariableName(j); double[] var0 = ds.GetEnumeratedVariableValues(a).ToArray(); double[] var1 = ds.GetEnumeratedVariableValues(b).ToArray(); double r = alglib.spearmancorr2(var0, var1, var0.Length); double bothtails, temp; bothtails = temp = 0.0; alglib.correlationtests.spearmanrankcorrelationsignificance(r, var0.Length, ref bothtails, ref temp, ref temp); if (bothtails < 0.001 && r > 0.85) s.AppendLine(a + " -- " + b + " [len=\"" + 1.0 / (r * r) + "\"];"); } } textBox.Text = s.ToString(); } } } }