Last active
April 11, 2016 05:44
-
-
Save ikegami-yukino/1335ba47e14ce4d0c40dc0a5a85e9a47 to your computer and use it in GitHub Desktop.
LIBLINEAR 2.1 multiclass logistic regression patch from http://blog.goo.ne.jp/nakano-tomofumi/e/27d8b7b18ec74b41f16e64aa0006391d
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
--- linear.cpp 2015-09-27 07:03:33.000000000 +0900 | |
+++ new_linear.cpp 2016-04-09 01:32:23.000000000 +0900 | |
@@ -2685,9 +2685,10 @@ double predict_probability(const struct | |
double label=predict_values(model_, x, prob_estimates); | |
for(i=0;i<nr_w;i++) | |
- prob_estimates[i]=1/(1+exp(-prob_estimates[i])); | |
+ prob_estimates[i]=exp(prob_estimates[i]); | |
if(nr_class==2) // for binary classification | |
+ prob_estimates[0]=1/(1+1/prob_estimates[0]); | |
prob_estimates[1]=1.-prob_estimates[0]; | |
else | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
パッチの作成ありがとうございます。
ところで、トリッキーなC言語の仕様のため、二つ目の修正箇所の if 文の中は、複数なので、else以降のように{} の括弧が必要なんです。