Questions tagged [data-fitting]

Data fitting is to fit a line through a data set i.e. a series of data points.

853 questions
61
votes
1 answer

Meaning of validation_steps in Keras Sequential fit_generator parameter list

I am using Keras with a Tensorflow backend in Python. To be more precise tensorflow 1.2.1 and its build-in contrib.keras lib. I want to use the fit_generator method of a Sequential model object, but I am confused with what I should pass as the…
Philipp Lange
  • 851
  • 1
  • 6
  • 11
59
votes
3 answers

fitting data with numpy

I have the following data: >>> x array([ 3.08, 3.1 , 3.12, 3.14, 3.16, 3.18, 3.2 , 3.22, 3.24, 3.26, 3.28, 3.3 , 3.32, 3.34, 3.36, 3.38, 3.4 , 3.42, 3.44, 3.46, 3.48, 3.5 , 3.52, 3.54, 3.56, 3.58, 3.6 , 3.62, …
ezitoc
  • 729
  • 1
  • 6
  • 9
52
votes
6 answers

How to find probability distribution and parameters for real data? (Python 3)

I have a dataset from sklearn and I plotted the distribution of the load_diabetes.target data (i.e. the values of the regression that the load_diabetes.data are used to predict). I used this because it has the fewest number of variables/attributes…
O.rka
  • 29,847
  • 68
  • 194
  • 309
42
votes
3 answers

Getting standard errors on fitted parameters using the optimize.leastsq method in python

I have a set of data (displacement vs time) which I have fitted to a couple of equations using the optimize.leastsq method. I am now looking to get error values on the fitted parameters. Looking through the documentation the matrix outputted is the…
Phil
  • 581
  • 1
  • 7
  • 11
41
votes
4 answers

Fitting a closed curve to a set of points

I have a set of points pts which form a loop and it looks like this: This is somewhat similar to 31243002, but instead of putting points in between pairs of points, I would like to fit a smooth curve through the points (coordinates are given at the…
Mahdi
  • 3,188
  • 2
  • 20
  • 33
34
votes
3 answers

Fitting a 2D Gaussian function using scipy.optimize.curve_fit - ValueError and minpack.error

I intend to fit a 2D Gaussian function to images showing a laser beam to get its parameters like FWHM and position. So far I tried to understand how to define a 2D Gaussian function in Python and how to pass x and y variables to it. I've written a…
Kokomoking
  • 363
  • 1
  • 4
  • 5
25
votes
3 answers

Why does scipy.optimize.curve_fit not fit to the data?

I've been trying to fit an exponential to some data for a while using scipy.optimize.curve_fit but i'm having real difficulty. I really can't see any reason why this wouldn't work but it just produces a strait line, no idea why! Any help would be…
user1696811
  • 941
  • 4
  • 10
  • 20
15
votes
2 answers

How to weigh the points in a scatter plot for a fit?

So, I looked up information about the weights parameter in the polyfit (numpy.polynomial.polynomial.polyfit) function in Python and it seems like it has something to do with the error associated with the individual points. (How to include…
14
votes
1 answer

SciPy LeastSq Goodness of Fit Estimator

I have a data surface that I'm fitting using SciPy's leastsq function. I would like to have some estimate of the quality of the fit after leastsq returns. I'd expected that this would be included as a return from the function, but, if so, it doesn't…
Richard
  • 56,349
  • 34
  • 180
  • 251
12
votes
2 answers

Fitting an ellipse to a set of data points in python

I have a 2D points (x,y), and I want to fit the ellipse using this post fit a ellipse in Python given a set of points xi=(xi,yi) But my result is axes = [ 0.93209407 nan] since in function ellipse_axis_length the down2 is a minus number, so res2…
Jiao Li
  • 323
  • 1
  • 5
  • 13
12
votes
2 answers

Fitting data with integral function

When using curve_fit from scipy.optimize to fit a some data in python, one first defines the fitting function (e.g. a 2nd order polynomial) as follows: def f(x, a, b): return a*x**2+b*x And then proceeds with the fitting popt, pcov =…
user4587874
12
votes
1 answer

How to fit known values to a known curve by changing x-axis

This is a continuum to a Cross-validated question where I asked about plausible methods for the problem. This question is more programming orientated, so I post it here on SO. Background I have a curve with known dates spanning over a year. The…
Mikko
  • 7,530
  • 8
  • 55
  • 92
11
votes
2 answers

Is there a way to get the error in fitting parameters from scipy.stats.norm.fit?

I have some data which I have fitted a normal distribution to using the scipy.stats.normal objects fit function like so: import numpy as np …
SomeRandomPhysicist
  • 1,531
  • 4
  • 19
  • 42
10
votes
4 answers

Fitting data to system of ODEs using Python via Scipy & Numpy

I am having some trouble translating my MATLAB code into Python via Scipy & Numpy. I am stuck on how to find optimal parameter values (k0 and k1) for my system of ODEs to fit to my ten observed data points. I currently have an initial guess for k0…
Zack
  • 713
  • 2
  • 8
  • 21
9
votes
1 answer

How to do a polynomial fit with fixed points in 3D

I have sets of x,y,z points in 3D space and another variable called charge which represents the amount of charge that was deposited in a specific x,y,z coordinate. I would like to do a weighted (weighted by the amount of charge deposited in the…
1
2 3
56 57