-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add regression plots [WIP] #14
base: master
Are you sure you want to change the base?
Conversation
I also ended up adding a miminimzation for 1st and 2nd order polynomials if that is wanted? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! In principle i really like the idea. Needs a bit more work though. I've added some comments accordingly
@@ -283,6 +287,41 @@ func (r *Regression) String() string { | |||
return str | |||
} | |||
|
|||
//Plot regression and return file path where its saved | |||
func (r *Regression) Plot() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should:
- return the
err
instead of panicking. - allow the user to specify where to save the file
- needs to be more configurable in general. e.g. only the first two vars are plotted. What if there are more?
|
||
p, err := plot.New() | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err instead of panic
"Observed", observed, | ||
"Predicted", predicted) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err instead of panic
panic(err) | ||
} | ||
if err := p.Save(4*vg.Inch, 4*vg.Inch, "points.png"); err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err instead of panic
panic(err) | ||
} | ||
p.Title.Text = r.GetObserved() | ||
p.X.Label.Text = r.GetVar(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The var numbers are hardcoded to 0 and 1, but what if there are > 2 vars?
Hi @mish15 and @domenicrosati. I'm going to use this project in my master thesis as a lib. I'M going to need plotting... So since this PR is not completed for a long time, may I continue to work on different PR and contribute to you?. Thanks! |
@olimpias yes of course! |
|
@olimpias yeah i guess in general each variable needs to be plotted against Y. Potentially it would also be useful to see X1 against Xn, but that's less important. |
Made this WIP while I was working on something else.
If this is interesting I can polish it up and test it.
Just let me know