Closed JayCata closed 5 years ago
Have you tried reg[:coef_]
? Also note that there's a native-Julia implementation ScikitLearn.Models.LinearRegression()
, although it's more vanilla than sklearn
's.
Ahh that worked perfectly. Thank you. Do you know what documentation I can find this Julia-specific syntax in? I'm sure I will need other properties from other models as time goes on. Is it always going to be model[:property] where property is the way it is referenced in SKL documentation? Thanks again for your help.
ScikitLearn.jl relies on PyCall.jl for its Python models. It's well documented.
Is it always going to be model[:property]
Yes, that's the syntax for accessing object fields and methods.
That's why I couldn't find it. Was looking in this documentation instead of the PyCall documentation. Thanks sorry I am new to using these packages.
No worries, the docs could undoubtedly be better. FWIW it was mentioned here but I should probably have a link to PyCall on that page.
Let me know if you have other issues!
Thanks! I really appreciate the help.
This is kind of a basic question, but I've tried all combinations of syntax and cannot get it to work. I also looked through all of the old issues before posting here, so my apologies if this has already been answered.
I am having issues returning the coefficients from the linear regression. You can see my code below. I looked at the .jl file for it and tried various function/dot notation using coefs and I did the same with coef_ from the python manual. Those attempts aren't shown below because none of them worked.
Can someone please let me know what the command that returns the coefficient array is after the model has been fit? Sorry if this is not the place for such an issue.
Generate Data
Distributions
UniRVB = Uniform(0,1); NRVB = Normal(0,1);
srand(32); n=1000000; numX=10; X=rand(UniRVB,n,numX); Xmiss=sum(X,2) + rand(NRVB,n); Xtot=hcat(X,Xmiss); y=sum(Xtot,2) + rand(NRVB,n);
Check
@sk_import linear_model: LinearRegression; reg=LinearRegression(); (SKL.fit!(reg,X,Xmiss)) Xmisspred=SKL.predict(reg,X); print(sum(Xmisspred-Xmiss)/n)