Package prompt :: Module model_selection
[hide private]
[frames] | no frames]

Source Code for Module prompt.model_selection

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004, 2008-2010 Edward d'Auvergne                       # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing the 'model_selection' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import Basic_class 
 29  import arg_check 
 30  from generic_fns import model_selection 
 31   
 32   
33 -class Modsel(Basic_class):
34 """Class containing the function for selecting which model selection method should be used.""" 35
36 - def model_selection(self, method=None, modsel_pipe=None, pipes=None):
37 """Function for model selection. 38 39 Keyword arguments 40 ~~~~~~~~~~~~~~~~~ 41 42 method: The model selection technique (see below). 43 44 modsel_pipe: The name of the new data pipe which will be created by this user function by 45 the copying of the selected data pipe. 46 47 pipes: An array containing the names of all data pipes to include in model selection. 48 49 50 Description 51 ~~~~~~~~~~~ 52 53 The following model selection methods are supported: 54 55 AIC: Akaike's Information Criteria. 56 57 AICc: Small sample size corrected AIC. 58 59 BIC: Bayesian or Schwarz Information Criteria. 60 61 Bootstrap: Bootstrap model selection. 62 63 CV: Single-item-out cross-validation. 64 65 Expect: The expected overall discrepancy (the true values of the parameters are 66 required). 67 68 Farrow: Old model-free method by Farrow et al., 1994. 69 70 Palmer: Old model-free method by Mandel et al., 1995. 71 72 Overall: The realised overall discrepancy (the true values of the parameters are 73 required). 74 75 For the methods 'Bootstrap', 'Expect', and 'Overall', the function 'monte_carlo' should have 76 previously been executed with the type argument set to the appropriate value to modify its 77 behaviour. 78 79 If the pipes argument is not supplied then all data pipes will be used for model selection. 80 81 82 Example 83 ~~~~~~~ 84 85 For model-free analysis, if the preset models 1 to 5 are minimised and loaded into the 86 program, the following commands will carry out AIC model selection and to place the selected 87 results into the 'mixed' data pipe, type one of: 88 89 relax> model_selection('AIC', 'mixed') 90 relax> model_selection(method='AIC', modsel_pipe='mixed') 91 relax> model_selection('AIC', 'mixed', ['m1', 'm2', 'm3', 'm4', 'm5']) 92 relax> model_selection(method='AIC', modsel_pipe='mixed', pipes=['m1', 'm2', 'm3', 'm4', 'm5']) 93 """ 94 95 # Function intro text. 96 if self._exec_info.intro: 97 text = self._exec_info.ps3 + "model_selection(" 98 text = text + "method=" + repr(method) 99 text = text + ", modsel_pipe=" + repr(modsel_pipe) 100 text = text + ", pipes=" + repr(pipes) + ")" 101 print(text) 102 103 # The argument checks. 104 arg_check.is_str(method, 'model selection method') 105 arg_check.is_str(modsel_pipe, 'model selection data pipe name') 106 arg_check.is_str_list(pipes, 'data pipes', can_be_none=True, list_of_lists=True) 107 108 # Execute the functional code. 109 model_selection.select(method=method, modsel_pipe=modsel_pipe, pipes=pipes)
110