public KPCAResult(DataTable inputData, double[,] inputDataDeviationScores, double[,] inputDataStandardScores, string[] columnNames, AnalysisMethod method, DescriptiveMeasureCollection measures, double[,] scatterPlotValues, double[,] componentMatrix, PrincipalComponentCollection principalComponents) { this.inputData = inputData; this.inputDataDeviationScores = inputDataDeviationScores; this.inputDataStandardScores = inputDataStandardScores; this.columnNames = columnNames; this.method = method; this.measures = measures; this.scatterPlotValues = scatterPlotValues; this.componentMatrix = componentMatrix; this.principalComponents = principalComponents; }
public VisualizationForm(PrincipalComponentCollection componentsToVisualize, bool cumulative, String windowTitle) { InitializeComponent(); this.Text = windowTitle; this.StartPosition = FormStartPosition.CenterScreen; this.cumulativeView.Cumulative = cumulative; this._screenWidth = Screen.PrimaryScreen.Bounds.Width; this._screenHeight = Screen.PrimaryScreen.Bounds.Height; this.Controls.Add(this.cumulativeView); cumulativeView.DataSource = componentsToVisualize; this.Width = _screenWidth / 2; this.Height = _screenHeight / 2; }
/// <summary> /// Creates additional information about principal components. /// </summary> /// protected void CreateComponents() { int numComponents = singularValues.Length; componentProportions = new double[numComponents]; componentCumulative = new double[numComponents]; // Calculate proportions double sum = 0.0; for (int i = 0; i < eigenvalues.Length; i++) { sum += System.Math.Abs(eigenvalues[i]); } sum = (sum == 0) ? 0.0 : (1.0 / sum); for (int i = 0; i < componentProportions.Length; i++) { componentProportions[i] = System.Math.Abs(eigenvalues[i]) * sum; } // Calculate cumulative proportions this.componentCumulative[0] = this.componentProportions[0]; for (int i = 1; i < this.componentCumulative.Length; i++) { this.componentCumulative[i] = this.componentCumulative[i - 1] + this.componentProportions[i]; } // Creates the object-oriented structure to hold the principal components var components = new PrincipalComponent[singularValues.Length]; for (int i = 0; i < components.Length; i++) { components[i] = new PrincipalComponent(this, i); } this.componentCollection = new PrincipalComponentCollection(components); if (NumberOfOutputs == 0 || NumberOfOutputs > MaximumNumberOfOutputs) { NumberOfOutputs = MaximumNumberOfOutputs; } }
public static double[,] Project(PrincipalComponentCollection pcs, DataTable sampleData, double constant) { var rowPc = new double[sampleData.Rows.Count, pcs.Count]; double[] sampleEntry; double[] pc; double pcNew; for (int rowInd = 0; rowInd < sampleData.Rows.Count; rowInd++) { sampleEntry = sampleData.Rows[rowInd].ItemArray.Convert(item => (double) item); for (int pcInd = 0; pcInd < pcs.Count; pcInd++) { pc = pcs[pcInd].Eigenvector; pcNew = constant; for (int coordInd = 0; coordInd < pc.Length; coordInd++) { pcNew += sampleEntry[coordInd] * pc[coordInd]; } rowPc[rowInd, pcInd] = pcNew; } } return rowPc; }
public static double[,] Project(PrincipalComponentCollection pcs, DataTable sampleData, double constant) { var rowPc = new double[sampleData.Rows.Count, pcs.Count]; double[] sampleEntry; double[] pc; double pcNew; for (int rowInd = 0; rowInd < sampleData.Rows.Count; rowInd++) { sampleEntry = sampleData.Rows[rowInd].ItemArray.Convert(item => (double)item); for (int pcInd = 0; pcInd < pcs.Count; pcInd++) { pc = pcs[pcInd].Eigenvector; pcNew = constant; for (int coordInd = 0; coordInd < pc.Length; coordInd++) { pcNew += sampleEntry[coordInd] * pc[coordInd]; } rowPc[rowInd, pcInd] = pcNew; } } return(rowPc); }