https://raw.githubusercontent.com/MatthewReid854/reliability/master/docs/images/logo.png

Fit_Everything

class reliability.Fitters.Fit_Everything(failures=None, right_censored=None, exclude=None, sort_by='BIC', method='MLE', optimizer=None, print_results=True, show_histogram_plot=True, show_PP_plot=True, show_probability_plot=True, show_best_distribution_probability_plot=True, downsample_scatterplot=True)

This function will fit all available distributions to the data provided. The only distributions not fitted are Weibull_DSZI and Weibull_ZI. The Beta_2P distribution will only be fitted if the data are between 0 and 1.

Parameters:
  • failures (array, list) – The failure data. Must have at least 2 elements for all the 2 parameter distributions to be fitted and 3 elements for all distributions to be fitted.
  • right_censored (array, list, optional) – The right censored data. Optional input. Default = None.
  • sort_by (str) – Goodness of fit test to sort results by. Must be ‘BIC’,’AICc’,’AD’, or ‘Log-likelihood’. Default is BIC.
  • show_probability_plot (bool, optional) – Provides a probability plot of each of the fitted distributions. True or False. Default = True
  • show_histogram_plot (bool, optional) – True or False. Default = True. Will show a histogram (scaled to account for censored data) with the PDF and CDF of each fitted distribution.
  • show_PP_plot (bool, optional) – Provides a comparison of parametric vs non-parametric fit using Probability-Probability (PP) plot. True or False. Default = True.
  • show_best_distribution_probability_plot (bool, optional) – Provides a probability plot in a new figure of the best fitting distribution. True or False. Default = True.
  • exclude (list, array, optional) – List or array of strings specifying which distributions to exclude. Default is None. Options are Weibull_2P, Weibull_3P, Weibull_CR, Weibull_Mixture, Weibull_DS, Normal_2P, Gamma_2P, Loglogistic_2P, Gamma_3P, Lognormal_2P, Lognormal_3P, Loglogistic_3P, Gumbel_2P, Exponential_2P, Exponential_1P, Beta_2P.
  • print_results (bool, optional) – Will show the results of the fitted parameters and the goodness of fit tests in a dataframe. True/False. Defaults to True.
  • method (str, optional) – The method used to fit the distribution. Must be either ‘MLE’ (maximum likelihood estimation), ‘LS’ (least squares estimation), ‘RRX’ (Rank regression on X), or ‘RRY’ (Rank regression on Y). LS will perform both RRX and RRY and return the better one. Default is ‘MLE’.
  • optimizer (str, optional) – The optimization algorithm used to find the solution. Must be either ‘TNC’, ‘L-BFGS-B’, ‘nelder-mead’, or ‘powell’. Specifying the optimizer will result in that optimizer being used. To use all of these specify ‘best’ and the best result will be returned. The default behaviour is to try each optimizer in order (‘TNC’, ‘L-BFGS-B’, ‘nelder-mead’, and ‘powell’) and stop once one of the optimizers finds a solution. If the optimizer fails, the initial guess will be returned. For more detail see the documentation.
  • downsample_scatterplot (bool, int, optional) – If True or None, and there are over 1000 points, then the scatterplot will be downsampled by a factor. The default downsample factor will seek to produce between 500 and 1000 points. If a number is specified, it will be used as the downsample factor. Default is True. This functionality makes plotting faster when there are very large numbers of points. It only affects the scatterplot not the calculations.
Returns:

  • results (dataframe) – a pandas dataframe of results. Fitted parameters in this dataframe may be accessed by name. See below example in Notes.
  • best_distribution (object) – a reliability.Distributions object created based on the parameters of the best fitting distribution.
  • best_distribution_name (str) – the name of the best fitting distribution. E.g. ‘Weibull_3P’
  • parameters and goodness of fit results (float) – This is provided for each fitted distribution. For example, the Weibull_3P distribution values are Weibull_3P_alpha, Weibull_3P_beta, Weibull_3P_gamma, Weibull_3P_BIC, Weibull_3P_AICc, Weibull_3P_AD, Weibull_3P_loglik
  • excluded_distributions (list) – a list of strings of the excluded distributions.

Notes

All parametric models have the number of parameters in the name. For example, Weibull_2P uses alpha and beta, whereas Weibull_3P uses alpha, beta, and gamma. This is applied even for Normal_2P for consistency in naming conventions. From the results, the distributions are sorted based on their goodness of fit test results, where the smaller the goodness of fit value, the better the fit of the distribution to the data.

If the data provided contains only 2 failures, the three parameter distributions will automatically be excluded.

Example Usage:

X = [5,3,8,6,7,4,5,4,2]
output = Fit_Everything(X)
print('Weibull Alpha =',output.Weibull_2P_alpha)