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);
124 vector<float> class_weights = {};
132 for (
unsigned i = 0; i < params.
n_classes; ++i){
134 int support = (data.
y.cast<
int>().array() == i).count();
137 class_weights.at(i) = 0.0f;
139 class_weights.at(i) = float(data.
y.size()) / float(params.
n_classes * support);
147 return score(data.
y, y_pred, loss, class_weights);
151template <ProgramType P>
161 const vector<float>&);
179 float score(
const VectorXf& y_true,
const ArrayXXf& y_pred,
180 VectorXf& loss,
const vector<float>& w)
196 return score_hash.at(this->scorer)(y_true, y_pred, loss, w);
205 vector<float> class_weights = {};
209 for (
unsigned i = 0; i < params.
n_classes; ++i){
211 int support = (data.
y.cast<
int>().array() == i).count();
214 class_weights.at(i) = 0.0;
216 class_weights.at(i) = float(data.
y.size()) / float(params.
n_classes * support);
223 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
string class_weights_type