Re: Scipy curve_fit

Liste des GroupesRevenir à cl python 
Sujet : Re: Scipy curve_fit
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 09. Mar 2025, 15:05:35
Autres entêtes
Organisation : Stefan Ram
Message-ID : <Warning-20250309145742@ram.dialup.fu-berlin.de>
References : 1
Jorge Conrado Conforte <jc2conforte@gmail.com> wrote or quoted:
OptimizeWarning: Covariance of the parameters could not be estimated
Please how can I resolve this error.

  The OptimizeWarning you're running into isn't a full-blown error,
  but a heads-up that the covariance of the parameters couldn't be
  nailed down. This often crops up when the fit's all over the map or
  when there's something fishy with the model or data. To get around
  this and up your curve fitting game, give these tricks a whirl:

  1. Throw in some initial parameter guesstimates:

# Tweak the number and values of initial guesses based on your model
popt, _ = curve_fit(non_linear_model, preciamz, areaqamz, p0=[1, 1, 1]) 

  . 2. Set some guardrails for your parameters if you've got a ballpark
  idea of where they should land:

# Adjust bounds based on your model and data
popt, _ = curve_fit(non_linear_model, preciamz, areaqamz,
                    bounds=([0, 0, 0], [100, 100, 100])) 

  . 3. Make sure your `non_linear_model` function is on point and
  coughs up values for all input data:

# Example function, tweak based on your specific model
def non_linear_model(x, a, b, c): 
    return a * np.exp(-b * x) + c

  . 4. Give your data a once-over for any oddball points or
  inconsistencies that might throw a wrench in the works.

  5. If you're still hitting a wall, try a different optimization
  method:

popt, _ = curve_fit(non_linear_model, preciamz, areaqamz, method='trf')

  . 6. Think about using the lmfit library for more bells and whistles
  in fitting options and better handling of parameter uncertainties.

  If you're still stuck, double-check your model and data
  to make sure they're suitable for curve fitting. Keep in mind
  that curve_fit assumes continuous variables, so discrete or
  step-like data might gum up the works.



Date Sujet#  Auteur
6 Mar 25 * Scipy curve_fit2Jorge Conrado Conforte
9 Mar 25 `- Re: Scipy curve_fit1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal