16template <ProgramType P>
28 const vector<float>&);
45 float score(
const VectorXf& y_true,
const VectorXf& y_pred,
46 VectorXf& loss,
const vector<float>& w)
59 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
73template <ProgramType P>
83 const vector<float>&);
102 float score(
const VectorXf& y_true,
const VectorXf& y_pred,
103 VectorXf& loss,
const vector<float>& w)
115 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
127 if (!class_weights.empty())
130 for (
unsigned i = 0; i < params.
n_classes; ++i){
131 class_weights.at(i) = float((data.
y.cast<
int>().array() == i).count())/data.
y.size();
132 class_weights.at(i) = (1.0 - class_weights.at(i));
136 return score(data.
y, y_pred, loss, class_weights);
140template <ProgramType P>
150 const vector<float>&);
168 float score(
const VectorXf& y_true,
const ArrayXXf& y_pred,
169 VectorXf& loss,
const vector<float>& w)
185 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
197 if (!class_weights.empty())
200 for (
unsigned i = 0; i < params.
n_classes; ++i){
201 class_weights.at(i) = float((data.
y.cast<
int>().array() == i).count())/data.
y.size();
202 class_weights.at(i) = (1.0 - class_weights.at(i));
206 return score(data.
y, y_pred, loss, class_weights);
void set_scorer(string scorer)
float score(Individual< P > &ind, Dataset &data, VectorXf &loss, const Parameters ¶ms)
float score(const VectorXf &y_true, const ArrayXXf &y_pred, VectorXf &loss, const vector< float > &w)
Scorer(string scorer="multi_log")
Scorer(string scorer="log")
std::map< string, funcPointer > score_hash
float score(const VectorXf &y_true, const VectorXf &y_pred, VectorXf &loss, const vector< float > &w)
float(* funcPointer)(const VectorXf &, const VectorXf &, VectorXf &, const vector< float > &)
void set_scorer(string scorer)
float score(Individual< P > &ind, Dataset &data, VectorXf &loss, const Parameters ¶ms)
typename std::conditional_t< P==PT::Regressor, ArrayXf, std::conditional_t< P==PT::Representer, ArrayXXf, ArrayXf > > RetType
Scorer(string scorer="mse")
std::map< string, funcPointer > score_hash
float score(const VectorXf &y_true, const VectorXf &y_pred, VectorXf &loss, const vector< float > &w)
float(* funcPointer)(const VectorXf &, const VectorXf &, VectorXf &, const vector< float > &)
auto predict(const Dataset &data)
auto predict_proba(const Dataset &d)
holds variable type data.
ArrayXf y
length N array, the target label
#define HANDLE_ERROR_THROW(err)
float multi_zero_one_loss(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Accuracy for multi-classification.
float zero_one_loss(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Accuracy for binary classification.
float mean_log_loss(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
log loss
float mean_multi_log_loss(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Calculates the mean multinomial log loss between the predicted probabilities and the true labels.
float average_precision_score(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Calculates the average precision score between the predicted probabilities and the true labels.
float mse(const VectorXf &y, const VectorXf &yhat, VectorXf &loss, const vector< float > &class_weights)
mean squared error
float bal_zero_one_loss(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Balanced accuracy for binary classification.
< nsga2 selection operator for getting the front
vector< float > class_weights
weights for each class