Ë
    £�Dj�  ã                   óR   — d Z ddlmZ ddlZddlmZ  G d„ de«      Z G d„ d«      Zy)	zgBase classes for statistical test results

Created on Mon Apr 22 14:03:21 2013

Author: Josef Perktold
é    )ÚlzipN)ÚHolderc                   ó>   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zd„ Zdd„Zˆ xZ	S )	ÚHolderTuplez Holder class with indexing

    c                 ó˜   •‡ — t        ‰‰ �  di |¤Ž |�t        ˆ fd„|D «       «      ‰ _        y ‰ j                  ‰ j                  f‰ _        y )Nc              3   ó6   •K  — | ]  }t        ‰|«      –— Œ y ­w©N)Úgetattr)Ú.0ÚattÚselfs     €úZC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels\stats\base.pyú	<genexpr>z'HolderTuple.__init__.<locals>.<genexpr>   s   øè ø€ ÒD°cœw t¨S×1ÑDùs   ƒ© )ÚsuperÚ__init__ÚtupleÚ	statisticÚpvalue)r   Útuple_ÚkwdsÚ	__class__s   `  €r   r   zHolderTuple.__init__   s?   ù€ Ü‰ÑÑ ˜4Ò ØÐÜÓD¸VÔDÓDˆD�JàŸ.™.¨$¯+©+Ð6ˆD�Jó    c              #   ó8   K  — | j                   E d {  –—†  y 7 Œ­wr	   ©r   ©r   s    r   Ú__iter__zHolderTuple.__iter__   s   è ø€ Ø—:‘:×Òús   ‚’“c                 ó    — | j                   |   S r	   r   )r   Úidxs     r   Ú__getitem__zHolderTuple.__getitem__   s   € Ø�z‰z˜#‰Ðr   c                 ó,   — t        | j                  «      S r	   )Úlenr   r   s    r   Ú__len__zHolderTuple.__len__   s   € Ü�4—:‘:‹Ðr   c                 óX   — t        j                  t        | j                  «      ||¬«      S )N)ÚdtypeÚcopy)ÚnpÚarrayÚlistr   )r   r%   r&   s      r   Ú	__array__zHolderTuple.__array__!   s   € Ü�x‰xœ˜TŸZ™ZÓ(°¸DÔAÐAr   r	   )NT)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r    r#   r*   Ú__classcell__)r   s   @r   r   r      s"   ø„ ñõ7òòò÷Br   r   c                   ó6   — e Zd ZdZ	 	 dd„Zd	d„Zd„ Zd„ Zd„ Zy)
ÚAllPairsResultsa–  Results class for pairwise comparisons, based on p-values

    Parameters
    ----------
    pvals_raw : array_like, 1-D
        p-values from a pairwise comparison test
    all_pairs : list of tuples
        list of indices, one pair for each comparison
    multitest_method : str
        method that is used by default for p-value correction. This is used
        as default by the methods like if the multiple-testing method is not
        specified as argument.
    levels : {list[str], None}
        optional names of the levels or groups
    n_levels : None or int
        If None, then the number of levels or groups is inferred from the
        other arguments. It can be explicitly specified, if the inferred
        number is incorrect.

    Notes
    -----
    This class can also be used for other pairwise comparisons, for example
    comparing several treatments to a control (as in Dunnet's test).

    Nc           	      ó2  — || _         || _        |€t        j                  |«      dz   | _        n|| _        || _        || _        |€|D �cg c]  }|›‘Œ c}| _        y |D �cg c]   }dj                  ||d      ||d      «      ‘Œ" c}| _        y c c}w c c}w )Né   z{}-{}r   )	Ú	pvals_rawÚ	all_pairsr'   ÚmaxÚn_levelsÚmultitest_methodÚlevelsÚall_pairs_namesÚformat)r   r4   r5   r8   r9   r7   Úpairss          r   r   zAllPairsResults.__init__@   s«   € à"ˆŒØ"ˆŒØÐäŸF™F 9Ó-°Ñ1ˆD�Mà$ˆDŒMà 0ˆÔØˆŒØˆ>à*3ö$Ø!&�5�)‘ò$ˆDÕ ð  )ö$ð ð —‘Ø˜5 ™8Ñ$ f¨U°1©XÑ&6õò$ˆDÕ ùò	$ùò$s   Á

