Example #1
0
        /// <summary>
        /// Plots all preprocessed spectra into a newly created graph.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        public static void PlotPredictionScores(Altaxo.Data.DataTable table)
        {
            MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

            if (plsMemo == null)
            {
                return;
            }
            if (plsMemo.PreferredNumberOfFactors <= 0)
            {
                QuestPreferredNumberOfFactors(plsMemo);
            }

            GetAnalysis(table).CalculateAndStorePredictionScores(table, plsMemo.PreferredNumberOfFactors);

            AscendingIntegerCollection sel = new AscendingIntegerCollection();

            for (int i = 0; i < plsMemo.NumberOfConcentrationData; i++)
            {
                string name = WorksheetAnalysis.GetPredictionScore_ColumnName(i, plsMemo.PreferredNumberOfFactors);
                if (null != table[name])
                {
                    sel.Add(table.DataColumns.GetColumnNumber(table[name]));
                }
            }

            Worksheet.Commands.PlotCommands.PlotLine(table, sel, true, false);
        }
Example #2
0
        private void WriteBasicYData(bool bWriteEndElement)
        {
            Altaxo.Data.DoubleColumn col = null;
            string colname;

            _writer.WriteStartElement("YData");

            colname = WorksheetAnalysis.GetYMean_ColumnName();
            col     = _table.DataColumns.TryGetColumn(colname) as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("YMean", col, _numberOfY);

            colname = WorksheetAnalysis.GetYScale_ColumnName();
            col     = _table.DataColumns.TryGetColumn(colname) as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("YScale", col, _numberOfY);

            if (bWriteEndElement)
            {
                _writer.WriteEndElement(); // YData
            }
        }
Example #3
0
        /// <summary>
        /// Plots the cross PRESS value into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        public static void PlotCrossPRESSValue(Altaxo.Data.DataTable table, XYPlotLayer layer)
        {
            Altaxo.Data.DataColumn ycol = table[WorksheetAnalysis.GetCrossPRESSValue_ColumnName()];
            Altaxo.Data.DataColumn xcol = table[WorksheetAnalysis.GetNumberOfFactors_ColumnName()];

            XYColumnPlotData       pa = new XYColumnPlotData(xcol, ycol);
            G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.LineAndScatter);

            layer.PlotItems.Add(new XYColumnPlotItem(pa, ps));

            layer.DefaultXAxisTitleString = "Number of factors";
            layer.DefaultYAxisTitleString = "Cross PRESS value";
        }
Example #4
0
        /// <summary>
        /// Plots the cross predicted versus actual Y (concentration) into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
        /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
        public static void PlotCrossPredictedVersusActualY(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
        {
            string ypredcolname = WorksheetAnalysis.GetYCrossPredicted_ColumnName(whichY, numberOfFactors);
            string yactcolname  = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);

            if (table[ypredcolname] == null)
            {
                GetAnalysis(table).CalculateCrossPredictedAndResidual(table, whichY, numberOfFactors, true, false, false);
            }

            PlotOnlyLabel(layer, table[yactcolname], table[ypredcolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Y original{0}", whichY);
            layer.DefaultYAxisTitleString = string.Format("Y cross predicted{0} (#factors:{1})", whichY, numberOfFactors);
        }
Example #5
0
        /// <summary>
        /// Plots the x (spectral) residuals into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
        /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
        public static void PlotXResiduals(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
        {
            string xresidualcolname = WorksheetAnalysis.GetXResidual_ColumnName(whichY, numberOfFactors);
            string yactcolname      = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);

            if (table[xresidualcolname] == null)
            {
                GetAnalysis(table).CalculateXResidual(table, whichY, numberOfFactors);
            }

            PlotOnlyLabel(layer, table[yactcolname], table[xresidualcolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Y original{0}", whichY);
            layer.DefaultYAxisTitleString = string.Format("X residual{0} (#factors:{1})", whichY, numberOfFactors);
        }
Example #6
0
        /// <summary>
        /// Plots the x (spectral) leverage into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="preferredNumberOfFactors">The number of factors used for leverage calculation.</param>
        public static void PlotXLeverage(Altaxo.Data.DataTable table, XYPlotLayer layer, int preferredNumberOfFactors)
        {
            string xcolname = WorksheetAnalysis.GetMeasurementLabel_ColumnName();
            string ycolname = WorksheetAnalysis.GetXLeverage_ColumnName(preferredNumberOfFactors);

            if (table[ycolname] == null)
            {
                GetAnalysis(table).CalculateXLeverage(table, preferredNumberOfFactors);
            }

            PlotOnlyLabel(layer, table[xcolname], table[ycolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Measurement");
            layer.DefaultYAxisTitleString = string.Format("Score leverage (#factors:{0})", preferredNumberOfFactors);
        }
Example #7
0
        public static void PLSOnColumns(WorksheetController ctrl)
        {
            MultivariateAnalysisOptions  options;
            SpectralPreprocessingOptions preprocessOptions;

            if (!QuestPLSAnalysisOptions(out options, out preprocessOptions))
            {
                return;
            }

            WorksheetAnalysis analysis = (WorksheetAnalysis)System.Activator.CreateInstance(options.AnalysisMethod);

            string err = analysis.ExecuteAnalysis(Current.Project, ctrl.Doc, ctrl.SelectedDataColumns, ctrl.SelectedDataRows, ctrl.SelectedPropertyColumns, false, options, preprocessOptions);

            if (null != err)
            {
                System.Windows.Forms.MessageBox.Show(ctrl.View.TableViewForm, err, "An error occured");
            }
        }
        void WriteBasicXData(bool bWriteEndElement)
        {
            Altaxo.Data.DoubleColumn col = null;
            string colname;

            _writer.WriteStartElement("XData");

            colname = WorksheetAnalysis.GetXOfX_ColumnName();
            col     = _table.DataColumns[colname] as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("XOfX", col, _numberOfX);

            colname = WorksheetAnalysis.GetXMean_ColumnName();
            col     = _table.DataColumns[colname] as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("XMean", col, _numberOfX);

            colname = WorksheetAnalysis.GetXScale_ColumnName();
            col     = _table.DataColumns[colname] as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("XScale", col, _numberOfX);

            if (bWriteEndElement)
            {
                _writer.WriteEndElement(); // XData
            }
        }