#pragma once
#ifndef METRICS_H
#define METRICS_H



#include <vector>
#include "matrix.h"
#include "abc.h"
#include <map>

namespace metrics
{
    namespace pairwise
    {
        typedef data_t(*dist_fptr)(const data_t* x, const data_t* y, size_t  size);
        enum Metric { MANHATTAN, EUCLIDEAN, SQUARED_EUCLIDEAN};
		const vector<std::string> METRIC_NAMES = { "MANHATTAN", "EUCLIDEAN", "SQUARED_EUCLIDEAN" };
        data_t manhattan_distance(const data_t* x, const data_t* y, size_t  size);
        data_t euclidean_distance(const data_t* x, const data_t* y, size_t  size);
        data_t squared_euclidean_distance(const data_t* x, const data_t* y, size_t  size);
        dist_fptr distance(Metric metric_type);
    }

    namespace classification
    {
		typedef Matrix<size_t> CONF_MAT;
        typedef score_t(*multiclass_metric_fptr)(const vector<label_t>& y_true, const vector<label_t>& y_pred);
		enum Score { ACCURACY, F1_MACRO, F1_MICRO};
		const vector<std::string> SCORE_NAMES = { "ACCURACY", "F1_MACRO", "F1_MICRO" };
        void _check_targets(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        //key - label, value score
        vector<score_t>  precision(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        vector<score_t>  recall(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        vector<score_t>  f1_score(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        //single value
        score_t accuracy(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        score_t f1_macro(const vector<label_t>& y_true, const vector<label_t>& y_pred);
        score_t f1_micro(const vector<label_t>& y_true, const vector<label_t>& y_pred);
		multiclass_metric_fptr get_score_func(Score score_type);
        //confusion matrix, first axis - true values, second - predicted
        CONF_MAT confusion_matrix(const vector<label_t>& y_true, const vector<label_t>& y_pred);
		std::string make_report(const vector<label_t>& y_true, const vector<label_t>& y_pred);
    }
}



#endif