Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Asks the user for the preferred number of factors to use for calculation and plotting and stores that number in the
        /// PLS content tag of the table.
        /// </summary>
        /// <param name="table">The table which contains the PLS model.</param>
        public static void QuestPreferredNumberOfFactors(Altaxo.Data.DataTable table)
        {
            MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

            if (plsMemo == null)
            {
                return;
            }

            QuestPreferredNumberOfFactors(plsMemo);
        }
Exemple #3
0
        public static WorksheetAnalysis GetAnalysis(DataTable table)
        {
            MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

            if (plsMemo == null)
            {
                throw new ArgumentException("Table does not contain a PLSContentMemento");
            }

            return(plsMemo.Analysis);
        }
Exemple #4
0
        /// <summary>
        /// This predicts the selected columns/rows against a user choosen calibration model.
        /// The orientation of spectra is given by the parameter <c>spectrumIsRow</c>.
        /// </summary>
        /// <param name="ctrl">The worksheet controller containing the selected data.</param>
        /// <param name="spectrumIsRow">If true, the spectra is horizontally oriented, else it is vertically oriented.</param>
        public static void PredictValues(WorksheetController ctrl, bool spectrumIsRow)
        {
            string modelName, destName;

            if (false == QuestCalibrationModelAndDestinationTable(out modelName, out destName) || null == modelName)
            {
                return; // Cancelled by user
            }
            Altaxo.Data.DataTable modelTable = Current.Project.DataTableCollection[modelName];
            Altaxo.Data.DataTable destTable  = (null == destName ? new Altaxo.Data.DataTable() : Current.Project.DataTableCollection[destName]);

            if (modelTable == null || destTable == null)
            {
                throw new ApplicationException("Unexpected: modelTable or destTable is null");
            }

            int numberOfFactors = 0;

            MultivariateContentMemento memento = modelTable.GetTableProperty("Content") as MultivariateContentMemento;

            if (memento != null)
            {
                numberOfFactors = memento.PreferredNumberOfFactors;
            }

            if (numberOfFactors == 0)
            {
                QuestPreferredNumberOfFactors(modelTable);
                memento = modelTable.GetTableProperty("Content") as MultivariateContentMemento;
                if (memento != null)
                {
                    numberOfFactors = memento.PreferredNumberOfFactors;
                }
            }

            memento.Analysis.PredictValues(
                ctrl.DataTable,
                ctrl.SelectedDataColumns,
                ctrl.SelectedDataRows,
                spectrumIsRow,
                numberOfFactors,
                modelTable,
                destTable);



            // if destTable is new, show it
            if (destTable.ParentObject == null)
            {
                Current.Project.DataTableCollection.Add(destTable);
                Current.ProjectService.OpenOrCreateWorksheetForTable(destTable);
            }
        }
Exemple #5
0
        public static void QuestPreferredNumberOfFactors(MultivariateContentMemento plsMemo)
        {
            // quest the number of factors to export
            IntegerValueInputController ivictrl = new IntegerValueInputController(1, "Please choose preferred number of factors(>0):");


            ivictrl.Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator();
            if (!Current.Gui.ShowDialog(ivictrl, "Number of factors", false))
            {
                return;
            }

            plsMemo.PreferredNumberOfFactors = ivictrl.EnteredContents;
        }
Exemple #6
0
        /// <summary>
        /// Plots the x (spectral) leverage into a graph.
        /// </summary>
        /// <param name="table">The table with the PLS model data.</param>
        public static void PlotXLeverage(Altaxo.Data.DataTable table)
        {
            MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

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

            Altaxo.Graph.GUI.IGraphController graphctrl = Current.ProjectService.CreateNewGraph();
            PlotXLeverage(table, graphctrl.Doc.Layers[0], plsMemo.PreferredNumberOfFactors);
        }
Exemple #7
0
        /// <summary>
        /// Plots the cross prediction values of all y components invidually in a  graph.
        /// </summary>
        /// <param name="table">The table with the PLS model data.</param>
        public static void PlotCrossPredictedVersusActualY(Altaxo.Data.DataTable table)
        {
            MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

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

            for (int nComponent = 0; nComponent < plsMemo.NumberOfConcentrationData; nComponent++)
            {
                Altaxo.Graph.GUI.IGraphController graphctrl = Current.ProjectService.CreateNewGraph();
                PlotCrossPredictedVersusActualY(table, graphctrl.Doc.Layers[0], nComponent, plsMemo.PreferredNumberOfFactors);
            }
        }