Skip to content

Instantly share code, notes, and snippets.

@ikegami-yukino
Last active April 11, 2016 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikegami-yukino/1335ba47e14ce4d0c40dc0a5a85e9a47 to your computer and use it in GitHub Desktop.
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
--- 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
{
@tomofumi-nakano
Copy link

パッチの作成ありがとうございます。
ところで、トリッキーなC言語の仕様のため、二つ目の修正箇所の if 文の中は、複数なので、else以降のように{} の括弧が必要なんです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment