o
    tBh3
                     @   s   d dl Zd dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ e Ze
dZeejjd  Zee eje Zeje ZeeZe  G dd	 d	Zd
d Zdd Zdd Zdd Z dS )    N)assert_allclose)assert_array_almost_equal)check_random_state)	load_iris)
Perceptron   c                   @   s.   e Zd ZdddZdd Zdd Zdd	 Zd
S )MyPerceptron   c                 C   s
   || _ d S Nn_iter)selfr    r   /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sklearn/linear_model/tests/test_perceptron.py__init__   s   
zMyPerceptron.__init__c                 C   s   |j \}}tj|tjd| _d| _t| jD ],}t|D ]%}| || d || krA|  j|| ||  7  _|  j|| 7  _qqd S )N)dtypeg        r   )	shapenpzerosfloat64wbranger   predict)r   Xy	n_samples
n_featurestir   r   r   fit   s   
zMyPerceptron.fitc                 C   s   t || j| j S r
   )r   dotr   r   r   r   r   r   r   project$   s   zMyPerceptron.projectc                 C   s   t |}t | |S r
   )r   
atleast_2dsignr#   r"   r   r   r   r   '   s   
zMyPerceptron.predictN)r	   )__name__
__module____qualname__r   r    r#   r   r   r   r   r   r      s
    
r   c                  C   sD   t tfD ]} tdd dd}|| t || t}|dksJ qd S )Nd   F)max_itertolshufflegffffff?)r   X_csrr   r    r   score)dataclfr.   r   r   r   test_perceptron_accuracy,   s   r1   c                  C   sZ   t  } d| t dk< tdd}|t|  tddd d}|t|  t|j|j	  d S )Nr	      r   F)r*   r,   r+   )
r   copyr   r    r   r   r   r   coef_ravel)y_binclf1clf2r   r   r   test_perceptron_correctness4   s   
r:   c               	   C   sL   t dd} dD ]}tt t| | W d    n1 sw   Y  qd S )Nr)   )r*   )predict_probapredict_log_proba)r   pytestraisesAttributeErrorgetattr)r0   methr   r   r   test_undefined_methodsA   s   
rB   c                  C   s   t ddd} | tt t ddd}|tt | tt|ttks&J t ddtt}t dddtt}t|j|j t ddtt}t dddtt}t|j|j d	S )
z?Check that `l1_ratio` has an impact when `penalty='elasticnet'`r   
elasticnet)l1_ratiopenaltyg333333?l1)rE   r	   l2N)r   r    r   r   r.   r   r5   )r8   r9   clf_l1clf_elasticnetclf_l2r   r   r   test_perceptron_l1_ratioH   s   rK   )!numpyr   scipy.sparsesparsespr=   sklearn.utils._testingr   r   sklearn.utilsr   sklearn.datasetsr   sklearn.linear_modelr   irisrandom_statearanger/   r   indicesr,   r   targetr   
csr_matrixr-   sort_indicesr   r1   r:   rB   rK   r   r   r   r   <module>   s*    



