Hallo all, I am using Octave 3.8.0 to build a linear model that has several input features and one output feature. I will be using this model in order to predict the output for the given set of input features. When I searched on
the web for statistical packages, I found the following functions: polyfit and regress. But none of these functions returns me a model object which I can use it for prediction. Can I kindly know from the forum is there a function in octave that returns me a model object for linear regression? Regards, Krishnaprasad _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
On Mon, Sep 22, 2014 at 1:40 PM, Narayanan, Krishnaprasad
<[hidden email]> wrote: > Hallo all, > > > > I am using Octave 3.8.0 to build a linear model that has several input > features and one output feature. I will be using this model in order to > predict the output for the given set of input features. When I searched on > the web for statistical packages, I found the following functions: polyfit > and regress. But none of these functions returns me a model object which I > can use it for prediction. > > > > Can I kindly know from the forum is there a function in octave that returns > me a model object for linear regression? > > > > Regards, > > Krishnaprasad > > > _______________________________________________ > Help-octave mailing list > [hidden email] > https://lists.gnu.org/mailman/listinfo/help-octave > Krishnaprasad If you want to use linear regression you do not need polyfit. The function regress indeed returns a model you can use, here a minimalist example X = randn(10,5); y = X*linspace(-1,1,5).' + 0.01*randn(10,1); B = regress (y, X); plot(y,'.;data;',X*B,'o;train;') X_new = randn(100,5); y_predict = X_new*B Just make sure you read the help of regress to understand its outputs and also check your theory on linear regression for more robust results. Hope this helps. _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
On Mon, Sep 22, 2014 at 2:50 PM, Juan Pablo Carbajal
<[hidden email]> wrote: > On Mon, Sep 22, 2014 at 1:40 PM, Narayanan, Krishnaprasad > <[hidden email]> wrote: >> Hallo all, >> >> >> >> I am using Octave 3.8.0 to build a linear model that has several input >> features and one output feature. I will be using this model in order to >> predict the output for the given set of input features. When I searched on >> the web for statistical packages, I found the following functions: polyfit >> and regress. But none of these functions returns me a model object which I >> can use it for prediction. >> >> >> >> Can I kindly know from the forum is there a function in octave that returns >> me a model object for linear regression? >> >> >> >> Regards, >> >> Krishnaprasad >> >> >> _______________________________________________ >> Help-octave mailing list >> [hidden email] >> https://lists.gnu.org/mailman/listinfo/help-octave >> > > Krishnaprasad > > If you want to use linear regression you do not need polyfit. The > function regress indeed returns a model you can use, here a minimalist > example > > X = randn(10,5); > y = X*linspace(-1,1,5).' + 0.01*randn(10,1); > B = regress (y, X); > plot(y,'.;data;',X*B,'o;train;') > X_new = randn(100,5); > y_predict = X_new*B > > Just make sure you read the help of regress to understand its outputs > and also check your theory on linear regression for more robust > results. > > Hope this helps. oh, check the model in B B = -0.9994197 -0.4920026 -0.0020738 0.5000850 1.0058200 and compare with linspace(-1,1,5).' _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
Hi Juan,
Thanks for your reply. I was looking for a function similar to fitlm in Matlab. I will try the example which you have suggested and check whether it resolves the problem that I had mentioned. Regards, Krishnaprasad |
On Mon, Sep 22, 2014 at 3:10 PM, Krishnaprasad <[hidden email]> wrote:
> Hi Juan, > > Thanks for your reply. I was looking for a function similar to fitlm in > Matlab. I will try the example which you have suggested and check whether it > resolves the problem that I had mentioned. > > Regards, > Krishnaprasad > > > > -- > View this message in context: http://octave.1599824.n4.nabble.com/Model-object-as-output-for-linear-regression-in-Octave-3-8-tp4666624p4666630.html > Sent from the Octave - General mailing list archive at Nabble.com. > > _______________________________________________ > Help-octave mailing list > [hidden email] > https://lists.gnu.org/mailman/listinfo/help-octave Have in mind that what I did wont be useful for a realistic situation, you will have to do regularization, eventl. outlyier detection, etc in any real world application I can think of. My examples solves the regression problem for mappings from R^n --> R that is n features generating a scalar value, which is what I understood you need. _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
Free forum by Nabble | Edit this page |