`L i dZddlmZddlZddlmZddlmZm Z m Z ddl m Z ddl mZmZe d d gd ge d d hgd geedddgddd ddddZy)z!Determination of parameter bounds)RealN)LabelBinarizer)Interval StrOptionsvalidate_params)safe_sparse_dot) check_arraycheck_consistent_lengthz array-likez sparse matrix squared_hingelogbooleanneither)closed)Xyloss fit_interceptintercept_scalingT)prefer_skip_nested_validationg?)rrrc &t|d}t||tdj|j}t j t jt||}|rt jt j|df|t j|j}t |tt j||j }|dk(r td|d k(rd |z Sd |z S) aReturn the lowest bound for `C`. The lower bound for `C` is computed such that for `C` in `(l1_min_C, infinity)` the model is guaranteed not to be empty. This applies to l1 penalized classifiers, such as :class:`sklearn.svm.LinearSVC` with penalty='l1' and :class:`sklearn.linear_model.LogisticRegression` with penalty='l1'. This value is valid if `class_weight` parameter in `fit()` is not set. For an example of how to use this function, see :ref:`sphx_glr_auto_examples_linear_model_plot_logistic_path.py`. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where `n_samples` is the number of samples and `n_features` is the number of features. y : array-like of shape (n_samples,) Target vector relative to X. loss : {'squared_hinge', 'log'}, default='squared_hinge' Specifies the loss function. With 'squared_hinge' it is the squared hinge loss (a.k.a. L2 loss). With 'log' it is the loss of logistic regression models. fit_intercept : bool, default=True Specifies if the intercept should be fitted by the model. It must match the fit() method parameter. intercept_scaling : float, default=1.0 When fit_intercept is True, instance vector x becomes [x, intercept_scaling], i.e. a "synthetic" feature with constant value equals to intercept_scaling is appended to the instance vector. It must match the fit() method parameter. Returns ------- l1_min_c : float Minimum value for C. Examples -------- >>> from sklearn.svm import l1_min_c >>> from sklearn.datasets import make_classification >>> X, y = make_classification(n_samples=100, n_features=20, random_state=42) >>> print(f"{l1_min_c(X, y, loss='squared_hinge', fit_intercept=True):.4f}") 0.0044 csc) accept_sparse) neg_label)dtypegzUIll-posed l1_min_c calculation: l1 will always select zero coefficients for this datar g?g@)r r r fit_transformTnpmaxabsr fullsizearrayrdot ValueError)rrrrrYdenbiass Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/svm/_bounds.pyl1_min_cr,s| AU+AAq!$221577A &&1-. /Cww WWQZO.bhh?P6Q6W6W #s266!T?+//12 cz 5   SySy)__doc__numbersrnumpyr preprocessingrutils._param_validationrrr utils.extmathr utils.validationr r r,r-r+r6s' *KK+CO ,^_e456#&tQYGH #' +$RUH Hr-