jlevy44 / InteractionTransformer

Extract meaningful interactions from machine learning models to obtain machine-learning performance with statistical model interpretability.
MIT License
7 stars 2 forks source link

XGBoostRegressor #1

Closed jyayoub closed 4 years ago

jyayoub commented 4 years ago

Hello, I am trying to use your transformer for XGBoostRegressor but I keep on receiving the following error : Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead.
Do you have any suggestions on how to solve this problem?

jlevy44 commented 4 years ago

Thanks for the github issue. Can you post the full error and what line it occurred in? Also what command did you run, could have been a particular parameter that was set incorrectly. This seems like it should be a relatively easy fix.

jyayoub commented 4 years ago

Thank you so much for replying that quickly!! I was confused on what to change in the interactiontransformer function, if is possible to provide some hints on the general form of the function. This is the code: from xgboost import XGBRegressor transformer=InteractionTransformer(untrained_model=XGBRegressor(random_state=42)) transformer.fit(X_train,y_train)

This is the error:


ValueError Traceback (most recent call last)

in () 1 from xgboost import XGBRegressor 2 transformer=InteractionTransformer(untrained_model=XGBRegressor(random_state=42))----> 3 transformer.fit(X_train,y_train) ------------------------------ 5 frames ------------------------------ /usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py in _make_test_folds(self, X, y) 644 raise ValueError( 645 'Supported target types are: {}. Got {!r} instead.'.format(--> 646 allowed_target_types, type_of_target_y)) 647 648 y = column_or_1d(y) ValueError: Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead. Thanks, Jackie On Tue, May 19, 2020 at 10:55 PM Joshua Levy wrote: > Thanks for the github issue. Can you post the full error and what line it > occurred in? Also what command did you run, could have been a particular > parameter that was set incorrectly. This seems like it should be a > relatively easy fix. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . >
jlevy44 commented 4 years ago

Ah okay. So I would add a keyword argument, and change cv_scoring to “r2” or “mae”, right now it’s trying to use the auc score to evaluate your model

jlevy44 commented 4 years ago

See https://github.com/jlevy44/InteractionTransformer/blob/master/interactiontransformer/InteractionTransformer.py#L66

jlevy44 commented 4 years ago

Regression targets have been a new addition, we’ll have to update our documentation to reflect this. Definitely let me know if you run into any issues!

jyayoub commented 4 years ago

How will I be able to change the cv_scoring to “r2” if I am using googlecolab? I tried this : from xgboost import XGBRegressor transformer=InteractionTransformer(untrained_model=XGBRegressor(random_state=42), max_train_test_samples=416, cv_splits=10, cv_scoring='r2') transformer.fit(X_train,y_train) I still have the same error:

ValueError Traceback (most recent call last)

in () 1 from xgboost import XGBRegressor 2 transformer=InteractionTransformer(untrained_model=XGBRegressor(random_state=42), max_train_test_samples=416, cv_splits=10, cv_scoring='r2') ----> 3 transformer.fit(X_train,y_train) 5 frames /usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py in _make_test_folds(self, X, y) 644 raise ValueError( 645 'Supported target types are: {}. Got {!r} instead.'.format( --> 646 allowed_target_types, type_of_target_y)) 647 648 y = column_or_1d(y) ValueError: Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead.
jlevy44 commented 4 years ago

Ok, try it now @jyayoub , you can install the updated version from source, let me know if it fails anywhere and I will debug:

pip install git+https://github.com/jlevy44/InteractionTransformer.git
jyayoub commented 4 years ago

I installed the updated version but now I have a new error:

ValueError Traceback (most recent call last)

in () ----> 1 transformer.fit(X_train,y_train) 4 frames /usr/local/lib/python3.6/dist-packages/pandas/core/internals/construction.py in prep_ndarray(values, copy) 293 values = values.reshape((values.shape[0], 1)) 294 elif values.ndim != 2: --> 295 raise ValueError("Must pass 2-d input") 296 297 return values ValueError: Must pass 2-d input
jlevy44 commented 4 years ago

Ok, I will work out the bug. Thanks for bringing this up, much appreciated!

If you can, can you show me a few more lines of the error? Thanks!

jyayoub commented 4 years ago

[01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:58] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror. [01:52:59] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.

ValueError Traceback (most recent call last)

in () ----> 1 transformer.fit(X_train,y_train) 4 frames /usr/local/lib/python3.6/dist-packages/pandas/core/internals/construction.py in prep_ndarray(values, copy) 293 values = values.reshape((values.shape[0], 1)) 294 elif values.ndim != 2: --> 295 raise ValueError("Must pass 2-d input") 296 297 return values ValueError: Must pass 2-d input
jlevy44 commented 4 years ago

Ok, @jyayoub , try now!

jyayoub commented 4 years ago

Thanks! It is working now.

jlevy44 commented 4 years ago

Great, glad to hear that it is working. We will push an update soon to add it as a standard part of our software distribution.