<commit_before>/** @file sg_gp_regression_dev.h
 *
 *  @brief An implementation of "Sparse Greedy Gaussian Process
 *         regression" by Smola et al.
 *
 *  @author <NAME> (<EMAIL>)
 */

#ifndef MLPACK_GP_REGRESSION_SG_GP_REGRESSION_DEV_H
#define MLPACK_GP_REGRESSION_SG_GP_REGRESSION_DEV_H

#include "sg_gp_regression.h"

namespace ml {
namespace gp_regression {

template<typename CovarianceType>
double SparseGreedyGprModel::PredictMean(
  const CovarianceType &covariance,
  const Vector &point) const {

  // Get the indices of the points in the dictionary.
  const std::vector<int> &point_indices_in_dictionary =
    dictionary_for_error_.point_indices_in_dictionary();

  // Compute the kernel values with the basis points and take the dot
  // product with the coefficients.
  Vector kernel_values;
  ComputeKernelValues_(
    covariance, point_indices_in_dictionary, point, &kernel_values);

  return la::Dot(kernel_values, coefficients_);
}

template<typename CovarianceType>
double SparseGreedyGprModel::PredictVariance(
  const CovarianceType &covariance,
  const Vector &point) const {

  // Get the indices of the points in the dictionary.
  const std::vector<int> &point_indices_in_dictionary =
    dictionary_for_error_.point_indices_in_dictionary();

  // The variance is self-correlation minus the variance explained by
  // the sparse GPR model.
  Vector kernel_values;
  ComputeKernelValues_(
    covariance, point_indices_in_dictionary, point, &kernel_values);

}

void SparseGreedyGprModel::FinalizeModel() {
  Vector weighted_target_subset;
  ExtractWeightedTargetSubset_(
    dictionary_in, kernel_values_in, &weighted_target_subset);
  SolveSystem_(dictionary_, weighted_target_subset, &coefficients);
}

double SparseGreedyGprModel::frobenius_norm_targets() const {
  return frobenius_norm_targets_;
}
<commit_msg>Smola's method should be complete.<commit_after>/** @file sg_gp_regression_dev.h
 *
 *  @brief An implementation of "Sparse Greedy Gaussian Process
 *         regression" by Smola et al.
 *
 *  @author <NAME> (<EMAIL>)
 */

#ifndef MLPACK_GP_REGRESSION_SG_GP_REGRESSION_DEV_H
#define MLPACK_GP_REGRESSION_SG_GP_REGRESSION_DEV_H

#include "sg_gp_regression.h"

namespace ml {
namespace gp_regression {

template<typename CovarianceType>
double SparseGreedyGprModel::PredictMean(
  const CovarianceType &covariance,
  const Vector &point) const {

  // Get the indices of the points in the dictionary.
  const std::vector<int> &point_indices_in_dictionary =
    dictionary_for_error_.point_indices_in_dictionary();

  // Compute the kernel values with the basis points and take the dot
  // product with the coefficients.
  Vector kernel_values;
  ComputeKernelValues_(
    covariance, point_indices_in_dictionary, point, &kernel_values);

  return la::Dot(kernel_values, coefficients_);
}

template<typename CovarianceType>
double SparseGreedyGprModel::PredictVariance(
  const CovarianceType &covariance,
  const Vector &point) const {

  // Get the indices of the points in the dictionary.
  const std::vector<int> &point_indices_in_dictionary =
    dictionary_for_error_.point_indices_in_dictionary();

  // The variance is self-correlation minus the variance explained by
  // the sparse GPR model.
  Vector kernel_values;
  ComputeKernelValues_(
    covariance, point_indices_in_dictionary, point, &kernel_values);
  Vector left_hand_side;
  SolveSystem_(dictionary_for_error_, kernel_values, &left_hand_side);
  double dot_product = la::Dot(left_hand_side, dot_product);
  double self_correlation = covariance.NormSq(point);
  return self_correlation - dot_product;
}

void SparseGreedyGprModel::FinalizeModel() {
  Vector weighted_target_subset;
  ExtractWeightedTargetSubset_(
    dictionary_in, kernel_values_in, &weighted_target_subset);
  SolveSystem_(dictionary_, weighted_target_subset, &coefficients);
}

double SparseGreedyGprModel::frobenius_norm_targets() const {
  return frobenius_norm_targets_;
}

{'fraction_non_alphanumeric': 0.07702020202020202, 'fraction_numerical': 0.0, 'mean_word_length': 5.702199661590525, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6615048', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1203, 'n_words': 297}