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>&);
105 float score(
const VectorXf& y_true,
const VectorXf& y_pred,
106 VectorXf& loss,
const vector<float>& w)
118 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
127 vector<float> class_weights = {};
135 for (
unsigned i = 0; i < params.
n_classes; ++i){
137 int support = (data.
y.cast<
int>().array() == i).count();
140 class_weights.at(i) = 0.0f;
142 class_weights.at(i) = float(data.
y.size()) / float(params.
n_classes * support);
152 return score(data.
y, y_pred, loss, class_weights);
156template <ProgramType P>
166 const vector<float>&);
189 float score(
const VectorXf& y_true,
const ArrayXXf& y_pred,
190 VectorXf& loss,
const vector<float>& w)
206 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
215 vector<float> class_weights = {};
219 for (
unsigned i = 0; i < params.
n_classes; ++i){
221 int support = (data.
y.cast<
int>().array() == i).count();
224 class_weights.at(i) = 0.0;
226 class_weights.at(i) = float(data.
y.size()) / float(params.
n_classes * support);
233 return score(data.
y, y_pred, loss, class_weights);
void set_scorer(string scorer)
float(*) funcPointer(const VectorXf &, const VectorXf &, VectorXf &, const vector< float > &)
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)
void set_scorer(string scorer)
float(*) funcPointer(const VectorXf &, const VectorXf &, VectorXf &, const vector< float > &)
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)
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 precision_score(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Precision for binary classification (threshold 0.5, positive label 1).
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 multi_recall_score(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Macro-averaged recall for multi-classification.
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 multi_bal_zero_one_loss(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Balanced accuracy for multi-classification.
float recall_score(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Recall for binary classification (threshold 0.5, positive label 1).
float multi_roc_auc_score(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Macro-averaged one-vs-rest AUROC for multi-classification.
float multi_precision_score(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Macro-averaged precision for multi-classification.
float multi_average_precision_score(const VectorXf &y, const ArrayXXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Macro-averaged one-vs-rest average precision for multi-classification.
float bal_zero_one_loss(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Balanced accuracy for binary classification.
float roc_auc_score(const VectorXf &y, const VectorXf &predict_proba, VectorXf &loss, const vector< float > &class_weights)
Area under the ROC curve for binary classification.
< nsga2 selection operator for getting the front
vector< float > class_weights
weights for each class
string class_weights_type