fitting
calculators
interface_factory
InterfaceFactoryTemplate
This class allows for the creation and transference of interfaces.
Source code in src/easyscience/fitting/calculators/interface_factory.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
available_interfaces
property
Return all available interfaces.
:return: List of available interface names :rtype: List[str]
create(*args, **kwargs)
Create an interface to a calculator from those initialized.
Interfaces can be selected by interface_name where
interface_name is one of obj.available_interfaces. This
interface can now be accessed by obj().
:param interface_name: name of interface to be created :type interface_name: str :return: None :rtype: noneType
Source code in src/easyscience/fitting/calculators/interface_factory.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
current_interface
property
Returns the constructor for the currently selected interface.
:return: Interface constructor :rtype: InterfaceTemplate
current_interface_name
property
Returns the constructor name for the currently selected interface.
:return: Interface constructor name :rtype: str
fit_func
property
Pass through to the underlying interfaces fitting function.
:param x_array: points to be calculated at
:type x_array: np.ndarray
:param args: positional arguments for the fitting function
:type args: Any
:param kwargs: key/value pair arguments for the fitting function.
:type kwargs: Any
:return: points calculated at positional values x
:rtype: np.ndarray
generate_bindings(model, *args, ifun=None, **kwargs)
Automatically bind a Parameter to the corresponding
interface.
:param name: parameter name :type name: str :return: binding property :rtype: property
Source code in src/easyscience/fitting/calculators/interface_factory.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
return_name(this_interface)
staticmethod
Return an interfaces name.
Source code in src/easyscience/fitting/calculators/interface_factory.py
191 192 193 194 195 196 197 | |
switch(new_interface, fitter=None)
Changes the current interface to a new interface. The current interface is destroyed and all SerializerComponent parameters carried over to the new interface. i.e. pick up where you left off.
:param new_interface: name of new interface to be created :type new_interface: str :param fitter: Fitting interface which contains the fitting object which may have bindings which will be updated. :type fitter: EasyScience.fitting.Fitter :return: None :rtype: noneType
Source code in src/easyscience/fitting/calculators/interface_factory.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
fitter
Fitter
Fitter is a class which makes it possible to undertake fitting utilizing one of the supported minimizers.
Source code in src/easyscience/fitting/fitter.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
available_minimizers
property
Get a list of the names of available fitting minimizers.
:return: List of available fitting minimizers :rtype: List[str]
create(minimizer_enum=DEFAULT_MINIMIZER)
Create the required minimizer.
:param minimizer_enum: The enum of the minimization engine to create.
Source code in src/easyscience/fitting/fitter.py
58 59 60 61 62 63 64 65 66 67 | |
fit
property
Property which wraps the current fit function from the
fitting interface.
This property return a wrapped fit function which converts the input data into the correct shape for the optimizer, wraps the fit function to re-constitute the independent variables and once the fit is completed, reshape the inputs to those expected.
fit_function
property
writable
The raw fit function that the optimizer will call (no wrapping) :return: Raw fit function.
fit_object
property
writable
The EasyScience object which will be used as a model :return:
EasyScience Model.
initialize(fit_object, fit_function)
Set the model and callable in the calculator interface.
:param fit_object: The EasyScience model object :param fit_function: The function to be optimized against.
Source code in src/easyscience/fitting/fitter.py
47 48 49 50 51 52 53 54 55 | |
max_evaluations
property
writable
Get the maximal number of evaluations for the minimizer.
:return: Maximal number of steps for the minimizer
minimizer
property
Get the current fitting minimizer object.
:return: :rtype: MinimizerBase
switch_minimizer(minimizer_enum)
Switch minimizer and initialize.
:param minimizer_enum: The enum of the minimizer to create and instantiate.
Source code in src/easyscience/fitting/fitter.py
69 70 71 72 73 74 75 76 77 78 79 | |
tolerance
property
writable
Get the tolerance for the minimizer.
:return: Tolerance for the minimizer
minimizers
bumps_utils
BumpsProgressMonitor
Bases: Monitor
BUMPS :class:Monitor that forwards per-step progress
information to a user-supplied callback.
The monitor delegates payload construction to payload_builder so
the BUMPS minimizer can keep all backend-specific payload semantics
in one place.
Source code in src/easyscience/fitting/minimizers/bumps_utils/progress_monitor.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
EvalCounter
Wrap a callable so the number of invocations is recorded on
count.
Used by the BUMPS minimizer to count objective-function evaluations
for cross-backend consistency with LMFit (nfev) and DFO-LS
(nf).
Source code in src/easyscience/fitting/minimizers/bumps_utils/eval_counter.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
eval_counter
EvalCounter
Wrap a callable so the number of invocations is recorded on
count.
Used by the BUMPS minimizer to count objective-function evaluations
for cross-backend consistency with LMFit (nfev) and DFO-LS
(nf).
Source code in src/easyscience/fitting/minimizers/bumps_utils/eval_counter.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
progress_monitor
BumpsProgressMonitor
Bases: Monitor
BUMPS :class:Monitor that forwards per-step progress
information to a user-supplied callback.
The monitor delegates payload construction to payload_builder so
the BUMPS minimizer can keep all backend-specific payload semantics
in one place.
Source code in src/easyscience/fitting/minimizers/bumps_utils/progress_monitor.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
minimizer_base
MinimizerBase
This template class is the basis for all minimizer engines in
EasyScience.
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
all_methods()
abstractmethod
staticmethod
Return a list of all available methods for the minimizer.
:return: List of all available methods :rtype: List[str]
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
156 157 158 159 160 161 162 163 | |
convert_to_par_object(obj)
abstractmethod
staticmethod
Convert an EasyScience.variable.Parameter object to an
engine Parameter object.
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
165 166 167 168 169 170 | |
convert_to_pars_obj(par_list=None)
abstractmethod
Create an engine compatible container with the Parameters
converted from the base object.
:param par_list: If only a single/selection of parameter is required. Specify as a list :type par_list: List[str] :return: engine Parameters compatible object
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
136 137 138 139 140 141 142 143 144 145 | |
evaluate(x, minimizer_parameters=None, **kwargs)
Evaluate the fit function for values of x. Parameters used are either the latest or user supplied. If the parameters are user supplied, it must be in a dictionary of {'parameter_name': parameter_value,...}.
:param x: x values for which the fit function will be evaluated :type x: np.ndarray :param minimizer_parameters: Dictionary of parameters which will be used in the fit function. They must be in a dictionary of {'parameter_name': parameter_value,...} :type minimizer_parameters: dict :param kwargs: additional arguments :return: y values calculated at points x for a set of parameters. :rtype: np.ndarray
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
fit(x, y, weights, model=None, parameters=None, method=None, tolerance=None, max_evaluations=None, progress_callback=None, **kwargs)
abstractmethod
Perform a fit using the engine.
:param x: points to be calculated at :type x: np.ndarray :param y: measured points :type y: np.ndarray :param weights: Weights for supplied measured points :type weights: np.ndarray :param model: Optional Model which is being fitted to :param parameters: Optional parameters for the fit :param method: method for the minimizer to use. :type method: str :param kwargs: Additional arguments for the fitting function. :return: Fit results
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
supported_methods()
abstractmethod
staticmethod
Return a list of supported methods for the minimizer.
:return: List of supported methods :rtype: List[str]
Source code in src/easyscience/fitting/minimizers/minimizer_base.py
147 148 149 150 151 152 153 154 | |
minimizer_bumps
Bumps
Bases: MinimizerBase
This is a wrapper to Bumps: https://bumps.readthedocs.io/
It allows for the Bumps fitting engine to use parameters declared in an EasyScience.base_classes.ObjBase.
Source code in src/easyscience/fitting/minimizers/minimizer_bumps.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
__init__(obj, fit_function, minimizer_enum=None)
Initialize the fitting engine with a ObjBase and an
arbitrary fitting function.
:param obj: Object containing elements of the Parameter class
:type obj: ObjBase
:param fit_function: function that when called returns y values. 'x' must be the first
and only positional argument. Additional values can be supplied by
keyword/value pairs
:type fit_function: Callable
Source code in src/easyscience/fitting/minimizers/minimizer_bumps.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
convert_to_par_object(obj)
staticmethod
Convert an EasyScience.variable.Parameter object to a bumps
Parameter object.
:return: bumps Parameter compatible object. :rtype: BumpsParameter
Source code in src/easyscience/fitting/minimizers/minimizer_bumps.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
convert_to_pars_obj(par_list=None)
Create a container with the Parameters converted from the
base object.
:param par_list: If only a single/selection of parameter is required. Specify as a list :type par_list: List[str] :return: bumps Parameters list :rtype: List[BumpsParameter]
Source code in src/easyscience/fitting/minimizers/minimizer_bumps.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
fit(x, y, weights, model=None, parameters=None, method=None, tolerance=None, max_evaluations=None, progress_callback=None, minimizer_kwargs=None, engine_kwargs=None, **kwargs)
Perform a fit using the BUMPS engine.
:param x: points to be calculated at
:type x: np.ndarray
:param y: measured points
:type y: np.ndarray
:param weights: Weights for supplied measured points
:type weights: np.ndarray
:param model: Optional Model which is being fitted to
:param parameters: Optional parameters for the fit
:type parameters: List[BumpsParameter]
:param method: Method for minimization
:type method: str
:param max_evaluations: Maximum number of optimizer steps. Forwarded to BUMPS as
its steps parameter. If None, the default value defined by the
selected BUMPS fitter (fitclass.settings) is used.
:type max_evaluations: int | None
:param progress_callback: Optional callback for progress updates. The payload
field iteration carries the BUMPS optimizer step index.
:type progress_callback: Callable
.. note::
The :class:FitResults field n_evaluations reports the number of
objective-function evaluations consumed by the fit, for cross-backend
consistency with LMFit (nfev) and DFO-LS (nf). For BUMPS this is
distinct from the optimizer step count that max_evaluations (i.e.
BUMPS steps) is budgeted against and returned as
:class:FitResults.iterations; a single step may trigger several objective
evaluations, so n_evaluations can legitimately exceed
max_evaluations. The budget-exhaustion check is performed against
iterations, not n_evaluations.
:return: Fit results :rtype: FitResults
Source code in src/easyscience/fitting/minimizers/minimizer_bumps.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
minimizer_dfo
DFO
Bases: MinimizerBase
This is a wrapper to Derivative Free Optimisation for Least Square: https://numericalalgorithmsgroup.github.io/dfols/
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
__init__(obj, fit_function, minimizer_enum=None)
Initialize the fitting engine with a ObjBase and an
arbitrary fitting function.
:param obj: Object containing elements of the Parameter class
:type obj: ObjBase
:param fit_function: function that when called returns y values. 'x' must be the first
and only positional argument. Additional values can be supplied by
keyword/value pairs
:type fit_function: Callable
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
convert_to_par_object(obj)
staticmethod
Required by interface but not needed for DFO-LS.
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
170 171 172 173 | |
convert_to_pars_obj(par_list=None)
Required by interface but not needed for DFO-LS.
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
166 167 168 | |
fit(x, y, weights, model=None, parameters=None, method=None, tolerance=None, max_evaluations=None, progress_callback=None, callback=None, **kwargs)
Perform a fit using the DFO-ls engine.
:param x: points to be calculated at :type x: np.ndarray :param y: measured points :type y: np.ndarray :param weights: Weights for supplied measured points. :type weights: np.ndarray :param model: Optional Model which is being fitted to :type model: lmModel :param parameters: Optional parameters for the fit :type parameters: List[bumpsParameter] :param kwargs: Additional arguments for the fitting function. :param method: Method for minimization :type method: str :return: Fit results :rtype: ModelResult For standard least squares, the weights should be 1/sigma, where sigma is the standard deviation of the measurement. For unweighted least squares, these should be 1.
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
DFOCallbackState
dataclass
Snapshot of a DFO objective evaluation.
Source code in src/easyscience/fitting/minimizers/minimizer_dfo.py
24 25 26 27 28 29 30 31 32 33 34 35 36 | |
minimizer_lmfit
LMFit
Bases: MinimizerBase
This is a wrapper to the extended Levenberg-Marquardt Fit: https://lmfit.github.io/lmfit-py/
It allows for the lmfit fitting engine to use parameters declared in an EasyScience.base_classes.ObjBase.
Source code in src/easyscience/fitting/minimizers/minimizer_lmfit.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
__init__(obj, fit_function, minimizer_enum=None)
Initialize the minimizer with the ObjBase and the
fit_function to be used.
:param obj: Base object which contains the parameters to be fitted :type obj: ObjBase :param fit_function: Function which will be fitted to the data :type fit_function: Callable :param method: Method to be used by the minimizer :type method: str
Source code in src/easyscience/fitting/minimizers/minimizer_lmfit.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
convert_to_par_object(parameter)
staticmethod
Convert an EasyScience Parameter object to a lmfit Parameter object.
:return: lmfit Parameter compatible object. :rtype: LMParameter
Source code in src/easyscience/fitting/minimizers/minimizer_lmfit.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
convert_to_pars_obj(parameters=None)
Create an lmfit compatible container with the Parameters
converted from the base object.
:param parameters: If only a single/selection of parameter is required. Specify as a list :return: lmfit Parameters compatible object
Source code in src/easyscience/fitting/minimizers/minimizer_lmfit.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
fit(x, y, weights=None, model=None, parameters=None, method=None, tolerance=None, max_evaluations=None, progress_callback=None, minimizer_kwargs=None, engine_kwargs=None, **kwargs)
Perform a fit using the lmfit engine.
:param method: :type method: :param x: points to be calculated at :type x: np.ndarray :param y: measured points :type y: np.ndarray :param weights: Weights for supplied measured points :type weights: np.ndarray :param model: Optional Model which is being fitted to :type model: LMModel :param parameters: Optional parameters for the fit :type parameters: LMParameters :param minimizer_kwargs: Arguments to be passed directly to the minimizer :type minimizer_kwargs: dict :param kwargs: Additional arguments for the fitting function. :return: Fit results :rtype: ModelResult For standard least squares, the weights should be 1/sigma, where sigma is the standard deviation of the measurement. For unweighted least squares, these should be 1.
Source code in src/easyscience/fitting/minimizers/minimizer_lmfit.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
utils
FitResults
At the moment this is just a dummy way of unifying the returned fit parameters.
Source code in src/easyscience/fitting/minimizers/utils.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
multi_fitter
MultiFitter
Bases: Fitter
Extension of Fitter to enable multiple dataset/fit function fitting.
We can fit these types of data simultaneously: - Multiple models on multiple datasets.
The inherited fit wrapper from Fitter is used unchanged,
including support for forwarding progress callbacks to the active
minimizer.
Source code in src/easyscience/fitting/multi_fitter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |