java weka logistic,如何解释Weka Logistic回归输出?

Please help interpret results of logistic regression produced by weka.classifiers.functions.Logistic from Weka library.

I use numeric data from Weka examples:

@relation weather

@attribute outlook {sunny, overcast, rainy}

@attribute temperature real

@attribute humidity real

@attribute windy {TRUE, FALSE}

@attribute play {yes, no}

@data

sunny,85,85,FALSE,no

sunny,80,90,TRUE,no

overcast,83,86,FALSE,yes

rainy,70,96,FALSE,yes

rainy,68,80,FALSE,yes

rainy,65,70,TRUE,no

overcast,64,65,TRUE,yes

sunny,72,95,FALSE,no

sunny,69,70,FALSE,yes

rainy,75,80,FALSE,yes

sunny,75,70,TRUE,yes

overcast,72,90,TRUE,yes

overcast,81,75,FALSE,yes

rainy,71,91,TRUE,no

To create logistic regression model I use command:

java -cp $WEKA_INS/weka.jar weka.classifiers.functions.Logistic -t $WEKA_INS/data/weather.numeric.arff -T $WEKA_INS/data/weather.numeric.arff -d ./weather.numeric.model.arff

Here the three arguments mean:

-t : Sets training file.

-T : Sets test file.

-d : Sets model output file.

Running the above command produce the following output:

Logistic Regression with ridge parameter of 1.0E-8

Coefficients...

Class

Variable yes

===============================

outlook=sunny -6.4257

outlook=overcast 13.5922

outlook=rainy -5.6562

temperature -0.0776

humidity -0.1556

windy 3.7317

Intercept 22.234

Odds Ratios...

Class

Variable yes

===============================

outlook=sunny 0.0016

outlook=overcast 799848.4264

outlook=rainy 0.0035

temperature 0.9254

humidity 0.8559

windy 41.7508

Time taken to build model: 0.05 seconds

Time taken to test model on training data: 0 seconds

=== Error on training data ===

Correctly Classified Instances 11 78.5714 %

Incorrectly Classified Instances 3 21.4286 %

Kappa statistic 0.5532

Mean absolute error 0.2066

Root mean squared error 0.3273

Relative absolute error 44.4963 %

Root relative squared error 68.2597 %

Total Number of Instances 14

=== Confusion Matrix ===

a b

7 2 | a = yes

1 4 | b = no

Questions:

1) First section of the report:

Coefficients...

Class

Variable yes

===============================

outlook=sunny -6.4257

outlook=overcast 13.5922

outlook=rainy -5.6562

temperature -0.0776

humidity -0.1556

windy 3.7317

Intercept 22.234

1.1) Do I understand right that "Coefficients" are in fact weights that are applied to each attribute

before adding them together to produce the value of class attribute "play" equal to " yes"?

2) Second section of the report:

Odds Ratios...

Class

Variable yes

===============================

outlook=sunny 0.0016

outlook=overcast 799848.4264

outlook=rainy 0.0035

temperature 0.9254

humidity 0.8559

windy 41.7508

2.1) What is the meaning of "Odds Ratios"?

2.2) Do they all also relate to class attribute "play" equal to " yes"?

2.3) Why value of "outlook=overcast" is so much bigger then value of "outlook=sunny"?

3)

=== Confusion Matrix ===

a b

7 2 | a = yes

1 4 | b = no

3.1) What is the menaing of Confusion Matrix?

Thanks a lot for your help!

解决方案

Question:

Updated from comment below: The coefficients are in fact the weights that are applied to each attribute which are plugged into the logistic function 1/(1+exp(-weighted_sum)) to obtain probabilities. Note that the "Intercept" value is added to the sum without multiplying by any of your variables before adding them together. The result is the probability that the new instance belongs to class yes (> 0.5 means yes).

The odds ratios indicate how large of an influence a change in that value (or change to that value) will have on the prediction. I think this

The confusion matrix simply shows you how many of the test data points are correctly and incorrectly classified. In your example 7 A's were actually classified as A, whereas 2 A's were misclassified as B. Your question is more thoroughly answered in this question: How to read the classifier confusion matrix in WEKA.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java使用WekaLogistic算法,你需要按照以下步骤进行操作: 1. 首先,确保你已经装了Weka库。你可以从Weka官方网站(https://www.cs.waikato.ac.nz/ml/weka/)下载并安装Weka。 2. 在Java项目中导入Weka库。你可以通过在你的项目中添加Weka的JAR文件来实现。具体的步骤可以根据你使用的IDE来进行操作。 3. 创建一个实例对象,用于加载和处理数据。例如,你可以使用`weka.core.Instances`类来加载数据集,代码如下: ```java import weka.core.Instances; import java.io.BufferedReader; import java.io.FileReader; // 加载数据集 BufferedReader reader = new BufferedReader(new FileReader("path/to/your/dataset.arff")); Instances data = new Instances(reader); reader.close(); data.setClassIndex(data.numAttributes() - 1); // 设置类别属性 ``` 4. 创建Logistic分类器对象并进行训练。你可以使用`weka.classifiers.functions.Logistic`类来创建Logistic分类器,并使用数据进行训练,代码如下: ```java import weka.classifiers.functions.Logistic; // 创建Logistic分类器对象 Logistic classifier = new Logistic(); // 训练分类器 classifier.buildClassifier(data); ``` 5. 进行预测。你可以使用训练好的Logistic分类器对新数据进行预测,代码如下: ```java import weka.core.Instance; // 创建新的实例 Instance newInstance = new DenseInstance(data.numAttributes()); newInstance.setDataset(data); // 设置实例的属性值 // 进行预测 double prediction = classifier.classifyInstance(newInstance); System.out.println("预测结果:" + prediction); ``` 这些是在Java使用WekaLogistic算法的基本步骤。你可以根据自己的需求进行进一步的调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值