Reporting
Fit-Results as Report.
PrintingResults
¶
Print the results of the fitting process.
Source code in spectrafit/report.py
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 |
|
__call__()
¶
Print the results of the fitting process.
Source code in spectrafit/report.py
334 335 336 337 338 339 |
|
__init__(args, result, minimizer)
¶
Initialize the PrintingResults class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | Dict[str, Any] | The input file arguments as a dictionary with additional information beyond the command line arguments. | required |
result | Any | The lmfit | required |
minimizer | Minimizer | The lmfit | required |
Source code in spectrafit/report.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
print_confidence_interval()
¶
Print the confidence interval.
Source code in spectrafit/report.py
377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
print_confidence_interval_verbose()
¶
Print confidence interval in verbose mode.
Source code in spectrafit/report.py
425 426 427 428 429 |
|
print_fit_results()
¶
Print the fit results.
Source code in spectrafit/report.py
370 371 372 373 374 375 |
|
print_fit_results_verbose()
¶
Print fit results in verbose mode.
Source code in spectrafit/report.py
420 421 422 423 |
|
print_input_parameters_verbose()
¶
Print input parameters in verbose mode.
Source code in spectrafit/report.py
415 416 417 418 |
|
print_linear_correlation()
¶
Print the linear correlation.
Source code in spectrafit/report.py
391 392 393 394 |
|
print_linear_correlation_verbose()
¶
Print overall linear-correlation in verbose mode.
Source code in spectrafit/report.py
431 432 433 434 |
|
print_regression_metrics()
¶
Print the regression metrics.
Source code in spectrafit/report.py
396 397 398 399 |
|
print_regression_metrics_verbose()
¶
Print regression metrics in verbose mode.
Source code in spectrafit/report.py
436 437 438 439 |
|
print_statistic()
¶
Print the statistic.
Source code in spectrafit/report.py
365 366 367 368 |
|
print_statistic_verbose()
¶
Print the data statistic in verbose mode.
Source code in spectrafit/report.py
410 411 412 413 |
|
print_tabulate(args)
staticmethod
¶
Print the results of the fitting process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | Dict[str, Any] | The args to be printed as a dictionary. | required |
Source code in spectrafit/report.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
printing_regular_mode()
¶
Print the fitting results in the regular mode.
Source code in spectrafit/report.py
357 358 359 360 361 362 363 |
|
printing_verbose_mode()
¶
Print all results in verbose mode.
Source code in spectrafit/report.py
401 402 403 404 405 406 407 408 |
|
PrintingStatus
¶
Print the status of the fitting process.
Source code in spectrafit/report.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
credits()
¶
Print the credits of the fitting process.
Source code in spectrafit/report.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
end()
¶
Print the end of the fitting process.
Source code in spectrafit/report.py
457 458 459 |
|
start()
¶
Print the start of the fitting process.
Source code in spectrafit/report.py
453 454 455 |
|
thanks()
¶
Print the end of the fitting process.
Source code in spectrafit/report.py
461 462 463 |
|
version()
¶
Print current version of the SpectraFit.
Source code in spectrafit/report.py
449 450 451 |
|
welcome()
¶
Print the welcome message.
Source code in spectrafit/report.py
445 446 447 |
|
yes_no()
¶
Print the end of the fitting process.
Source code in spectrafit/report.py
465 466 467 |
|
RegressionMetrics
¶
Calculate the regression metrics of the Fit(s) for the post analysis.
Regression Metrics for post analysis of the Fit(s)
SpectraFit
provides the following regression metrics for post analysis of the regular and global fit(s) based on the metric functions of sklearn.metrics
:
- `explained_variance_score`: Explained variance score.
- `r2_score`: the coefficient of determination
- `max_error`: Maximum error.
- `mean_absolute_error`: the mean absolute error
- `mean_squared_error`: the mean squared error
- `mean_squared_log_error`: the mean squared log error
- `median_absolute_error`: the median absolute error
- `mean_absolute_percentage_error`: the mean absolute percentage error
- `mean_poisson_deviance`: the mean Poisson deviance
- `mean_gamma_deviance`: the mean Gamma deviance
- `mean_tweedie_deviance`: the mean Tweedie deviance
- `mean_pinball_loss`: the mean Pinball loss
- `d2_tweedie_score`: the D2 Tweedie score
- `d2_pinball_score`: the D2 Pinball score
- `d2_absolute_error_score`: the D2 absolute error score
The regression fit metrics can be used to evaluate the quality of the fit by comparing the fit to the actual intensity.
D2 Tweedie and D2 Pinball scores
d2_pinball_score
and d2_absolute_error_score
are only available for sklearn
versions >= 1.1.2 and will be later implemented if the End of support (2023-06-27) is reached for the Python3.7
.
Source code in spectrafit/report.py
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 |
|
__call__()
¶
Calculate the regression metrics of the Fit(s) for the post analysis.
Returns:
Type | Description |
---|---|
Dict[Hashable, Any] | Dict[Hashable, Any]: Dictionary containing the regression metrics. |
Source code in spectrafit/report.py
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 |
|
__init__(df, name_true='intensity', name_pred='fit')
¶
Initialize the regression metrics of the Fit(s) for the post analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | DataFrame containing the input data ( | required |
name_true | str | Name of the data. Defaults to "intensity". | 'intensity' |
name_pred | str | Name of the fit data. Defaults to "fit". | 'fit' |
Source code in spectrafit/report.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
initialize(df, name_true='intensity', name_pred='fit')
¶
Initialize the regression metrics of the Fit(s) for the post analysis.
For this reason, the dataframe is split into two numpy array for true (intensity
) and predicted (fit
) intensities. In terms of global fit, the numpy array according to the order in the original dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | DataFrame containing the input data ( | required |
name_true | str | Name of the data. Defaults to "intensity". | 'intensity' |
name_pred | str | Name of the fit data. Defaults to "fit". | 'fit' |
Raises:
Type | Description |
---|---|
ValueError | In terms of global fit contains an unequal number of intial data and fit data. |
Returns:
Type | Description |
---|---|
Tuple[NDArray[np.float64], NDArray[np.float64]] | Tuple[NDArray[np.float64], NDArray[np.float64]]: Tuple of true and predicted (fit) intensities. |
Source code in spectrafit/report.py
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 |
|
fit_report_as_dict(inpars, modelpars=None)
¶
Generate the best fit report as dictionary.
About fit_report_as_dict
The report contains the best-fit values for the parameters and their uncertainties and correlations. The report is generated as dictionary and consits of the following three main criteria:
1. Fit Statistics
2. Fit variables
3. Fit correlations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inpars | minimize | Input Parameters from a fit or the Minimizer results returned from a fit. | required |
modelpars | Dict[str, Any] | Known Model Parameters. Defaults to None. | None |
Returns:
Type | Description |
---|---|
Dict[str, Dict[Any, Any]] | Dict[str, Dict[Any, Any]]: The report as a dictionary. |
Source code in spectrafit/report.py
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 |
|
get_init_value(param, modelpars=None)
¶
Get the initial value of a parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param | Parameter | The Parameter to extract the initial value from. | required |
modelpars | Parameter | Known Model Parameters. Defaults to None. | None |
Returns:
Type | Description |
---|---|
Union[float, str] | Union[float, str]: The initial value. |
Source code in spectrafit/report.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|