Skip to content
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

[ENH] Log normal distribution #22 #214

Closed
wants to merge 9 commits into from

Conversation

bhavikar04
Copy link
Contributor

Reference Issues/PRs

#22

What does this implement/fix? Explain your changes.

Implemented a log normal probability distribution

Does your contribution introduce a new dependency? If yes, which one?

None

What should a reviewer concentrate their feedback on?

-energy method

Did you add any tests for the change?

no

Any other comments?

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the skpro root directory (not the CONTRIBUTORS.md). Common badges: code - fixing a bug, or adding code logic. doc - writing or improving documentation or docstrings. bug - reporting or diagnosing a bug (get this plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • [x ] The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

A few things about mechanics of making PR:

  • you have committed some pycache files, these should not be tracked. Your .gitignore might not be setup properly?
  • You are making changes to empirical and laplace too, is that by accident?

@bhavikar04
Copy link
Contributor Author

Hey,

In laplace I only changed a comment, empirical was by accident. I'll setup the .gitignore properly and make all the necessary changes soon. Apologies for the delay, I appreciate the review.

@@ -3,7 +3,9 @@
# copyright: skpro developers, BSD-3-Clause License (see LICENSE file)
# adapted from sktime

__all__ = ["Laplace", "Normal"]
__all__ = ["Log-Normal","Empirical", "Laplace", "Normal"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what state of the repository are you branching off from? This does not look like the most recent version, it looks like it is half a year old. Please make sure you update your fork regularly.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is still an issue with your pull request, you seem to be branching off a much earlier version of the repository. Make sure your fork is up to date, you can do that on GitHub by clicking "sync fork" at the top right.

That's why your changes are being shown as conflicting.
If you update your branch, it will probably throw a lot of merge errors.

I would recommend to update your main, and then start a new branch. Then, move only the lognormal file over, and make changes to __init__ again.

d = self.loc[x.index, x.columns]
mu_arr, sd_arr = d._mu, d._sigma

c_arr = x*(2*self.cdf(x)-1)-2*exp((mu_arr+sd_arr**2)/2)*(self.cdf((np.log(x)-mu_arr-sd_arr**2)/sd_arr)+self.cdf(sd_arr/mu_arr**0.5)-1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you kindly write down the formula in math, or explain otherwise how you are getting this expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, so this is basically the CRPS score which is E[IX-xI] -0.5E[|X-X'|] from which I was unable to isolate the first term. Wolfram alpha too wasnt able to produce a closed form for the integral. Can we change the description of the energy method accordingly or would you rather we go by the approximation in the base class?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we try to spend a short discussion on trying to see whether we can get somewhere. Removing it entirely is always an option.

A "trick" to isolate the first term is to observe that adding the same constant to x and X (so, the location parameter) should leave the formula unchanged.

Regarding the integral, which integral concretely are you feeding into Wolfram Alpha?

Copy link
Contributor Author

@bhavikar04 bhavikar04 Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes so this is what I got. If I try to add limits it crashes. Am I misinterpreting the integral?
Screenshot 2024-03-23 130300

Copy link
Collaborator

@fkiraly fkiraly Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks correct. Now you need to add the limits. That should be an easy substitution, no? I recommend, do that manually. Use that

$\lim_{x\rightarrow -\infty} \mbox{erf}(x) = -1$, and $\lim_{x\rightarrow \infty} \mbox{erf}(x) = 1$. You need to be careful with the sign, but that should be it?

The number 0.707 etc should be $\frac{1}{2} \sqrt{2}$, but it doesn't matter for the limits.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved discussion here: #219

@bhavikar04
Copy link
Contributor Author

@fkiraly please take a look. I haven't made any changes to empirical.py.

I think there is still an issue with your pull request, you seem to be branching off a much earlier version of the repository. Make sure your fork is up to date, you can do that on GitHub by clicking "sync fork" at the top right.

That's why your changes are being shown as conflicting. If you update your branch, it will probably throw a lot of merge errors.

I would recommend to update your main, and then start a new branch. Then, move only the lognormal file over, and make changes to __init__ again.

okay, I did that. Thank you

@fkiraly
Copy link
Collaborator

fkiraly commented Mar 23, 2024

okay, I did that. Thank you

I don't think that has worked, you need to resolve the conflicts:
image

Here is the GitHub guide on the topic:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github
Let me know if you need any help! We can do a screenshare.

@bhavikar04
Copy link
Contributor Author

okay, I did that. Thank you

I don't think that has worked, you need to resolve the conflicts: image

Here is the GitHub guide on the topic: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github Let me know if you need any help! We can do a screenshare.

No,no I havent committed the new branch yet, just made the changes locally. Was awaiting your response on the energy method dilemma. Thank you so much

@fkiraly
Copy link
Collaborator

fkiraly commented Mar 23, 2024

Was awaiting your response on the energy method dilemma. Thank you so much

Ensuring your PR is up-to-date and non-conflicting is a basic requirement for proper review, so I'd recommend not to wait with anything until you fix that.

@bhavikar04
Copy link
Contributor Author

Was awaiting your response on the energy method dilemma. Thank you so much

Ensuring your PR is up-to-date and non-conflicting is a basic requirement for proper review, so I'd recommend not to wait with anything until you fix that.

right so I'll make a new PR and close this one.

@fkiraly
Copy link
Collaborator

fkiraly commented Mar 24, 2024

Thanks.
This one looks good now: #218

I've moved the content regarding the energy function into this issue: #219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants