Introduction
Weka Installation on Mac
Download Weka disk image for OS X and install it.
Install libsvm
By default Weka doesn’t has libsvm library. In order to use SVM classification algorithm, we have to install the libsvm jar package manually.
Install libsvm.jar step by step:
- Download libsvm, and save to a local directory.
- Unzip the libsvm-x.xx.zip file.
- Copy the jar file
java/libsvm.jar
to the directory/Applications/weka-3-6-13-oracle-jvm.app/Contents/Java/Classes
. This directory is in the classpath of Weka - Go to directory
/Applications/weka-3-6-13-oracle-jvm.app/Contents/Java/Classes
, extract the libsvm.jar by the commandjar xf libsvm.jar
Create Data Set
Training Data Set
For Rehmertz 2, create training data file rehmertz-2-training.arff.
%
% Rehmertz Training Data
% Reference to the table-1 "实验室中的模拟试验 - 雷墨磁2"
%
@relation Rehmertz
@attribute torque-diff numeric
@attribute resistance-diff numeric
@attribute cost numeric
@attribute result {pass, fail}
@data
1.0,0.4,0.18,fail
0.7,0.9,1.15,pass
4.0,4.0,4.00,fail
4.0,4.0,6.00,pass
For Rehmertz 1 and Rehmertz 3, create training data file rehmertz-1-3-training.arff.
%
% Rehmertz Training Data
% Reference to the table-2 "实验室中的模拟试验 - 雷墨磁1和雷墨磁3"
%
@relation Rehmertz
@attribute torque-diff numeric
@attribute resistance-diff numeric
@attribute cost numeric
@attribute result {pass, fail}
@data
1.0,0.4,0.4,fail
0.7,0.9,1.1,pass
4.0,4.0,4.00,fail
4.0,4.0,6.00,pass
0.7,0.8,0.75,fail
1.4,1.0,1.25,pass
Test Data Set
Create testing data file rehmertz-test.arff.
%
% Rehmertz Testing Data
%
@relation Rehmertz
@attribute torque-diff numeric
@attribute resistance-diff numeric
@attribute cost numeric
@attribute result {pass, fail}
@data
3,3,0.2,pass
3,3,0.4,pass
3,3,0.6,pass
3,3,0.8,pass
3,3,1.0,pass
3,3,1.2,pass
3,3,1.4,pass
3,3,1.6,pass
3,3,1.8,pass
3,3,2.0,pass
3,3,2.2,pass
... ...
3,3,8.0,pass
Detail Steps
Load traing data set
-
Open Weka GUI and click the “Explorer”
-
In the “Weka Explorer” Window, select “Preprocess” tab, and click the
Open File
button and select the filerehmertz-2-training.arff
. The the training data for Rehmertz 2 is loaded.
Select Classification Algorithm
-
Select the
Classify
tab in the “Weka Explorer” Window, and clickchoose
button in Classifier area
Select the classification algorithm logistic
Supply test data file
- Under the same
Classify
tab, in theTest options
area, selectSupplied test set
and click theSet
->Open file...
to the load the filerehmertz-test.arff
.
Select Classification Options
- Click
More options
in theTest options
area. In theClassifier evaluation options
window, selectOutput predictions
option, and setOutput additional attributes
to 3.
Run Classfication and Check Result
- Confirm the
(Nom) result
is selected as target. Then clickstart
- The execution result is shown