skpro
skpro copied to clipboard
[ENH] Adding an interface of `ngboost` to `skpro`
Reference Issues/PRs
Enhances #135
What does this implement/fix? Explain your changes.
This PR has added a way to use ngboost regressor
in skpro
.
Tested it using the following piece of code
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
#Load Boston housing dataset
data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
X = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
Y = raw_df.values[1::2, 2]
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2)
ngb = NGBoostRegressor()._fit(X_train, Y_train)
Y_preds = ngb._predict(X_test)
Y_dists = ngb._pred_dist(X_test)
# test Mean Squared Error
test_MSE = mean_squared_error(Y_preds, Y_test)
print('Test MSE', test_MSE)
# test Negative Log Likelihood
test_NLL = -Y_dists.logpdf(Y_test).mean()
print('Test NLL', test_NLL)
Does your contribution introduce a new dependency? If yes, which one?
NGBRegressor
has been added from the ngboost
package.
What should a reviewer concentrate their feedback on?
What modifications need to be done and some help on how to add get_test_params
function and the parameters to be sent via FITTED_PARAMS_TO_FORWARD
.
Did you add any tests for the change?
No
Any other comments?
PR checklist
For all contributions
- [x] 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 theCONTRIBUTORS.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 pluscode
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.