




'''simple docstring'''



import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


UpperCAmelCase_				:     List[str]     			=						1_0_0_0_0_0_0_0_0_0_0_0
UpperCAmelCase_				:     List[str]     			=						1_0_0_0_0

UpperCAmelCase_			,    UpperCAmelCase_				:     Optional[int]     			=						os.path.split(__file__)
UpperCAmelCase_				:     Optional[int]     			=						os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))







def 	_UpperCamelCase       (_lowerCamelCase							:   int      ,		_lowerCamelCase							:   int		)->      datasets.Dataset:




     '''simple docstring'''





     __snake_case			    =     pa.Table.from_pydict({'''col''': [0] * chunk_size}		)
     __snake_case			    =     pa.concat_tables([table] * (num_examples // chunk_size)		)
     return datasets.Dataset(_lowerCamelCase      ,		fingerprint='''table_100B'''		)





@dataclass
class 			lowerCAmelCase      :
       __lowercase     :					int
       __lowercase     :					int
       __lowercase     :					int
       __lowercase     :					int


       def 					lowerCAmelCase					(      self     )					->     Any:



            '''simple docstring'''




            __snake_case			    =     np.random.default_rng(self.seed     )
            __snake_case			    =     rng.integers(low=self.low			,     high=self.high			,     size=self.size     ).tolist()


       def __iter__(      self     )					->     Tuple:



            '''simple docstring'''




            return iter(self._sampled_values     )




       def __len__(      self     )					->     List[Any]:



            '''simple docstring'''




            return self.size







@get_duration
def 	_UpperCamelCase       (_lowerCamelCase							:   datasets.Dataset		)->      List[Any]:




     '''simple docstring'''





     __snake_case			    =     dataset[0]







@get_duration
def 	_UpperCamelCase       (_lowerCamelCase							:   datasets.Dataset		)->      List[str]:




     '''simple docstring'''





     __snake_case			    =     dataset[-1]







@get_duration
def 	_UpperCamelCase       (_lowerCamelCase							:   datasets.Dataset		)->      List[str]:




     '''simple docstring'''





     __snake_case			    =     dataset[range(len(_lowerCamelCase		) // 2      ,		len(_lowerCamelCase		) // 2 + 10_24		)]







@get_duration
def 	_UpperCamelCase       (_lowerCamelCase							:   datasets.Dataset		)->      Dict:




     '''simple docstring'''





     __snake_case			    =     dataset[RandIter(0      ,		len(_lowerCamelCase		)      ,		10_24      ,		seed=42		)]







def 	_UpperCamelCase       ()->      List[str]:




     '''simple docstring'''





     __snake_case			    =     {'''num examples''': SPEED_TEST_N_EXAMPLES}
     __snake_case			    =     (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
     print('''generating dataset'''		)
     __snake_case			    =     generate_100B_dataset(num_examples=_lowerCamelCase      ,		chunk_size=_lowerCamelCase		)
     print('''Functions'''		)
     for func in functions:
          print(func.__name__		)
          __snake_case			    =     func(_lowerCamelCase		)

     with open(_lowerCamelCase      ,		'''wb'''		) as f:
          f.write(json.dumps(_lowerCamelCase		).encode('''utf-8'''		)		)


if __name__ == "__main__":  # useful to run the profiler
     benchmark_table_100B()












'''simple docstring'''



from sklearn.metrics import accuracy_score

import datasets


UpperCAmelCase_				:     List[Any]     			=						'''
Accuracy is the proportion of correct predictions among the total number of cases processed. It can be computed with:
Accuracy = (TP + TN) / (TP + TN + FP + FN)
 Where:
TP: True positive
TN: True negative
FP: False positive
FN: False negative
'''


UpperCAmelCase_				:     List[Any]     			=						'''
Args:
    predictions (`list` of `int`): Predicted labels.
    references (`list` of `int`): Ground truth labels.
    normalize (`boolean`): If set to False, returns the number of correctly classified samples. Otherwise, returns the fraction of correctly classified samples. Defaults to True.
    sample_weight (`list` of `float`): Sample weights Defaults to None.

Returns:
    accuracy (`float` or `int`): Accuracy score. Minimum possible value is 0. Maximum possible value is 1.0, or the number of examples input, if `normalize` is set to `True`.. A higher score means higher accuracy.

Examples:

    Example 1-A simple example
        >>> accuracy_metric = datasets.load_metric("accuracy")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0])
        >>> print(results)
        {\'accuracy\': 0.5}

    Example 2-The same as Example 1, except with `normalize` set to `False`.
        >>> accuracy_metric = datasets.load_metric("accuracy")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0], normalize=False)
        >>> print(results)
        {\'accuracy\': 3.0}

    Example 3-The same as Example 1, except with `sample_weight` set.
        >>> accuracy_metric = datasets.load_metric("accuracy")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0], sample_weight=[0.5, 2, 0.7, 0.5, 9, 0.4])
        >>> print(results)
        {\'accuracy\': 0.8778625954198473}
'''


UpperCAmelCase_				:     Union[str, Any]     			=						'''
@article{scikit-learn,
  title={Scikit-learn: Machine Learning in {P}ython},
  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.
         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.
         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and
         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},
  journal={Journal of Machine Learning Research},
  volume={12},
  pages={2825--2830},
  year={2011}
}
'''





@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION ,      _KWARGS_DESCRIPTION)
class 			lowerCAmelCase      (       datasets.Metric):


       def 					lowerCAmelCase					(      self     )					->     List[str]:



            '''simple docstring'''




            return datasets.MetricInfo(
                description=_DESCRIPTION			,     citation=_CITATION			,     inputs_description=_KWARGS_DESCRIPTION			,     features=datasets.Features(
                    {
                        '''predictions''': datasets.Sequence(datasets.Value('''int32'''     )     ),
                        '''references''': datasets.Sequence(datasets.Value('''int32'''     )     ),
                    }
                    if self.config_name == '''multilabel'''
                    else {
                        '''predictions''': datasets.Value('''int32'''     ),
                        '''references''': datasets.Value('''int32'''     ),
                    }     )			,     reference_urls=['''https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html''']			,     )




       def 					lowerCAmelCase					(      self			,     __SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE=True			,     __SCREAMING_SNAKE_CASE=None     )					->     Any:



            '''simple docstring'''




            return {
                "accuracy": float(
                    accuracy_score(__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE			,     normalize=__SCREAMING_SNAKE_CASE			,     sample_weight=__SCREAMING_SNAKE_CASE     )     )
            }