BÁ!%Bc                 óp   — ddl mc m} |€| j                  }|j	                  | j
                  |¬«      d   S )zºp-values corrected for multiple testing problem

        This uses the default p-value correction of the instance stored in
        ``self.multitest_method`` if method is None.

        r   N)Úmethodr3   )Ústatsmodels.stats.multitestÚstatsÚ	multitestr8   Úmultipletestsr4   )r   r>   Úsmts      r   Úpval_correctedzAllPairsResults.pval_correctedW   s9   € ÷ 	2Ð1Øˆ>Ø×*Ñ*ˆFà× Ñ  §¡¸Ð Ó?ÀÑBÐBr   c                 ó"   — | j                  «       S r	   )Úsummaryr   s    r   Ú__str__zAllPairsResults.__str__d   s   € Ø�|‰|‹~Ðr   c                 ó’   — | j                   }t        j                  ||f«      }| j                  «       |t	        | j
                  Ž <   |S )z�create a (n_levels, n_levels) array with corrected p_values

        this needs to improve, similar to R pairwise output
        )r7   r'   ÚzerosrD   r   r5   )r   ÚkÚ	pvals_mats      r   Ú
pval_tablezAllPairsResults.pval_tableg   sA   € ð
 �M‰MˆÜ—H‘H˜a ˜VÓ$ˆ	à+/×+>Ñ+>Ó+@ˆ	”$˜Ÿ™Ð'Ñ(ØÐr   c           	      ó*  — ddl mc m} t        d„ | j                  D «       «      }d|j
                  | j                     z  }|dd|dz
  dz   z  z   d	z   z  }|d
j                  d„ t        | j                  | j                  «       «      D «       «      z  }|S )z•returns text summarizing the results

        uses the default pvalue correction of the instance stored in
        ``self.multitest_method``
        r   Nc              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr	   )r"   )r   Ússs     r   r   z*AllPairsResults.summary.<locals>.<genexpr>y   s   è ø€ Ò> 2”s˜2—wÑ>ùó   ‚z0Corrected p-values using %s p-value correction

ÚPairsú é   r3   z	p-values
ú
c              3   ó2   K  — | ]  \  }}|› d |d›�–— Œ y­w)z  z6.4gNr   )r   r<   Úpvs      r   r   z*AllPairsResults.summary.<locals>.<genexpr>~   s'   è ø€ ò L±K°U¸B˜U˜G 2 b¨ YÔ/ñ LùrP   )
r?   r@   rA   r6   r:   Úmultitest_methods_namesr8   ÚjoinÚziprD   )r   rC   ÚmaxlevelÚtexts       r   rF   zAllPairsResults.summaryr   s¢   € ÷ 	2Ð1ÜÑ>¨×)=Ñ)=Ô>Ó>ˆàDØ×-Ñ-¨d×.CÑ.CÑDñEˆà�˜3 (¨Q¡,°Ñ"2Ñ3Ñ4°|ÑCÑCˆØ�—	‘	ñ LÜ˜d×2Ñ2°D×4GÑ4GÓ4IÓJôLó Lñ 	Lˆàˆr   )ÚhsNNr	   )	r+   r,   r-   r.   r   rD   rG   rL   rF   r   r   r   r1   r1   %   s*   „ ñð4 ?CØ'+óó.Còò	ór   r1   )	r.   Ústatsmodels.compat.pythonr   Únumpyr'   Ústatsmodels.tools.testingr   r   r1   r   r   r   ú<module>r`      s/   ðñõ +Û Ý ,ôB�&ô B÷2[ò [r   