Fitting parameters of a function to explain given data
Questions tagged [model-fitting]
414 questions
59
votes
11 answers
Finding the best trade-off point on a curve
Say I had some data, for which I want to fit a parametrized model over it. My goal is to find the best value for this model parameter.
I'm doing model selection using a AIC/BIC/MDL type of criterion which rewards models with low error but also…

Amro
- 123,847
- 25
- 243
- 454
14
votes
2 answers
Fit Quadrilateral (Tetragon) to a blob
After applying different filtering and segmentation techniques, I end up with an image like this:
I have access to some contours detection functions that return a list of points on the edge of that object, or returns a fitted polygon (with many…

Mehdi
- 1,370
- 3
- 15
- 26
13
votes
1 answer
trying to display original and fitted data (nls + dnorm) with ggplot2's geom_smooth()
I am exploring some data, so the first thing I wanted to do was try to fit a normal (Gaussian) distribution to it. This is my first time trying this in R, so I'm taking it one step at a time. First I pre-binned my data:
myhist = data.frame(size =…

Jeffrey Breen
- 463
- 4
- 8
13
votes
2 answers
Vector autoregressive model fitting with scikit-learn
I am trying to fit vector autoregressive (VAR) models using the generalized linear model fitting methods included in scikit-learn. The linear model has the form y = X w, but the system matrix X has a very peculiar structure: it is block-diagonal,…

MB-F
- 22,770
- 4
- 61
- 116
11
votes
4 answers
ValueError: Unknown label type: while implementing MLPClassifier
I have dataframe with columns Year, month, day,hour, minute, second, Daily_KWH. I need to predict Daily KWH using neural netowrk. Please let me know how to go about it
Daily_KWH_System year month day hour minute second
0 …

Anagha
- 3,073
- 8
- 25
- 43
10
votes
2 answers
Fitting a 3 parameter Weibull distribution
I have been doing some data analysis in R and I am trying to figure out how to fit my data to a 3 parameter Weibull distribution. I found how to do it with a 2 parameter Weibull but have come up short in finding how to do it with a 3 parameter.…

Matthew Crews
- 4,105
- 7
- 33
- 57
8
votes
1 answer
Correct usage of fmin_l_bfgs_b for fitting model parameters
I have a some experimental data (for y, x, t_exp, m_exp), and want to find the "optimal" model parameters (A, B, C, D, E) for this data using the constrained multivariate BFGS method. Parameter E must be greater than 0, the others are…

Benjamin
- 11,560
- 13
- 70
- 119
8
votes
1 answer
Why does scipy.optimize.least_squares exist when scipy.optimize.minimize could potentially be used for the same things?
I am trying to understand why the scipy.optimize.least_squares exists in scipy. This function can be used to perform model-fitting. However, one could use scipy.optimize.minimize to do the same thing. The only difference is that…

AstrOne
- 3,569
- 7
- 32
- 54
8
votes
0 answers
Fitting a non-homogeneous poisson-process with PyMC
I'm new to PyMC and trying to fit my non-homogeneous poisson-process with a piecewise-constant rate function using the maximum a posteriori estimate.
My process describes some events during a day. Therefore i'm splitting a day into 24 hours, which…

sascha
- 32,238
- 6
- 68
- 110
8
votes
2 answers
Does 'statsmodels' or another Python package offer an equivalent to R's 'step' function?
Is there a statsmodels or other Python equivalent for R's step functionality for selecting a formula-based model using AIC?

orome
- 45,163
- 57
- 202
- 418
7
votes
2 answers
How to check the convergence when fitting a distribution in SciPy
Is there a way to check the convergence when fitting a distribution in SciPy?
My goal is to fit a SciPy distribution (namely Johnson S_U distr.) to dozens of datasets as a part of an automated data-monitoring system. Mostly it works fine, but a few…

Vojta F
- 534
- 3
- 17
7
votes
3 answers
Is it possible to fit separate parts of an sklearn pipeline?
Consider having following sklearn Pipeline:
pipeline = make_pipeline(
TfidfVectorizer(),
LinearRegression()
)
I have TfidfVectorizer pretrained, so when I am calling pipeline.fit(X, y) I want only LinearRegression to be fitted and I don't…

Alexander
- 71
- 2
7
votes
1 answer
Python power law fit with upper limits & asymmetric errors in data using ODR
I'm trying to fit some data to a power law using python. The problem is that some of my points are upper limits, which I don't know how to include in the fitting routine.
In the data, I have put the upper limits as errors in y equal to 1, when the…

astrostudent
- 71
- 1
- 3
7
votes
1 answer
Fitting Parametric Curves in Python
I have experimental data of the form (X,Y) and a theoretical model of the form (x(t;*params),y(t;*params)) where t is a physical (but unobservable) variable, and *params are the parameters that I want to determine. t is a continuous variable, and…

Necarion
- 105
- 1
- 6
6
votes
1 answer
How to catch any Exception during Model Training in Tensorflow 2
I'm training a Unet model using Tensorflow. If there is a problem with any of the images I am passing to the model for training, an exception is thrown. Sometimes this can occur an hour or two into training. Is it possible to catch any such…

CSharp
- 1,396
- 1
- 18
- 41