matplotlib Error on "Fitting a specific distribution to data" with reliability package

pokxtpni  于 2023-02-23  发布在  其他
关注(0)|答案(1)|浏览(262)

With reliability package, I tried "Example 1" on Fitting a specific distribution to data as below

from reliability.Fitters import Fit_Weibull_2P
import matplotlib.pyplot as plt
data = [58,75,36,52,63,65,22,17,28,64,23,40,73,45,52,36,52,60,13,55,82,55,34,57,23,42,66,35,34,25] # made using Weibull Distribution(alpha=50,beta=3)
wb = Fit_Weibull_2P(failures=data)
plt.show()

Results with Parameters comes out, but error follows like below.

Results from Fit_Weibull_2P (95% CI):
Analysis method: Maximum Likelihood Estimation (MLE)
Optimizer: TNC
Failures / Right censored: 30/0 (0% right censored)

Parameter  Point Estimate  Standard Error  Lower CI  Upper CI
    Alpha          51.858         3.55628   45.3359   59.3183
     Beta         2.80086         0.41411   2.09624   3.74233

Goodness of fit    Value
 Log-likelihood -129.063
           AICc   262.57
            BIC  264.928
             AD 0.759805

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 4
      2 import matplotlib.pyplot as plt
      3 data = [58,75,36,52,63,65,22,17,28,64,23,40,73,45,52,36,52,60,13,55,82,55,34,57,23,42,66,35,34,25] # made using Weibull Distribution(alpha=50,beta=3)
----> 4 wb = Fit_Weibull_2P(failures=data)
      5 plt.show()

File N:\Programs\Python311\Lib\site-packages\reliability\Fitters.py:2333, in Fit_Weibull_2P.__init__(self, failures, right_censored, show_probability_plot, print_results, CI, quantiles, CI_type, method, optimizer, force_beta, downsample_scatterplot, **kwargs)
   2331 else:
   2332     rc = right_censored
-> 2333 Weibull_probability_plot(
   2334     failures=failures,
   2335     right_censored=rc,
   2336     __fitted_dist_params=self,
   2337     CI=CI,
   2338     CI_type=CI_type,
   2339     downsample_scatterplot=downsample_scatterplot,
   2340     **kwargs,
   2341 )
   2342 self.probability_plot = plt.gca()

File N:\Programs\Python311\Lib\site-packages\reliability\Probability_plotting.py:373, in Weibull_probability_plot(failures, right_censored, fit_gamma, __fitted_dist_params, a, CI, CI_type, show_fitted_distribution, show_scatter_points, downsample_scatterplot, **kwargs)
    368 plt.gca().set_yscale(
    369     "function",
    370     functions=(axes_transforms.weibull_forward, axes_transforms.weibull_inverse),
    371 )
    372 plt.xscale("log")
--> 373 plt.grid(b=True, which="major", color="k", alpha=0.3, linestyle="-")
    374 plt.grid(b=True, which="minor", color="k", alpha=0.08, linestyle="-")
    375 # adjust the figsize. This is done outside of figure creation so that layering of multiple plots is possible

File N:\Programs\Python311\Lib\site-packages\matplotlib\pyplot.py:2589, in grid(visible, which, axis, **kwargs)
   2587 @_copy_docstring_and_deprecators(Axes.grid)
   2588 def grid(visible=None, which='major', axis='both', **kwargs):
-> 2589     return gca().grid(visible=visible, which=which, axis=axis, **kwargs)

File N:\Programs\Python311\Lib\site-packages\matplotlib\axes\_base.py:3196, in _AxesBase.grid(self, visible, which, axis, **kwargs)
   3194 _api.check_in_list(['x', 'y', 'both'], axis=axis)
   3195 if axis in ['x', 'both']:
-> 3196     self.xaxis.grid(visible, which=which, **kwargs)
   3197 if axis in ['y', 'both']:
   3198     self.yaxis.grid(visible, which=which, **kwargs)

File N:\Programs\Python311\Lib\site-packages\matplotlib\axis.py:1655, in Axis.grid(self, visible, which, **kwargs)
   1652 if which in ['major', 'both']:
   1653     gridkw['gridOn'] = (not self._major_tick_kw['gridOn']
   1654                         if visible is None else visible)
-> 1655     self.set_tick_params(which='major', **gridkw)
   1656 self.stale = True

File N:\Programs\Python311\Lib\site-packages\matplotlib\axis.py:927, in Axis.set_tick_params(self, which, reset, **kwargs)
    914 """
    915 Set appearance parameters for ticks, ticklabels, and gridlines.
    916
   (...)
    924     gridlines.
    925 """
    926 _api.check_in_list(['major', 'minor', 'both'], which=which)
--> 927 kwtrans = self._translate_tick_params(kwargs)
    929 # the kwargs are stored in self._major/minor_tick_kw so that any
    930 # future new ticks will automatically get them
    931 if reset:

File N:\Programs\Python311\Lib\site-packages\matplotlib\axis.py:1071, in Axis._translate_tick_params(kw, reverse)
   1069 for key in kw_:
   1070     if key not in allowed_keys:
-> 1071         raise ValueError(
   1072             "keyword %s is not recognized; valid keywords are %s"
   1073             % (key, allowed_keys))
   1074 kwtrans.update(kw_)
   1075 return kwtrans

ValueError: keyword grid_b is not recognized; valid keywords are ['size', 'width', 'color', 'tickdir', 'pad', 'labelsize', 'labelcolor', 'zorder', 'gridOn', 'tick1On', 'tick2On', 'label1On', 'label2On', 'length', 'direction', 'left', 'bottom', 'right', 'top', 'labelleft', 'labelbottom', 'labelright', 'labeltop', 'labelrotation', 'grid_agg_filter', 'grid_alpha', 'grid_animated', 'grid_antialiased', 'grid_clip_box', 'grid_clip_on', 'grid_clip_path', 'grid_color', 'grid_dash_capstyle', 'grid_dash_joinstyle', 'grid_dashes', 'grid_data', 'grid_drawstyle', 'grid_figure', 'grid_fillstyle', 'grid_gapcolor', 'grid_gid', 'grid_in_layout', 'grid_label', 'grid_linestyle', 'grid_linewidth', 'grid_marker', 'grid_markeredgecolor', 'grid_markeredgewidth', 'grid_markerfacecolor', 'grid_markerfacecoloralt', 'grid_markersize', 'grid_markevery', 'grid_mouseover', 'grid_path_effects', 'grid_picker', 'grid_pickradius', 'grid_rasterized', 'grid_sketch_params', 'grid_snap', 'grid_solid_capstyle', 'grid_solid_joinstyle', 'grid_transform', 'grid_url', 'grid_visible', 'grid_xdata', 'grid_ydata', 'grid_zorder', 'grid_aa', 'grid_c', 'grid_ds', 'grid_ls', 'grid_lw', 'grid_mec', 'grid_mew', 'grid_mfc', 'grid_mfcalt', 'grid_ms']
  • Windows 10 Enterprise 21H2
  • Python 3.11.2
  • reliability==0.8.7
  • matplotlib==3.7.0
  • matplotlib-inline==0.1.6

How can I prevent error? In another PC with Mac OS, error does not come out and I don't know why.
I can succeed with matplotlib==3.6.1, so I made issue on GitHub.
https://github.com/MatthewReid854/reliability/issues/34

yv5phkfx

yv5phkfx1#

Today, this bug was fixed in "reliability" v0.8.8. https://github.com/MatthewReid854/reliability/issues/34#issuecomment-1438349636

相关问题