Regression with MATLAB fmincon

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024

Комментарии • 39

  • @hjnugget1974
    @hjnugget1974 3 года назад +1

    Very helpful, thanks! Couldn't get the constraints to work before watching this video :)

  • @dr.alikhudhair9414
    @dr.alikhudhair9414 19 дней назад +1

    Thank you

  • @konstapelwalander
    @konstapelwalander 5 лет назад +2

    Thank you so much for this great tutorial! Cheers

    • @apm
      @apm  5 лет назад

      You are welcome!

  • @helenos5578
    @helenos5578 3 года назад +1

    Thank you for this great tutorial

  • @nontheness
    @nontheness 5 лет назад +1

    @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  5 лет назад

      Thanks for the tip!

  • @gotravelbuddy
    @gotravelbuddy 3 года назад +1

    Hi, how about if the function is in complex number form. eg: y (x) = A(x) + B(x)*i . Thanks

    • @apm
      @apm  3 года назад

      Does this help? www.mathworks.com/help/optim/ug/complex-numbers-in-optimization-toolbox-solvers.html

  • @cheekiestclan5668
    @cheekiestclan5668 3 года назад +1

    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 года назад +1

    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.

  • @mengzhuwang3859
    @mengzhuwang3859 2 года назад +1

    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

  • @JackSparrow-yt3qw
    @JackSparrow-yt3qw 2 года назад +1

    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  2 года назад

      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).

  • @abubakarizhar5608
    @abubakarizhar5608 10 месяцев назад

    Can we use fmincon with two independent variables. Also can you please show how to use fmincon for finding global minimum.

  • @trotion
    @trotion 5 лет назад +1

    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.

  • @navneetkumar6606
    @navneetkumar6606 3 года назад +1

    thankyou

  • @musafir1068
    @musafir1068 6 лет назад +1

    its awesome.video quality is not good.plz makes videos on the fitting of large noisy by using user-defined functions.

    • @apm
      @apm  6 лет назад +1

      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.

  • @azrulkiromil8885
    @azrulkiromil8885 4 года назад +1

    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 года назад +1

      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 👍👍👍

  • @eduardobustos1887
    @eduardobustos1887 3 года назад +1

    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

  • @niccolotani6828
    @niccolotani6828 4 года назад +1

    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 года назад +1

      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

  • @zahrahoseini4088
    @zahrahoseini4088 5 лет назад +1

    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 года назад +1

    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 года назад +1

      Yes, you can do multivariate regression. You can additional parameters to the model.

    • @abdelmalekmezrag2849
      @abdelmalekmezrag2849 4 года назад

      @@apm OK thnx, I will try

  • @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

  • @firassami7399
    @firassami7399 5 лет назад +1

    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 лет назад +1

      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