Regression with MATLAB fmincon

  Рет қаралды 29,895

APMonitor.com

APMonitor.com

Күн бұрын

A frequent activity in data science and machine learning is to develop correlations from data. By importing the data into MATLAB, data analysis such as statistics, trending, or calculations can be made to synthesize the information into relevant and actionable information. This tutorial demonstrates how to create a function that best approximates the data trend and analyze the result. A script file of the MATLAB source code is available at apmonitor.com/che263/index.php...

Пікірлер: 38
@hjnugget1974
@hjnugget1974 3 жыл бұрын
Very helpful, thanks! Couldn't get the constraints to work before watching this video :)
@konstapelwalander
@konstapelwalander 5 жыл бұрын
Thank you so much for this great tutorial! Cheers
@apm
@apm 5 жыл бұрын
You are welcome!
@helenos5578
@helenos5578 3 жыл бұрын
Thank you for this great tutorial
@cheekiestclan5668
@cheekiestclan5668 3 жыл бұрын
Good video, would it be possible to run a Simulink model within a loop, saving outputs to use as the data each time and change workspace variables to optimise how the model runs?
@raajgovindan
@raajgovindan 4 жыл бұрын
Very well explained... Great... I have one doubt. How to verify that the optimized value is global optima not the local one?
@apm
@apm 4 жыл бұрын
The methods I share use local optimizers. You could try a multi-start method where you give the local optimizer different initial conditions.
@nontheness
@nontheness 4 жыл бұрын
@15:23: Modifying line 27 from 'lb = ones(3)*0.2' to 'lb = ones(1,3)*0.2;' removes the warning message (Length of lower bounds is > length(x) ...).
@apm
@apm 4 жыл бұрын
Thanks for the tip!
@mengzhuwang3859
@mengzhuwang3859 2 жыл бұрын
Thank you John, this is an excellent video! Thank you for the tutorial! My problem is that I wrote the same command with you . But the results I got are dependent on the random number I gave to P0 at the beginning, which means that if I input p0=[1,2] and p0=[2,3], I will get a totally different Popt. I don't know even how to describe this problem in Google >
@apm
@apm 2 жыл бұрын
Initial guesses are important, especially with less powerful solvers. See the Gekko solution to the same problem here: apmonitor.com/che263/index.php/Main/PythonDataRegression
@gotravelbuddy
@gotravelbuddy 2 жыл бұрын
Hi, how about if the function is in complex number form. eg: y (x) = A(x) + B(x)*i . Thanks
@apm
@apm 2 жыл бұрын
Does this help? www.mathworks.com/help/optim/ug/complex-numbers-in-optimization-toolbox-solvers.html
@trotion
@trotion 4 жыл бұрын
Another great video! I commented extensively on one of your other videos. I have further narrowed it down to the following: I keep getting this error: "Error using fmincon (line 619) Supplied objective function must return a scalar value." I think its due to the fact that I have more than one set of xm and ym's, i.e. [xm, ym; xm, ym; ....;......]. Any comments?
@apm
@apm 4 жыл бұрын
The error is because the objective function must always return a single number.
@azrulkiromil8885
@azrulkiromil8885 4 жыл бұрын
excuse me. thanks for the great tutorial. but, I want to ask something. in initial, there is the function y = p1 + (p2/x) + ln(x)*p3. is that equation an objective function for optimization? if it is so, what is the constraint? and, I think xm and ym can be plotted in excel file, so we shouldn't put xm and ym in MATLAB script. i.e. we import it from excel to MATLAB as an alternative. could it be? thank u so much.
@apm
@apm 4 жыл бұрын
No, the equation is the constraint. The objective function is a measure of how well the data fits the predicted output (y) based on the input xm such as (y-ym).^2 Here is information on importing data files into Matlab: apmonitor.com/che263/index.php/Main/MatlabDataAnalysis It is easier if you save the file as a CSV type first.
@azrulkiromil8885
@azrulkiromil8885 4 жыл бұрын
@@apm thank u so much for the answer, professor 👍👍👍
@abubakarizhar5608
@abubakarizhar5608 8 ай бұрын
Can we use fmincon with two independent variables. Also can you please show how to use fmincon for finding global minimum.
@JackSparrow-yt3qw
@JackSparrow-yt3qw Жыл бұрын
I am trying to do regression non-linear on a data of force-displacement. I would like to ask how to know the equation in advance (as you mostly do know at the start of your videos related to regression) without doing the fit first? I have a data with strain-hardening behavior
@apm
@apm Жыл бұрын
Coming up with the correct form of the equation is typically based on physics-based principles. Another approach is to use machine learning where the equations are determined by the algorithm: apmonitor.com/pds/ (see Regression section).
@musafir1068
@musafir1068 6 жыл бұрын
its awesome.video quality is not good.plz makes videos on the fitting of large noisy by using user-defined functions.
@apm
@apm 6 жыл бұрын
You may need to wait for the video to buffer for 1080p video resolution. Higher quality video is available but may be limited by your bandwidth. This method should also work with noisy data. See apmonitor.com/che263/index.php/Main/PythonRegressionStatistics for another example with a user-defined function.
@niccolotani6828
@niccolotani6828 4 жыл бұрын
Great video I tried to use this code with a p(1) + p(2).*x+p(3).*(x).^2 and this error pops up Unrecognized function or variable 'getIpOptions'. Error in fmincon (line 822) options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01); Error in Program1 (line 323) popt = fmincon(obj,p0); The code is the same as yours and i don't know what to do
@apm
@apm 4 жыл бұрын
It sounds like it could be a problem with your MATLAB installation or compatibility of a toolbox. APMonitor MATLAB toolbox is another option if that doesn't work for you: apmonitor.com/che263/index.php/Main/MatlabDataRegression or you could try Python: apmonitor.com/che263/index.php/Main/PythonDataRegression
@eduardobustos1887
@eduardobustos1887 3 жыл бұрын
I getting this error: "Error in fmincon (line 859) options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01)"
@apm
@apm 3 жыл бұрын
Check the MathWorks website for that specific option. Here is some help on fmincon: apmonitor.com/che263/index.php/Main/MatlabOptimization
@Chikka92
@Chikka92 5 жыл бұрын
What's the difference of fmincon and Polyval? Does polyval return same results as of fmincon for a given set of data?
@apm
@apm 5 жыл бұрын
fmincon is a general purpose solver while polyval is just for fitting polynomials to data. See apmonitor.com/che263/index.php/Main/MatlabOptimization and apmonitor.com/che263/index.php/Main/MatlabDataRegression
@navneetkumar6606
@navneetkumar6606 3 жыл бұрын
thankyou
@zahrahoseini4088
@zahrahoseini4088 5 жыл бұрын
What should we do if we want the sum of the errors?
@apm
@apm 5 жыл бұрын
You can compute it with sum((ym-yp).^2) where ym is your vector of measurements and yp is your vector of predicted values.
@abdelmalekmezrag2849
@abdelmalekmezrag2849 4 жыл бұрын
Sir thnx for ur tutorial! but I have a problem, Where I want to solve an error regression with an objective function contains a parameter contains three values at the same time, one always remains fixed and for the other two takes a value it depends on tells conditions how I can do that please !
@apm
@apm 4 жыл бұрын
Yes, you can do multivariate regression. You can additional parameters to the model.
@abdelmalekmezrag2849
@abdelmalekmezrag2849 4 жыл бұрын
@@apm OK thnx, I will try
@firassami7399
@firassami7399 5 жыл бұрын
Hello sir,it is really very usefull lesson. I am facing trouble and I hope to help me in coding. I want to separate the coeffisions to solve advace problems like below p1=4 p2=.54 p3=-0.1 yp =@(p1,p2,p3) p1+p2./xm +log (xm).*p3 obj=@(p1,p2,p3) sum ((yp (p1,p2,p3)-ym)./ym).^2) p_ottimal =fmincon (pbjective,(p1,p2,p3)) i found error in fmincon can you help me
@apm
@apm 5 жыл бұрын
If it's an error that it didn't converge then you may need to give better guess values for the optimizer. If it still isn't solving then a better optimizer such as APM Matlab may be better.
@firassami7399
@firassami7399 5 жыл бұрын
@@apm Thank you soo much
Regression in Python 🐍 with Scipy/GEKKO
10:19
APMonitor.com
Рет қаралды 5 М.
Lecture: Data Fitting with Matlab
39:15
AMATH 301
Рет қаралды 54 М.
МАМА И STANDOFF 2 😳 !FAKE GUN! #shorts
00:34
INNA SERG
Рет қаралды 3,9 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 25 МЛН
Универ. 13 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:07:11
Комедии 2023
Рет қаралды 6 МЛН
Nonlinear Regression in MATLAB
15:35
APMonitor.com
Рет қаралды 127 М.
Multivariate Regression with MATLAB
1:15:07
Economics, Statistics, and Public Finance
Рет қаралды 6 М.
Linear and Polynomial Regression in MATLAB
8:55
APMonitor.com
Рет қаралды 56 М.
Linear and Multivariable Regression in MATLAB
1:03:27
Yusri Yusup
Рет қаралды 14 М.
Design Optimization: What's Behind It?
29:25
MATLAB
Рет қаралды 15 М.
Non linear curve fitting using MATLAB and Excel
13:44
Rahmat Sunarya
Рет қаралды 4,5 М.
Gaussian Processes
23:47
Mutual Information
Рет қаралды 118 М.
How To Unlock Your iphone With Your Voice
0:34
요루퐁 yorupong
Рет қаралды 28 МЛН
1$ vs 500$ ВИРТУАЛЬНАЯ РЕАЛЬНОСТЬ !
23:20
GoldenBurst
Рет қаралды 1,3 МЛН
Неразрушаемый смартфон
1:00
Status
Рет қаралды 2 МЛН