
    =y!d!                     |    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)NuSVC)_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nu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                   3lib/python3.11/site-packages/sklearnex/svm/nusvc.pyr'   zNuSVC.__init__"   sS     	&uE[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.NuSVC.fitonedalsklearn)r   _validate_params_check_feature_namesr   r)   _onedal_fitsklearn_NuSVCfit)r(   Xysample_weights       r*   r8   z	NuSVC.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.NuSVC.predictr1   )r   r5   r   r)   _onedal_predictr7   predictr(   r9   s     r*   r?   zNuSVC.predict\   sa    $ !'' 	6%%au%5551n4$,4
 4
   	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NuSVC.predict_probau   s    8 	""r+   c                     t          d          r|                     |d           t          d          rt          j        nt          j        }t          | d| j        j        |d|          S )Nr-   Fr.   svm.NuSVC.predict_probar1   )r   r5   r7   rD   rC   r   r)   _onedal_predict_proba)r(   r9   sklearn_pred_probas      r*   rC   zNuSVC._predict_proba   s     '' 	6%%au%555!6u!=!=@m99#0#? 	 7n:):
 :
   	r+   c                     t          d          r|                     |d           t          | d| j        j        t
          j        d|          S )Nr-   Fr.   svm.NuSVC.decision_functionr1   )r   r5   r   r)   _onedal_decision_functionr7   decision_functionr@   s     r*   rL   zNuSVC.decision_function   s_     '' 	6%%au%555;n>$6>
 >
   	r+   c                     dS )NF r(   method_namedatas      r*   _onedal_gpu_supportedzNuSVC._onedal_gpu_supported   s    ur+   c                 L    |dk    r	| j         dv S |dv rt          | d          S d S )Nr0   )linearr   polysigmoid)r=   rF   rJ   _onedal_estimator)r   hasattrrO   s      r*   _onedal_cpu_supportedzNuSVC._onedal_cpu_supported   sJ    /));"FFF : : : 4!4555: :r+   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"   queuerN   )r   r   r   r   r   r   r   r   r!   r   r#   r"   onedal_NuSVCrW   r8   r   
_fit_proba_save_attributes)r(   r9   r:   r;   r\   onedal_paramss         r*   r6   zNuSVC._onedal_fit   s    'kkZZ8/ -/'+'C
 
 ".!>!>!>!>""1ae"DDD 	>OOAq-uO===r+   c                 :    | j                             ||          S Nr[   )rW   r?   r(   r9   r\   s      r*   r>   zNuSVC._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_offloadrN   )getattrr   _configrf   rg   re   rD   )r(   r9   r\   rf   rg   cfgs         r*   rG   zNuSVC._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 rb   )rW   rL   rc   s      r*   rK   zNuSVC._onedal_decision_function   s    %777GGGr+   )N)NN)__name__
__module____qualname__r7   __doc__r   r   dict__annotations__r
   r'   r8   r   r?   propertyrD   rC   rL   rR   rY   r6   r>   rG   rK   __classcell__)r)   s   @r*   r	   r	      s        #GU## P'O-*N'OOOO qdcU!	
' 
' 
' 
' 
' 
'  
'+ + + +Z   0 # # X#< 
 
 
     6 6 6       .> > > >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.svmr]   rN   r+   r*   <module>r|      s   " 9 8 8 8 8 8       8 8 8 8 8 8 8 8 . . . . . . ? ? ? ? ? ? - - - - - - , , , , , ,AH AH AH AH AHM7 AH AH AH AH AHr+   