Created
December 10, 2015 05:35
-
-
Save AlexanderSavochkin/3d705103b06fa7a4b1d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MultinomialLogRelModel::featurize(const valarray<double>& sample_features, int label, valarray<double>& modelFeatures) const | |
{ | |
for (int k = 0; k < num_classes; ++k) //Loop through classes | |
{ | |
for (int i = 0; i < num_sample_features; ++i ) //loop through features | |
{ | |
modelFeatures[k * (num_sample_features + 1) + i] = (k == label ? sample_features[i] : 0.0); | |
} | |
modelFeatures[(k + 1) * (num_sample_features + 1) - 1] = (k == label ? 1.0 : 0.0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment