<commit_before>//=======================================================================
// Copyright (c) 2014-2017 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "cpp_utils/stop_watch.hpp"

namespace dll {

struct predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->predict(image);
    }
};

#ifdef DLL_SVM_SUPPORT

struct svm_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->svm_predict(image);
    }
};

#endif //DLL_SVM_SUPPORT

struct deep_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->deep_predict(image, 5);
    }
};

struct label_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->predict_labels(image, 10);
    }
};

struct deep_label_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->deep_predict_labels(image, 10, 5);
    }
};

template <typename DBN, typename Functor, typename Samples, typename Labels>
double test_set(DBN& dbn, const Samples& images, const Labels& labels, Functor&& f) {
    return test_set(dbn, images.begin(), images.end(), labels.begin(), labels.end(), std::forward<Functor>(f));
}

template <typename DBN, typename Functor, typename Iterator, typename LIterator>
double test_set(DBN& dbn, Iterator first, Iterator last, LIterator lfirst, LIterator /*llast*/, Functor&& f) {
    size_t success = 0;
    size_t images  = 0;

    while (first != last) {
        const auto& image = *first;
        const auto& label = *lfirst;

        auto predicted = f(dbn, image);

        if (predicted == label) {
            ++success;
        }

        ++images;
        ++first;
        ++lfirst;
    }
<commit_msg>Get rid of legacy code<commit_after>//=======================================================================
// Copyright (c) 2014-2017 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "cpp_utils/stop_watch.hpp"

namespace dll {

struct predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->predict(image);
    }
};

#ifdef DLL_SVM_SUPPORT

struct svm_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->svm_predict(image);
    }
};

#endif //DLL_SVM_SUPPORT

struct label_predictor {
    template <typename T, typename V>
    size_t operator()(T& dbn, V& image) {
        return dbn->predict_labels(image, 10);
    }
};

template <typename DBN, typename Functor, typename Samples, typename Labels>
double test_set(DBN& dbn, const Samples& images, const Labels& labels, Functor&& f) {
    return test_set(dbn, images.begin(), images.end(), labels.begin(), labels.end(), std::forward<Functor>(f));
}

template <typename DBN, typename Functor, typename Iterator, typename LIterator>
double test_set(DBN& dbn, Iterator first, Iterator last, LIterator lfirst, LIterator /*llast*/, Functor&& f) {
    size_t success = 0;
    size_t images  = 0;

    while (first != last) {
        const auto& image = *first;
        const auto& label = *lfirst;

        auto predicted = f(dbn, image);

        if (predicted == label) {
            ++success;
        }

        ++images;
        ++first;
        ++lfirst;
    }

{'fraction_non_alphanumeric': 0.19559447983014863, 'fraction_numerical': 0.0074309978768577496, 'mean_word_length': 3.3723897911832945, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790610', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1144, 'n_words': 337}