<commit_before>#ifndef BNI_EVALUATION_BASIC_INFO_CRITERIA_HPP
#define BNI_EVALUATION_BASIC_INFO_CRITERIA_HPP

#include <cstdint>
#include <numeric>
#include <boost/optional.hpp>
#include <bayesian/graph.hpp>
#include <bayesian/sampler.hpp>
#include <bayesian/evaluation/basic_evaluation.hpp>

namespace bn {
namespace evaluation {

class basic_info_criteria : basic_evaluation{
public:
    basic_info_criteria(std::string const& file);

    // API
    virtual double operator() (graph_t const& graph) const = 0;

protected:
    // AIC/MDL: lbg[N\̓K؂Ɋւ鍀
    // - log P_theta^N(D)
    double calc_likelihood(graph_t const& graph) const;

    // AIC/MDL: lbg[N\̕GɊւ鍀
    // + d
    double calc_parameters(graph_t const& graph) const;
    
    // Samplinggetter
    boost::optional<std::size_t> const& sampling_size() const;

private:
    sampler const loader_;
    std::string const file_;
};

basic_info_criteria::basic_info_criteria(std::string const& file)
    : loader_(), file_(file)
{
}

double basic_info_criteria::calc_likelihood(graph_t const& graph) const
{
    double likelihood = 0.0;

    // Tv1sǂݍ
    loader_.load_sample(
        graph, file_,
        [&likelihood, &graph](condition_t const& sample)
        {
            condition_t cond = sample;

            // em[hɑ΂
            for(auto const& node : graph.vertex_list())
            {
				for (auto it = cond.begin(); it != cond.end();)
				{
					auto const& parent = graph.in_vertexes(node);<commit_msg>a bug in basic_info_criteria::calc_likelihood is repaired.<commit_after>#ifndef BNI_EVALUATION_BASIC_INFO_CRITERIA_HPP
#define BNI_EVALUATION_BASIC_INFO_CRITERIA_HPP

#include <cstdint>
#include <numeric>
#include <boost/optional.hpp>
#include <bayesian/graph.hpp>
#include <bayesian/sampler.hpp>
#include <bayesian/evaluation/basic_evaluation.hpp>

namespace bn {
namespace evaluation {

class basic_info_criteria : basic_evaluation{
public:
    basic_info_criteria(std::string const& file);

    // API
    virtual double operator() (graph_t const& graph) const = 0;

protected:
    // AIC/MDL: lbg[N\̓K؂Ɋւ鍀
    // - log P_theta^N(D)
    double calc_likelihood(graph_t const& graph) const;

    // AIC/MDL: lbg[N\̕GɊւ鍀
    // + d
    double calc_parameters(graph_t const& graph) const;
    
    // Samplinggetter
    boost::optional<std::size_t> const& sampling_size() const;

private:
    sampler const loader_;
    std::string const file_;
};

basic_info_criteria::basic_info_criteria(std::string const& file)
    : loader_(), file_(file)
{
}

double basic_info_criteria::calc_likelihood(graph_t const& graph) const
{
    double likelihood = 0.0;

    // Tv1sǂݍ
    loader_.load_sample(
        graph, file_,
        [&likelihood, &graph](condition_t const& sample)
        {
            // em[hɑ΂
            for(auto const& node : graph.vertex_list())
            {
                condition_t cond = sample;
				for (auto it = cond.begin(); it != cond.end();)
				{
					auto const& parent = graph.in_vertexes(node);
{'fraction_non_alphanumeric': 0.12083888149134488, 'fraction_numerical': 0.002663115845539281, 'mean_word_length': 3.3932748538011697, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4253152', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1079, 'n_words': 214}