@param array $labels

@return array
972733
protected function getNormalLabels(array $labels)
    {
        $choices = [];
        foreach ($labels as $label) {
            $choices[$label] = ucfirst(str_replace(['-', '_'], ' ', $label));
        }

        return $choices;
    }
10584
protected function getLangPhrases(array $labels, array &$messagesToRegister)
    {
        $messages = [];

        foreach ($labels as $label) {
            if (!$this->isMessageExists($label->localeGroup, $label->lang) || $this->option('force')) {
                $messages[] = $this->getMessage($label);
                $messagesToRegister[$label->localeGroup] = $label->text;
            }
        }

        $glue = "," . PHP_EOL;

        return !isset($messages[0]) ? '' : implode($glue, $messages) . $glue;
    }
27986
public function generate(array $predictions, array $labels) : array
    {
        $n = count($predictions);

        if ($n !== count($labels)) {
            throw new InvalidArgumentException('The number of labels'
                . ' must equal the number of predictions.');
        }

        $classes = array_unique(array_merge($predictions, $labels));

        $k = count($classes);

        $truePos = $trueNeg = $falsePos = $falseNeg = array_fill_keys($classes, 0);

        foreach ($predictions as $i => $prediction) {
            $label = $labels[$i];

            if ($prediction === $label) {
                $truePos[$prediction]++;
                
                foreach ($classes as $class) {
                    if ($class !== $prediction) {
                        $trueNeg[$class]++;
                    }
                }
            } else {
                $falsePos[$prediction]++;
                $falseNeg[$label]++;
            }
        }

        $averages = array_fill_keys([
            'accuracy', 'precision', 'recall', 'specificity', 'negative_predictive_value',
            'false_discovery_rate', 'miss_rate', 'fall_out', 'false_omission_rate',
            'f1_score', 'mcc', 'informedness', 'markedness',
        ], 0.);

        $counts = array_fill_keys([
            'true_positives', 'true_negatives', 'false_positives', 'false_negatives',
        ], 0);

        $overall = array_replace($averages, $counts);

        $table = [];

        foreach ($truePos as $label => $tp) {
            $tn = $trueNeg[$label];
            $fp = $falsePos[$label];
            $fn = $falseNeg[$label];

            $accuracy = ($tp + $tn) / ($tp + $tn + $fp + $fn);
            $precision = $tp / (($tp + $fp) ?: EPSILON);
            $recall = $tp / (($tp + $fn) ?: EPSILON);
            $specificity = $tn / (($tn + $fp) ?: EPSILON);
            $npv = $tn / (($tn + $fn) ?: EPSILON);
            $cardinality = $tp + $fn;

            $f1score = 2. * (($precision * $recall))
                / (($precision + $recall) ?: EPSILON);

            $mcc = ($tp * $tn - $fp * $fn)
                / sqrt((($tp + $fp) * ($tp + $fn)
                * ($tn + $fp) * ($tn + $fn)) ?: EPSILON);

            $metrics = [];

            $metrics['accuracy'] = $accuracy;
            $metrics['precision'] = $precision;
            $metrics['recall'] = $recall;
            $metrics['specificity'] = $specificity;
            $metrics['negative_predictive_value'] = $npv;
            $metrics['false_discovery_rate'] = 1. - $precision;
            $metrics['miss_rate'] = 1. - $recall;
            $metrics['fall_out'] = 1. - $specificity;
            $metrics['false_omission_rate'] = 1. - $npv;
            $metrics['f1_score'] = $f1score;
            $metrics['mcc'] = $mcc;
            $metrics['informedness'] = $recall + $specificity - 1.;
            $metrics['markedness'] = $precision + $npv - 1.;
            $metrics['true_positives'] = $tp;
            $metrics['true_negatives'] = $tn;
            $metrics['false_positives'] = $fp;
            $metrics['false_negatives'] = $fn;
            $metrics['cardinality'] = $cardinality;
            $metrics['density'] = $cardinality / $n;

            $table[$label] = $metrics;

            $overall['accuracy'] += $accuracy;
            $overall['precision'] += $precision;
            $overall['recall'] += $recall;
            $overall['specificity'] += $specificity;
            $overall['negative_predictive_value'] += $npv;
            $overall['false_discovery_rate'] += 1. - $precision;
            $overall['miss_rate'] += 1. - $recall;
            $overall['fall_out'] += 1. - $specificity;
            $overall['false_omission_rate'] += 1. - $npv;
            $overall['f1_score'] += $f1score;
            $overall['mcc'] += $mcc;
            $overall['informedness'] += $recall + $specificity - 1.;
            $overall['markedness'] += $precision + $npv - 1.;
            $overall['true_positives'] += $tp;
            $overall['true_negatives'] += $tn;
            $overall['false_positives'] += $fp;
            $overall['false_negatives'] += $fn;
        }

        foreach (array_keys($averages) as $metric) {
            $overall[$metric] /= $k;
        }

        $overall['cardinality'] = $n;

        return [
            'overall' => $overall,
            'label' => $table,
        ];
    }
46277
public function format(array $labels = [])
    {
        return array_merge($this->options, [
            'data'       => $this->formatValues($labels),
            'seriesName' => $this->name,
            'renderAs'   => strtolower($this->type),
        ]);
    }
154849
public function setLabels(array $labels): TaxonomyInterface
    {
        if (isset($this->args['labels'])) {
            $this->args['labels'] = array_merge($this->args['labels'], $labels);
        } else {
            $this->args['labels'] = $labels;
        }

        return $this;
    }
1090647
public static function createFromLabels(iterable $labels): self
    {
        $hostLabels = [];
        foreach ($labels as $label) {
            $label = self::filterComponent($label);
            if (null === $label) {
                throw new TypeError('a label can not be null');
            }
            $hostLabels[] = $label;
        }

        return new self(implode(self::SEPARATOR, array_reverse($hostLabels)));
    }
112575
public function modelAsNode($labels = null)
    {
        if (is_null($labels))
        {
            return 'n';
        } elseif (is_array($labels))
        {
            $labels = reset($labels);
        }

        return mb_strtolower($labels);
    }
1028777
protected function labelsToRaw(array $labels)
    {
        $final = [];

        foreach ($labels as $label) {
            if ($label->isPlain) {
                return $label->text;
            }

            $final[$label->lang] = $label->text;
        }

        return (object) $final;
    }
508674
public function label($label = null)
    {
        if (null === $label) {
            return $this->label;
        }
        $this->label = $label;

        return $this;
    }
593177
public static function getLabelName($label)
    {
        if ($label === self::LABEL_OPTIONAL) {
            return 'optional';
        }

        if ($label === self::LABEL_REQUIRED) {
            return 'required';
        }

        if ($label === self::LABEL_REPEATED) {
            return 'repeated';
        }

        return null;
    }
363783
protected function getLabelsFromArray(array $items)
    {
        $labels = [];

        foreach ($items as $key => $label) {
            $lang = empty($key) || is_numeric($key) ? $this->defaultLang : $key;
            $labels[] = new Label($label, $this->localeGroup, false, $lang);
        }

        return $labels;
    }
599905
public function findColumn($label)
    {
        $column = false;
        foreach ($this->getColumns() as $col) {
            if ($col->getLabel() == $label) {
                $column = $col;
                break;
            }
        }

        return $column;
    }
1288623
private function resolveParameters($parameters, $data, $labels = false)
    {
        $resolved = [];
        /** @var ReflectionParameter $reflectionParameter */
        foreach ($parameters as $reflectionParameter) {
            /** @noinspection PhpAssignmentInConditionInspection */
            $parameter = $this->parseParameter($reflectionParameter, $data, $labels);
            if (!is_null($parameter)) {
                $resolved[] = $parameter;
                continue;
            }
            /** @noinspection PhpAssignmentInConditionInspection */
            if ($parameterClassName = $this->extractClassName($reflectionParameter)) {
                $resolved[] = static::make($parameterClassName);
                continue;
            }
            $resolved[] = null;
        }
        return $resolved;
    }
64893
private function parseArrayToCatalogFieldEntities(array $items)
    {
        $entities = [];
        foreach ($items as $elementType => $catalogItems) {
            $entities = array_merge($entities, $this->parseArrayToFieldEntities($catalogItems, $elementType));
        }
        return $entities;
    }
1162099
public function score(array $predictions, array $labels) : float
    {
        if (empty($predictions)) {
            return 0.;
        }

        if (count($predictions) !== count($labels)) {
            throw new InvalidArgumentException('The number of labels'
                . ' must equal the number of predictions.');
        }

        $classes = array_unique(array_merge($predictions, $labels));

        $truePos = $trueNeg = $falsePos = $falseNeg = array_fill_keys($classes, 0);

        foreach ($predictions as $i => $prediction) {
            $label = $labels[$i];

            if ($prediction === $label) {
                $truePos[$prediction]++;

                foreach ($classes as $class) {
                    if ($class !== $prediction) {
                        $trueNeg[$class]++;
                    }
                }
            } else {
                $falsePos[$prediction]++;
                $falseNeg[$label]++;
            }
        }

        return Stats::mean(
            array_map([$this, 'mcc'], $truePos, $trueNeg, $falsePos, $falseNeg)
        );
    }
915993
protected function parseRecordLabel($label)
    {
        $table = null;
        if (false !== strpos($label, '.')) {
            list($table, $label) = explode('.', $label, 2);
        }
        return array($table, $label);
    }
319896
public function updateFieldLabels(&$labels)
    {
        $labels['Style'] = _t(__CLASS__ . '.STYLE', 'Style');
        $labels['Options'] = _t(__CLASS__ . '.OPTIONS', 'Options');
        $labels['Enabled'] = _t(__CLASS__ . '.ENABLED', 'Enabled');
        $labels['Disabled'] = _t(__CLASS__ . '.DISABLED', 'Disabled');
        $labels['ListView'] = _t(__CLASS__ . '.LISTVIEW', 'List View');
        $labels['ListImages'] = _t(__CLASS__ . '.LISTIMAGES', 'List Images');
        $labels['ListTitle'] = _t(__CLASS__ . '.TITLE', 'List title');
        $labels['ShowImage'] = _t(__CLASS__ . '.SHOWIMAGE', 'Show image');
        $labels['ShowHeader'] = _t(__CLASS__ . '.SHOWHEADER', 'Show header');
        $labels['ShowDetails'] = _t(__CLASS__ . '.SHOWDETAILS', 'Show details');
        $labels['ShowSummary'] = _t(__CLASS__ . '.SHOWSUMMARY', 'Show summary');
        $labels['ShowContent'] = _t(__CLASS__ . '.SHOWCONTENT', 'Show content');
        $labels['ShowFooter'] = _t(__CLASS__ . '.SHOWFOOTER', 'Show footer');
        $labels['LinkTitles'] = _t(__CLASS__ . '.LINKTITLES', 'Link titles');
        $labels['LinkImages'] = _t(__CLASS__ . '.LINKIMAGES', 'Link images');
        $labels['ButtonIcon'] = _t(__CLASS__ . '.BUTTONLABEL', 'Button icon');
        $labels['ButtonLabel'] = _t(__CLASS__ . '.BUTTONLABEL', 'Button label');
        $labels['HeadingLevel'] = _t(__CLASS__ . '.HEADINGLEVEL', 'Heading level');
        $labels['ItemsPerPage'] = _t(__CLASS__ . '.ITEMSPERPAGE', 'Items per page');
        $labels['PaginateItems'] = _t(__CLASS__ . '.PAGINATEITEMS', 'Paginate items');
        $labels['ImageLinksTo'] = _t(__CLASS__ . '.IMAGELINKSTO', 'Image links to');
        $labels['ImageResize'] = _t(__CLASS__ . '.IMAGEDIMENSIONS', 'Image dimensions');
        $labels['ImageResizeMethod'] = _t(__CLASS__ . '.IMAGERESIZEMETHOD', 'Image resize method');
        $labels['ImageAlignment'] = _t(__CLASS__ . '.IMAGEALIGNMENT', 'Image alignment');
        $labels['TextAlignment'] = _t(__CLASS__ . '.TEXTALIGNMENT', 'Text alignment');
        $labels['OverlayImages'] = _t(__CLASS__ . '.OVERLAYIMAGES', 'Overlay images');
        $labels['OverlayTitle'] = _t(__CLASS__ . '.SHOWTITLEINOVERLAY', 'Show title in overlay');
        $labels['OverlayIcon'] = _t(__CLASS__ . '.OVERLAYICON', 'Overlay icon');
        $labels['OverlayIconColor'] = _t(__CLASS__ . '.OVERLAYICONCOLOR', 'Overlay icon color');
        $labels['OverlayBackground'] = _t(__CLASS__ . '.OVERLAYBACKGROUNDCOLOR', 'Overlay background color');
        $labels['OverlayForeground'] = _t(__CLASS__ . '.OVERLAYFOREGROUNDCOLOR', 'Overlay foreground color');
        $labels['NumberOfItems'] = _t(__CLASS__ . '.NUMBEROFITEMS', 'Number of items');
        $labels['ReverseItems'] = _t(__CLASS__ . '.REVERSEITEMS', 'Reverse items');
        $labels['ImageItems'] = _t(__CLASS__ . '.IMAGEITEMS', 'Show only items with images');
        $labels['ListClass'] = _t(__CLASS__ . '.LISTCLASS', 'List class');
        $labels['ListInherit'] = _t(__CLASS__ . '.INHERITFROMPARENT', 'Inherit from parent');
        $labels['ListInheritance'] = _t(__CLASS__ . '.LISTINHERITANCE', 'List Inheritance');
        $labels['HideNoDataMessage'] = _t(__CLASS__ . '.HIDENODATAMESSAGE', 'Hide "no data" message');
        $labels['HideListTitle'] = _t(__CLASS__ . '.HIDETITLE', 'Hide list title');
    }