stepwise¶
In [ ]:
stepwise(estimator,
input_relation: (str, vDataFrame),
X: list,
y: str,
criterion: str = "bic",
direction: str = "backward",
max_steps: int = 100,
criterion_threshold: int = 3,
drop_final_estimator: bool = True,
x_order: str = "pearson",
print_info: bool = True,
show: bool = True,
ax=None,
**style_kwds,)
Uses the stepwise algorithm to find the most suitable number of features when fitting the estimator.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
estimator | object | ❌ | Vertica estimator with a fit method. This can be either a regressor or a binary classifier. Multiclass classifiers are not supported. |
input_relation | str / vDataFrame | ❌ | Input Relation. |
X | list | ❌ | List of the predictor columns. |
y | str | ❌ | Response Column. |
criterion | str | ✓ | Criterion used to evaluate the model.
|
direction | str | ✓ | How to start the stepwise search. Can be done 'backward' or 'forward'. |
max_steps | int | ✓ | The maximum number of steps to be considered. |
criterion_threshold | int | ✓ | Threshold used when comparing the models criterions. If the difference is lesser than the threshold then the current 'best' model is changed. |
drop_final_estimator | bool | ✓ | If set to True, the final estimator will be dropped. |
x_order | str | ✓ | How to preprocess X before using the stepwise algorithm.
|
print_info | bool | ✓ | If set to True, prints the model information at each step. |
show | bool | ✓ | If set to True, the Stepwise graphic will be drawn. |
ax | Matplotlib axes object | ✓ | The axes to plot on. |
**style_kwds | any | ✓ | Any optional parameter to pass to the Matplotlib functions. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [4]:
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression(name = "public.LR_titanic",
tol = 1e-4,
max_iter = 100,
solver = 'Newton')
from verticapy.learn.model_selection import stepwise
# backward
stepwise(model,
input_relation = "public.titanic",
X = ["age", "fare", "parch", "pclass",],
y = "survived",)
Out[4]:
In [5]:
# forward
stepwise(model,
input_relation = "public.titanic",
X = ["age", "fare", "parch", "pclass",],
y = "survived",
direction = "forward",)
Out[5]: