使用决策树对数据集进行分类
##开发平台
Ubuntu Kylin 14.04
##运行程序
在终端进入项目目录,输入:
$ make -- 编译程序
$ ./main -- 运行程序
$ ./main test -- 计算决策树的准确率
##输入输出说明
data/dataset.txt -- 决策树的数据集合,前100条记录用于训练模型,后面的数据用于预测并验证
data/correctResult.txt -- 数据的真实结果
data/predictions.txt -- 决策树的预测结果
##数据集描述
-
Title: 1984 United States Congressional Voting Records Database
-
Source Information: (a) Source: Congressional Quarterly Almanac, 98th Congress, 2nd session 1984, Volume XL: Congressional Quarterly Inc. Washington, D.C., 1985. (b) Donor: Jeff Schlimmer ([email protected]) (c) Date: 27 April 1987
-
Past Usage
- Publications
- Schlimmer, J. C. (1987). Concept acquisition through representational adjustment. Doctoral dissertation, Department of Information and Computer Science, University of California, Irvine, CA. -- Results: about 90%-95% accuracy appears to be STAGGER's asymptote
- Predicted attribute: party affiliation (2 classes)
- Publications
-
Relevant Information: This data set includes votes for each of the U.S. House of Representatives Congressmen on the 16 key votes identified by the CQA. The CQA lists nine different types of votes: voted for, paired for, and announced for (these three simplified to yea), voted against, paired against, and announced against (these three simplified to nay), voted present, voted present to avoid conflict of interest, and did not vote or otherwise make a position known (these three simplified to an unknown disposition).
-
Number of Instances: 435 (267 democrats, 168 republicans)
-
Number of Attributes: 16 + class name = 17 (all Boolean valued)
-
Attribute Information:
- Class Name: 2 (democrat, republican)
- handicapped-infants: 2 (y,n)
- water-project-cost-sharing: 2 (y,n)
- adoption-of-the-budget-resolution: 2 (y,n)
- physician-fee-freeze: 2 (y,n)
- el-salvador-aid: 2 (y,n)
- religious-groups-in-schools: 2 (y,n)
- anti-satellite-test-ban: 2 (y,n)
- aid-to-nicaraguan-contras: 2 (y,n)
-
mx-missile: 2 (y,n)
-
immigration: 2 (y,n)
-
synfuels-corporation-cutback: 2 (y,n)
-
education-spending: 2 (y,n)
-
superfund-right-to-sue: 2 (y,n)
-
crime: 2 (y,n)
-
duty-free-exports: 2 (y,n)
-
export-administration-act-south-africa: 2 (y,n)
-
Missing Attribute Values: Denoted by "?"
NOTE: It is important to recognize that "?" in this database does not mean that the value of the attribute is unknown. It means simply, that the value is not "yea" or "nay" (see "Relevant Information" section above).
Attribute: #Missing Values: 1: 0 2: 0 3: 12 4: 48 5: 11 6: 11 7: 15 8: 11 9: 14 10: 15 11: 22 12: 7 13: 21 14: 31 15: 25 16: 17 17: 28
-
Class Distribution: (2 classes)
- 45.2 percent are democrat
- 54.8 percent are republican