weka包里面只包含jre,如果要自己编译java程序调用weka的工具包,必须按照jdk,版本是jdk1.6.0_26.
1.安装jdk,然后配置好环境变量JAVA_HOME,PATH,CLASSPATH
1)JAVA_HOME
C:\Program Files\Java\jdk1.6.0_26
2) Path使得系统可以在任何路径下识别java命令,设为:
%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin
3) CLASSPATH为java加载类(class or lib)路径,只有类在classpath中,java命令才能识别,设为:
.;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar (要加.表示当前路径)
其中注意添加CLASSPATH .;
2.运行weka的MessageClassifier例子
三个参数 -m -t -c
-m 要分析的文件
-t 建立的模型
-c 分类的类型 hit/miss
三个参数都有时,是训练;
没有-c时,是预测。
训练
If you run the MessageClassifier for the first time, you need to provide labeled examples to build a classifier from, i.e., messages ("-m") and the corresponding classes ("-c"). Since the data and the model are kept for future use, one has to specify a filename, where the MessageClassifier is serialized to ("-t").
Here's an example, that labels the message email1.txt as miss:
>java MessageClassifier -m email1.txt -c miss -t messageclassifier.model
Repeat this for all the messages you want to have classified.
分类
Classifying an unseen message is quite straight-forward, one just omits the class option ("-c"). The following call
>java MessageClassifier
-m email1023.txt
-t messageclassifier.model
will produce something like this:
>Message classified as : miss
阅读(2138) | 评论(0) | 转发(0) |