Curve Fitting using Numpy's Polyfit Function

  Рет қаралды 34,827

Adam Gaweda

Adam Gaweda

4 жыл бұрын

Пікірлер: 34
@pgille2
@pgille2 2 жыл бұрын
You are killing it. Thanks for the thorough explanation
@j8ahmed
@j8ahmed 3 жыл бұрын
That was a great explanation. Thanks a ton!
@atolantis
@atolantis 3 жыл бұрын
That was very helpful and clear, thank you
@somecrispywater1146
@somecrispywater1146 3 жыл бұрын
That was very helpful! Thank you!! :)
@standman007
@standman007 7 ай бұрын
This was extremely helpful. I verified with excel and my equations match perfectly. Thanks, from the bottom of my heart. with value of 1 i got the same Linear equation. with value of 2 i got the same Polynomial equation - for example curve = np.polyfit(x,y,1)
@alice-gv5ue
@alice-gv5ue 3 жыл бұрын
Thanks, finally I understood difference between polyfit and poly1d, I was just wondering why they use 2 functions...
@nedasadati6385
@nedasadati6385 2 жыл бұрын
it was very useful. thanks!
@martinx1783
@martinx1783 2 жыл бұрын
That helps a lot, thanks
@dm3248
@dm3248 3 жыл бұрын
Very helpful!!
@mohammedthahaabdulshukoor4321
@mohammedthahaabdulshukoor4321 4 жыл бұрын
good explanation
@tomgt428
@tomgt428 3 жыл бұрын
So cool
@felipeemerson4050
@felipeemerson4050 4 жыл бұрын
Thanks
@kaaehtla
@kaaehtla 3 жыл бұрын
great
@keshav347
@keshav347 2 жыл бұрын
Could you please explain how i can use this function if i have 3 dimensions [x,y,z] how can i fit a curve in 3d. as i would like to compute the radius of curvature by fitting a curve. Thanks in advance.
@SomeOne-rx2xw
@SomeOne-rx2xw 2 жыл бұрын
Thank you sir
@yousfoss4367
@yousfoss4367 3 жыл бұрын
thks a lot
@Justin-yc5jt
@Justin-yc5jt 3 жыл бұрын
tysm
@dontaskme1625
@dontaskme1625 3 жыл бұрын
the pythonic way to create an array with the values from 1 to 20 is [x for x in range(1,21)]
@AMGaweda
@AMGaweda 3 жыл бұрын
While [x for x in range(1,21)] will create the 1 to 20 list, I would not consider it the "pythonic way". Plus, for many students, they've only recently learned about lists, so adding a one-line trick for creating lists, while nice, can be confusing to some students. Its not to say you shouldn't do it, but when teaching a separate concept, its better to reduce extra complexities.
@tony_joris
@tony_joris 3 жыл бұрын
hello! I need to get the potential and logarithmic equation from a data table, what command can I use instead of polyfit? thanks!
@AMGaweda
@AMGaweda 3 жыл бұрын
My biggest recommendation would be to look through NumPy's documentation: numpy.org/doc/stable/reference/routines.polynomials.html which may point you to the the particular equation you're looking for. If it is not there, then I'd recommend looking into other Python libraries that may do. Worse comes to worse, there's always the "build it yourself" approach
@Ingeniosamente
@Ingeniosamente Жыл бұрын
Muy interesante el video. Qué editor utilizas?. En todos los editores es posible usar esta funcion?
@AMGaweda
@AMGaweda Жыл бұрын
Disculpas por el lenguaje, estoy usando Google Translate. Utilizo GIMP con una tableta Wacom para dibujar en mi pantalla: mi paleta de colores se creó a partir de FlatUIColors.com (v1) y mi pincel es `Hardness 100` tamaño 2 con Smooth Stroke habilitado y configurado en 20. Para grabar videos, uso OBS (obsproject.com/) sin ninguna otra edición de video. Tengo mis botones F8 y F9 configurados para iniciar y detener la grabación. En este video, usé Spyder para la programación configurada desde la distribución de Anaconda (anaconda.org/), pero en el pasado también usé otros editores de texto. También uso Sublime Text con complementos de autocompletado de Python, pero VS Code también puede funcionar.
@joacimjohnsson
@joacimjohnsson 3 жыл бұрын
Can you use this curvfit for statistical fitting, like Normal dist/ exponential dist/ ... instead of the deg 2?
@AMGaweda
@AMGaweda 3 жыл бұрын
Polyfit is a "least squares polynomial fitting" algorithm, so you are able to increase (or decrease) the curve's degree as necessary. It will not do this for you, but you can adjust the number or add more code that checks the curves precision.
@aritraray2501
@aritraray2501 3 жыл бұрын
Hello, how can I find the area inside a curve? I have data points for a hysteresis loop and I want to calculate the area inside the curve.
@AMGaweda
@AMGaweda 3 жыл бұрын
You'd want to look into the SciPy's Integrate function; here is a video that might help kzbin.info/www/bejne/sHyul6pnjNCIqpY
@Soo5301
@Soo5301 3 жыл бұрын
What if the x axis is date? How can i deal with in this case?
@AMGaweda
@AMGaweda 3 жыл бұрын
In this case, you'd need to create a normal list from 0 to how ever many dates you have in mind. Think of this like a graph in math class - you still need to specify what the x-axis in your graph is (even if its dates). If you then need to plot the graph, you can modify the x-axis's display with MatPlotLib's set_xlabel function.
@abigailwaring4720
@abigailwaring4720 2 жыл бұрын
Hi, how would you do this using data in a pandas data frame of two columns please?
@AMGaweda
@AMGaweda 2 жыл бұрын
The quickest way I've found to extract a list from a DataFrame is to do something like x = list(df["x"]). Then you should be able to use the approach from the video
@Alpharabius99
@Alpharabius99 3 жыл бұрын
What if i want to plot variable data sets of x but with the same y axis. İmagine 10 data sets of x's and one data set of y. İts like one data set of x toone data set of y in the video. But what if i want to fit the curve for various data sets of x axis with only one y axis? Ofcourse i can do it one by one. But there should be some quick way to do this right? İt seems pointless to run this code for 10 times for different x Data sets.
@AMGaweda
@AMGaweda 3 жыл бұрын
My thoughts are that you could use a for loop to change your x, curve, and plot with your y outside of the loop. Something like: datasets = [[123],[4,5,6],[7,8,9]] # your X datasets y = [1,2,3] # your Y for x in datasets: curve = np.polyfit(x, y) # creates your curve on each X one at a time poly = np.poly1d(curve) # makes that curve an np.array # plot your datasets plt.show() # outside the for loop This would condense your code to only need to do the calculations "once" for each X dataset along the same Y. Also, since plt.show() is outside the for loop, all of your plotting would be done on the same graphic (you could also use subplots here instead depending on what you are looking for)
@Alpharabius99
@Alpharabius99 3 жыл бұрын
@@AMGaweda Thanks for the reply man. Wasnt expecting :). İ will post again after i try it.
Plotting with Matplotlib
9:07
Adam Gaweda
Рет қаралды 955
Curve Fitting in Python (2022)
24:50
Mr. P Solver
Рет қаралды 89 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 19 МЛН
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 46 МЛН
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 76 МЛН
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 104 МЛН
Representing Polynomials in Python Using Numpy
6:51
Adam Gaweda
Рет қаралды 11 М.
The Python Function You NEED For 2D Data
10:49
Mr. P Solver
Рет қаралды 35 М.
Polynomial Regression in Python
20:18
NeuralNine
Рет қаралды 43 М.
Chapter 13: Polynomial Curve Fitting in MATLAB
8:49
Hanshaw Virtual University
Рет қаралды 92 М.
Unlock the Secret of Nonlinear Curve Fitting - Python LMFIT
18:18
Introduction to Optimization and Curve Fitting
11:30
Forrest Charnock
Рет қаралды 27 М.
Polyfit and Polyval
17:52
DarkfrostTGF
Рет қаралды 15 М.
Building the Gradient Descent Algorithm in 15 Minutes | Coding Challenge
22:29
Python 🐍 Nonlinear Regression Curve Fit
14:22
APMonitor.com
Рет қаралды 80 М.
Least Squares Fit and Graphing in Python
9:49
Dot Physics
Рет қаралды 3,5 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 19 МЛН