
    =y!dE$                     |    d dl mZ ddlmZ ddlmZmZ d dlmZ	 d dl
mZ d dlmZ d dlmZ  G d	 d
e	e          ZdS )    )sklearn_check_version   )BaseSVC   )dispatchwrap_output_data)SVC)_deprecate_positional_args)NotFittedErrorc                       e Zd ZU ej        Z ed          ri ej        Zeed<   e	ddddddd	d
ddd	ddd	dd fd
            Z
ddZed             Zed             Zed             Zed             Zd Zd ZddZddZddZddZ xZS )r	   1.2_parameter_constraintsg      ?rbf   scaleg        TFgMbP?   NovrCkerneldegreegammacoef0	shrinkingprobabilitytol
cache_sizeclass_weightverbosemax_iterdecision_function_shape
break_tiesrandom_statec                h    t                                          |||||||||	|
|||||           d S )Nr   )super__init__)selfr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   	__class__s                   1lib/python3.11/site-packages/sklearnex/svm/svc.pyr'   zSVC.__init__"   sS     	vU%[cj%w$;
% 	 	' 	' 	' 	' 	'    c                     t          d          r|                                  t          d          r|                     |d           t          | d| j        j        t          j        d|||           | S )a  
        Fit the SVM model according to the given training data.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)                 or (n_samples, n_samples)
            Training vectors, where `n_samples` is the number of samples
            and `n_features` is the number of features.
            For kernel="precomputed", the expected shape of X is
            (n_samples, n_samples).

        y : array-like of shape (n_samples,)
            Target values (class labels in classification, real numbers in
            regression).

        sample_weight : array-like of shape (n_samples,), default=None
            Per-sample weights. Rescale C per sample. Higher weights
            force the classifier to put more emphasis on these points.

        Returns
        -------
        self : object
            Fitted estimator.

        Notes
        -----
        If X and y are not C-ordered and contiguous arrays of np.float64 and
        X is not a scipy.sparse.csr_matrix, X and/or y may be copied.

        If X is a dense array, then the other methods will not support sparse
        matrices as input.
        r   1.0Tresetsvm.SVC.fitonedalsklearn)r   _validate_params_check_feature_namesr   r)   _onedal_fitsklearn_SVCfit)r(   Xysample_weights       r*   r8   zSVC.fit/   s    D !'' 	$!!### '' 	5%%at%444}n0"'
 '
 a	  	  	  r+   c                     t          d          r|                     |d           t          | d| j        j        t
          j        d|          S )a  
        Perform regression on samples in X.

        For an one-class model, +1 (inlier) or -1 (outlier) is returned.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            For kernel="precomputed", the expected shape of X is
            (n_samples_test, n_samples_train).

        Returns
        -------
        y_pred : ndarray of shape (n_samples,)
            The predicted values.
        r-   Fr.   svm.SVC.predictr1   )r   r5   r   r)   _onedal_predictr7   predictr(   r9   s     r*   r?   zSVC.predict[   sa    $ !'' 	6%%au%555/n4"*2
 2
   	r+   c                 8    |                                   | j        S )a  
        Compute probabilities of possible outcomes for samples in X.

        The model need to have probability information computed at training
        time: fit with attribute `probability` set to True.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            For kernel="precomputed", the expected shape of X is
            (n_samples_test, n_samples_train).

        Returns
        -------
        T : ndarray of shape (n_samples, n_classes)
            Returns the probability of the sample for each class in
            the model. The columns correspond to the classes in sorted
            order, as they appear in the attribute :term:`classes_`.

        Notes
        -----
        The probability model is created using cross validation, so
        the results can be slightly different than those obtained by
        predict. Also, it will produce meaningless results on very small
        datasets.
        )_check_proba_predict_proba)r(   s    r*   predict_probazSVC.predict_probat   s    8 	""r+   c                     t          d          rt          j        nt          j        }t	          | d| j        j        |d|          S )Nr-   svm.SVC.predict_probar1   )r   r7   rD   rC   r   r)   _onedal_predict_proba)r(   r9   sklearn_pred_probas      r*   rC   zSVC._predict_proba   sZ     "7u!=!=>k77#.#= 	 5n:)8
 8
   	r+   c                     t          d          r|                     |d           t          | d| j        j        t
          j        d|          S )Nr-   Fr.   svm.SVC.decision_functionr1   )r   r5   r   r)   _onedal_decision_functionr7   decision_functionr@   s     r*   rL   zSVC.decision_function   s_     '' 	6%%au%5559n>"4<
 <
   	r+   c                    |dk    rt          |          dk    rWdd l}ddlm} t          |                    |d                             | _        |                    |d                   | _        | j        dv o;| j	        d u o2t          | d          o"| j        dk    ot          | d          o| j         S |d	v rt          | d
          o | j        dg|R  S t          d| d| j        j                   )Nr0   r   r   )sparse)linearr   _class_countr   
