watex.utils.plot_regularization_path#
- watex.utils.plot_regularization_path(X, y, c_range=(- 4.0, 6.0), fig_size=(8, 5), sns_style=False, savefig=None, **kws)[source]#
Plot the regularisation path from Logit / LogisticRegression
Varying the different regularization strengths and plot the weight coefficient of the different features for different regularization strength.
Note that, it is recommended to standardize the data first.
- Parameters
X (array-like of shape (n_samples, n_features)) – Training vector, where n_samples is the number of samples and n_features is the number of features. X is expected to be standardized.
y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target relative to X for classification or regression; None for unsupervised learning.
c_range (list or tuple [start, stop]) – Regularization strength list. It is a range from the strong strong ( start) to lower (stop) regularization. Note that ‘C’ is the inverse of the Logistic Regression regularization parameter \(\lambda\).
fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height
savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.
sns_style (str, optional,) – the seaborn style.
kws (dict,) – Additional keywords arguments passed to
sklearn.linear_model.LogisticRegression
Examples
>>> from watex.utils.plotutils import plot_regularization_path >>> from watex.datasets import fetch_data >>> X, y = fetch_data ('bagoue analysed' ) # data aleardy standardized >>> plot_regularization_path (X, y )