Author: bugman Date: Mon May 7 23:20:00 2012 New Revision: 16081 URL: http://svn.gna.org/viewcvs/relax?rev=16081&view=rev Log: Converted the model_selection user function to the auto-generation design. Added: branches/uf_redesign/user_functions/model_selection.py - copied, changed from r16068, branches/uf_redesign/prompt/model_selection.py Removed: branches/uf_redesign/prompt/model_selection.py Modified: branches/uf_redesign/prompt/__init__.py branches/uf_redesign/prompt/interpreter.py branches/uf_redesign/user_functions/__init__.py Modified: branches/uf_redesign/prompt/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/__init__.py?rev=16081&r1=16080&r2=16081&view=diff ============================================================================== --- branches/uf_redesign/prompt/__init__.py (original) +++ branches/uf_redesign/prompt/__init__.py Mon May 7 23:20:00 2012 @@ -36,7 +36,6 @@ 'interpreter', 'jw_mapping', 'model_free', - 'model_selection', 'molecule', 'molmol', 'monte_carlo', Modified: branches/uf_redesign/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/interpreter.py?rev=16081&r1=16080&r2=16081&view=diff ============================================================================== --- branches/uf_redesign/prompt/interpreter.py (original) +++ branches/uf_redesign/prompt/interpreter.py Mon May 7 23:20:00 2012 @@ -60,7 +60,6 @@ from fix import Fix from gpl import GPL from reset import Reset -from model_selection import Modsel from sys_info import Sys_info from temperature import Temp @@ -200,7 +199,6 @@ eliminate = Eliminate() fix = Fix() reset = Reset() - modsel = Modsel() opendx = OpenDX() sys_info = Sys_info() temp = Temp() @@ -209,7 +207,6 @@ objects['eliminate'] = eliminate.eliminate objects['fix'] = fix.fix objects['reset'] = reset.reset - objects['model_selection'] = modsel.model_selection objects['sys_info'] = sys_info.sys_info objects['temperature'] = temp.set Removed: branches/uf_redesign/prompt/model_selection.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/model_selection.py?rev=16080&view=auto ============================================================================== --- branches/uf_redesign/prompt/model_selection.py (original) +++ branches/uf_redesign/prompt/model_selection.py (removed) @@ -1,109 +1,0 @@ -############################################################################### -# # -# Copyright (C) 2003-2012 Edward d'Auvergne # -# # -# This file is part of the program relax. # -# # -# relax 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 2 of the License, or # -# (at your option) any later version. # -# # -# relax 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 relax; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -############################################################################### - -# Module docstring. -"""Module containing the 'model_selection' user function class.""" -__docformat__ = 'plaintext' - -# relax module imports. -import arg_check -from generic_fns import model_selection -from status import Status; status = Status() - - -class Modsel: - """Class containing the function for selecting which model selection method should be used.""" - - def model_selection(self, method=None, modsel_pipe=None, pipes=None): - """Function for model selection. - - Keyword arguments - ~~~~~~~~~~~~~~~~~ - - method: The model selection technique (see below). - - modsel_pipe: The name of the new data pipe which will be created by this user function by - the copying of the selected data pipe. - - pipes: An array containing the names of all data pipes to include in model selection. - - - Description - ~~~~~~~~~~~ - - The following model selection methods are supported: - - AIC: Akaike's Information Criteria. - - AICc: Small sample size corrected AIC. - - BIC: Bayesian or Schwarz Information Criteria. - - Bootstrap: Bootstrap model selection. - - CV: Single-item-out cross-validation. - - Expect: The expected overall discrepancy (the true values of the parameters are - required). - - Farrow: Old model-free method by Farrow et al., 1994. - - Palmer: Old model-free method by Mandel et al., 1995. - - Overall: The realised overall discrepancy (the true values of the parameters are - required). - - For the methods 'Bootstrap', 'Expect', and 'Overall', the function 'monte_carlo' should have - previously been executed with the type argument set to the appropriate value to modify its - behaviour. - - If the pipes argument is not supplied then all data pipes will be used for model selection. - - - Example - ~~~~~~~ - - For model-free analysis, if the preset models 1 to 5 are minimised and loaded into the - program, the following commands will carry out AIC model selection and to place the selected - results into the 'mixed' data pipe, type one of: - - relax> model_selection('AIC', 'mixed') - relax> model_selection(method='AIC', modsel_pipe='mixed') - relax> model_selection('AIC', 'mixed', ['m1', 'm2', 'm3', 'm4', 'm5']) - relax> model_selection(method='AIC', modsel_pipe='mixed', pipes=['m1', 'm2', 'm3', 'm4', 'm5']) - """ - - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "model_selection(" - text = text + "method=" + repr(method) - text = text + ", modsel_pipe=" + repr(modsel_pipe) - text = text + ", pipes=" + repr(pipes) + ")" - print(text) - - # The argument checks. - arg_check.is_str(method, 'model selection method') - arg_check.is_str(modsel_pipe, 'model selection data pipe name') - arg_check.is_str_list(pipes, 'data pipes', can_be_none=True, list_of_lists=True) - - # Execute the functional code. - model_selection.select(method=method, modsel_pipe=modsel_pipe, pipes=pipes) Modified: branches/uf_redesign/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/__init__.py?rev=16081&r1=16080&r2=16081&view=diff ============================================================================== --- branches/uf_redesign/user_functions/__init__.py (original) +++ branches/uf_redesign/user_functions/__init__.py Mon May 7 23:20:00 2012 @@ -42,6 +42,7 @@ 'dasha', 'diffusion_tensor', 'minimisation', + 'model_selection', 'palmer', 'pipe', 'relax_data', @@ -57,6 +58,7 @@ import user_functions.dasha import user_functions.diffusion_tensor import user_functions.minimisation +import user_functions.model_selection import user_functions.palmer import user_functions.pipe import user_functions.relax_data Copied: branches/uf_redesign/user_functions/model_selection.py (from r16068, branches/uf_redesign/prompt/model_selection.py) URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/model_selection.py?p2=branches/uf_redesign/user_functions/model_selection.py&p1=branches/uf_redesign/prompt/model_selection.py&r1=16068&r2=16081&rev=16081&view=diff ============================================================================== --- branches/uf_redesign/prompt/model_selection.py (original) +++ branches/uf_redesign/user_functions/model_selection.py Mon May 7 23:20:00 2012 @@ -21,89 +21,94 @@ ############################################################################### # Module docstring. -"""Module containing the 'model_selection' user function class.""" -__docformat__ = 'plaintext' +"""Module containing the 'model_selection' user function data.""" # relax module imports. -import arg_check -from generic_fns import model_selection -from status import Status; status = Status() +from generic_fns import model_selection, pipes +from graphics import WIZARD_IMAGE_PATH +from user_functions.data import Uf_info; uf_info = Uf_info() -class Modsel: - """Class containing the function for selecting which model selection method should be used.""" +# The model_selection user function. +uf = uf_info.add_uf('model_selection') +uf.title = "Select the best model from a set of optimised models." +uf.title_short = "Model selection." +uf.display = True +uf.add_keyarg( + name = "method", + py_type = "str", + desc_short = "model selection method", + desc = "The model selection technique (see below).", + wiz_element_type = 'combo', + wiz_combo_choices = [ + "Akaike's Information Criteria", + "Small sample size corrected AIC", + "Bayesian or Schwarz Information Criteria", + "Bootstrap model selection", + "Single-item-out cross-validation", + "Expected overall discrepancy", + "Farrow et al., 1994", + "Mandel et al., 1995", + "Realised overall discrepancy" + ], + wiz_combo_data = [ + "AIC", + "AICc", + "BIC", + "Bootstrap", + "CV", + "Expect", + "Farrow", + "Palmer", + "Overall" + ], + wiz_read_only = True +) +uf.add_keyarg( + name = "modsel_pipe", + py_type = "str", + desc_short = "model selection data pipe name", + desc = "The name of the new data pipe which will be created by this user function by the copying of the selected data pipe." +) +uf.add_keyarg( + name = "pipes", + py_type = "str_list_of_lists", + desc_short = "data pipes", + desc = "An array containing the names of all data pipes to include in model selection.", + wiz_element_type = 'combo_list', + wiz_combo_iter = pipes.pipe_names, + wiz_read_only = True, + can_be_none = True +) +uf.desc = """ +The following model selection methods are supported: - def model_selection(self, method=None, modsel_pipe=None, pipes=None): - """Function for model selection. + AIC: Akaike's Information Criteria. + AICc: Small sample size corrected AIC. + BIC: Bayesian or Schwarz Information Criteria. + Bootstrap: Bootstrap model selection. + CV: Single-item-out cross-validation. + Expect: The expected overall discrepancy (the true values of the parameters are required). + Farrow: Old model-free method by Farrow et al., 1994. + Palmer: Old model-free method by Mandel et al., 1995. + Overall: The realised overall discrepancy (the true values of the parameters are required). - Keyword arguments - ~~~~~~~~~~~~~~~~~ +For the methods 'Bootstrap', 'Expect', and 'Overall', the function 'monte_carlo' should have previously been executed with the type argument set to the appropriate value to modify its behaviour. - method: The model selection technique (see below). +If the pipes argument is not supplied then all data pipes will be used for model selection. +""" +uf.prompt_examples = """ +For model-free analysis, if the preset models 1 to 5 are minimised and loaded into the +program, the following commands will carry out AIC model selection and to place the selected +results into the 'mixed' data pipe, type one of: - modsel_pipe: The name of the new data pipe which will be created by this user function by - the copying of the selected data pipe. - - pipes: An array containing the names of all data pipes to include in model selection. - - - Description - ~~~~~~~~~~~ - - The following model selection methods are supported: - - AIC: Akaike's Information Criteria. - - AICc: Small sample size corrected AIC. - - BIC: Bayesian or Schwarz Information Criteria. - - Bootstrap: Bootstrap model selection. - - CV: Single-item-out cross-validation. - - Expect: The expected overall discrepancy (the true values of the parameters are - required). - - Farrow: Old model-free method by Farrow et al., 1994. - - Palmer: Old model-free method by Mandel et al., 1995. - - Overall: The realised overall discrepancy (the true values of the parameters are - required). - - For the methods 'Bootstrap', 'Expect', and 'Overall', the function 'monte_carlo' should have - previously been executed with the type argument set to the appropriate value to modify its - behaviour. - - If the pipes argument is not supplied then all data pipes will be used for model selection. - - - Example - ~~~~~~~ - - For model-free analysis, if the preset models 1 to 5 are minimised and loaded into the - program, the following commands will carry out AIC model selection and to place the selected - results into the 'mixed' data pipe, type one of: - - relax> model_selection('AIC', 'mixed') - relax> model_selection(method='AIC', modsel_pipe='mixed') - relax> model_selection('AIC', 'mixed', ['m1', 'm2', 'm3', 'm4', 'm5']) - relax> model_selection(method='AIC', modsel_pipe='mixed', pipes=['m1', 'm2', 'm3', 'm4', 'm5']) - """ - - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "model_selection(" - text = text + "method=" + repr(method) - text = text + ", modsel_pipe=" + repr(modsel_pipe) - text = text + ", pipes=" + repr(pipes) + ")" - print(text) - - # The argument checks. - arg_check.is_str(method, 'model selection method') - arg_check.is_str(modsel_pipe, 'model selection data pipe name') - arg_check.is_str_list(pipes, 'data pipes', can_be_none=True, list_of_lists=True) - - # Execute the functional code. - model_selection.select(method=method, modsel_pipe=modsel_pipe, pipes=pipes) +relax> model_selection('AIC', 'mixed') +relax> model_selection(method='AIC', modsel_pipe='mixed') +relax> model_selection('AIC', 'mixed', ['m1', 'm2', 'm3', 'm4', 'm5']) +relax> model_selection(method='AIC', modsel_pipe='mixed', pipes=['m1', 'm2', 'm3', 'm4', 'm5']) +""" +uf.backend = model_selection.select +uf.menu_text = "m&odel_selection" +uf.gui_icon = "relax.discrepancy_curve" +uf.wizard_size = (800, 600) +uf.wizard_image = WIZARD_IMAGE_PATH + 'discrepancy_curve.png'