首页 > 编程语言 > 详细

Find-S:寻找极大特殊假设_Java实现

时间:2014-04-06 11:03:19      阅读:394      评论:0      收藏:0      [点我收藏+]

算法描述:bubuko.com,布布扣

bubuko.com,布布扣

算法说明:该算法是概念空间挖掘最简单的算法,只考虑了正实例,不断做泛化,实际上求得了一个最特化边界

算法实现:

bubuko.com,布布扣
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class FindS {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        int maxTrain = 4;
        int maxLen = 7;
        int i = 0;
        String temp = null;
        String yes = new String("Yes");
        String[][] state = new String[maxTrain][maxLen];
        String[] concept = new String[maxLen];
        FileReader fr = new FileReader("e:\\workspace\\train.txt");
        BufferedReader br = new BufferedReader(fr);
        while((temp = br.readLine()) != null && i < 4){
            state[i] = temp.split(" ");
            i++;

        }
        for(int j = 1; j < maxLen; j++){
            concept[j] = state[0][j];
        }
        for(i = 1; i < maxTrain; i++){
            if(state[i][maxLen-1].equals(yes)){
                for(int k = 1; k < maxLen-1; k++){
                    if(!state[i][k].equals(concept[k])){
                        concept[k] = "?";
                    }
                }
            }
        }
        System.out.print("The concept is : ");
        for(i = 1; i < maxLen - 1; i++){
            System.out.print(concept[i] + " ");
        }
        br.close();
        return;
    }
}
bubuko.com,布布扣
预测数据:

1 Sunny Warm Normal Strong Warm Yes  
2 Sunny Warm High Strong Warm Yes  
3 Rainy Cold High Strong Warm No  
4 Sunny Warm High Strong Cool Yes

运行结果:

The concept is : Sunny Warm High Strong ? 

 

Find-S:寻找极大特殊假设_Java实现,布布扣,bubuko.com

Find-S:寻找极大特殊假设_Java实现

原文:http://www.cnblogs.com/bleachzk/p/3647772.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!