_is_sparser=   rF   rJ   _onedal_estimatorUnknown method  in )lennumpyscipyrN   uniquerP   
isspmatrixrQ   r   r   hasattr_onedal_gpu_supportedRuntimeErrorr)   __name__)r(   method_namedatanpsps        r*   r\   zSVC._onedal_gpu_supported   sH   -''4yy1}}""""......$'		$q'(:(:$;$;!"$--Q"8"8;"33 D!T)Dn--D262Cq2HD l++D 59O0CD  8 8 8 4!455 A**=@4@@@AW[WWdn>UWWXXXr+   c                     |dk    r	| j         dv S |dv rt          | d          S t          d| d| j        j                   )Nr0   )rO   r   polysigmoidrR   rS   rT   rU   )r   r[   r]   r)   r^   )r(   r_   r`   s      r*   _onedal_cpu_supportedzSVC._onedal_cpu_supported   sd    -'';"FFF 8 8 8 4!4555W[WWdn>UWWXXXr+   c                 b   | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        d}t          di || _        | j                            ||||           | j        r|                     ||||           |                                  d S )N)r   r   r   r   r   r   r   r   r!   r   r#   r"   queue )r   r   r   r   r   r   r   r   r!   r   r#   r"   
onedal_SVCrS   r8   r   
_fit_proba_save_attributes)r(   r9   r:   r;   ri   onedal_paramss         r*   r6   zSVC._onedal_fit   s    kkZZ8/ -/'+'C
 
 ",!<!<m!<!<""1ae"DDD 	>OOAq-uO===r+   c                 :    | j                             ||          S Nrh   )rS   r?   r(   r9   ri   s      r*   r>   zSVC._onedal_predict   s    %--au-===r+   c                     t          | dd           t          d          ddlm}m}  |            }||d<    |di |5  | j                            |          cd d d            S # 1 swxY w Y   d S )Nclf_probzApredict_proba is not available when fitted with probability=Falser   )
get_configconfig_contexttarget_offloadrj   )getattrr   _configrt   ru   rs   rD   )r(   r9   ri   rt   ru   cfgs         r*   rG   zSVC._onedal_predict_proba   s    4T**2 SU U U88888888 jll %^""c"" 	2 	2=..q11	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s    A''A+.A+c                 :    | j                             ||          S rp   )rS   rL   rq   s      r*   rK   zSVC._onedal_decision_function   s    %777GGGr+   )N)NN)r^   
__module____qualname__r7   __doc__r   r   dict__annotations__r
   r'   r8   r   r?   propertyrD   rC   rL   r\   rf   r6   r>   rG   rK   __classcell__)r)   s   @r*   r	   r	      s        !GU## N'M+*L'MMMMawdcU!	
' 
' 
' 
' 
' 
'  
'* * * *X   0 # # X#<      Y Y Y&Y Y Y       .> > > >2 2 2 2H H H H H H H Hr+   r	   N)daal4py.sklearn._utilsr   _commonr   _device_offloadr   r   sklearn.svmr	   r7   sklearn.utils.validationr
   sklearn.exceptionsr   
onedal.svmrk   rj   r+   r*   <module>r      s   " 9 8 8 8 8 8       8 8 8 8 8 8 8 8 * * * * * * ? ? ? ? ? ? - - - - - - ( ( ( ( ( (OH OH OH OH OH+w OH OH OH OH OHr+   