• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NumericToNominal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中weka.filters.unsupervised.attribute.NumericToNominal的典型用法代码示例。如果您正苦于以下问题:Java NumericToNominal类的具体用法?Java NumericToNominal怎么用?Java NumericToNominal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NumericToNominal类属于weka.filters.unsupervised.attribute包,在下文中一共展示了NumericToNominal类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildAssociate

import weka.filters.unsupervised.attribute.NumericToNominal; //导入依赖的package包/类
public static String buildAssociate() throws Exception {
    InstanceQuery query = new InstanceQuery();
    query.setUsername("root");
    query.setPassword("cs6310");
    query.setDatabaseURL("jdbc:mysql://localhost/system?#characterEncoding=UTF-8");
    query.setQuery("select * from courses_sessions;");
    // You can declare that your data set is sparse
    // query.setSparseData(true);
    Instances data = query.retrieveInstances();
    data.setClassIndex(data.numAttributes() - 1);

    final NumericToNominal filter = new NumericToNominal();

    filter.setInputFormat(data);
    data = Filter.useFilter(data, filter);
    if (data.size() > 0) {
        // build associator
        Apriori apriori = new Apriori();
        apriori.setClassIndex(data.classIndex());
        apriori.buildAssociations(data);
        return String.valueOf(apriori);
    } else {
        return "Not enough data provided";
    }
}
 
开发者ID:ejesposito,项目名称:CS6310O01,代码行数:26,代码来源:WekaDataMiner.java


示例2: splitWorkload

import weka.filters.unsupervised.attribute.NumericToNominal; //导入依赖的package包/类
/**
 * 
 * @param data
 * @return
 */
protected Instances[] splitWorkload(Instances data) {
    int offset = 0;
    int all_cnt = data.numInstances();
    for (SplitType stype : SplitType.values()) {
        int idx = stype.ordinal();
        this.split_counts[idx] = (int)Math.round(all_cnt * stype.percentage);
        
        try {
            this.splits[idx] = new Instances(data, offset, this.split_counts[idx]);
        
            // Apply NumericToNominal filter!
            NumericToNominal filter = new NumericToNominal();
            filter.setInputFormat(this.splits[idx]);
            this.splits[idx] = Filter.useFilter(this.splits[idx], filter);
            
        } catch (Exception ex) {
            throw new RuntimeException("Failed to split " + stype + " workload", ex);
        }
        
        offset += this.split_counts[idx];
        if (debug.val) LOG.debug(String.format("%-12s%d", stype.toString()+":", this.split_counts[idx]));
    } // FOR
    return (this.splits);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:30,代码来源:FeatureClusterer.java


示例3: generateDecisionTree

import weka.filters.unsupervised.attribute.NumericToNominal; //导入依赖的package包/类
protected Classifier generateDecisionTree(AbstractClusterer clusterer, MarkovAttributeSet aset, Instances data) throws Exception {
    // We need to create a new Attribute that has the ClusterId
    Instances newData = data; // new Instances(data);
    newData.insertAttributeAt(new Attribute("ClusterId"), newData.numAttributes());
    Attribute cluster_attr = newData.attribute(newData.numAttributes()-1);
    assert(cluster_attr != null);
    assert(cluster_attr.index() > 0);
    newData.setClass(cluster_attr);
    
    // We will then tell the Classifier to predict that ClusterId based on the MarkovAttributeSet
    ObjectHistogram<Integer> cluster_h = new ObjectHistogram<Integer>();
    for (int i = 0, cnt = newData.numInstances(); i < cnt; i++) {
        // Grab the Instance and throw it at the the clusterer to get the target cluster
        Instance inst = newData.instance(i);
        int c = (int)clusterer.clusterInstance(inst);
        inst.setClassValue(c);
        cluster_h.put(c);
    } // FOR
    System.err.println("Number of Elements: " + cluster_h.getValueCount());
    System.err.println(cluster_h);

    NumericToNominal filter = new NumericToNominal();
    filter.setInputFormat(newData);
    newData = Filter.useFilter(newData, filter);
    
    String output = this.catalog_proc.getName() + "-labeled.arff";
    FileUtil.writeStringToFile(output, newData.toString());
    LOG.info("Wrote labeled data set to " + output);
    
    // Decision Tree
    J48 j48 = new J48();
    String options[] = {
        "-S", Integer.toString(this.rand.nextInt()),
        
    };
    j48.setOptions(options);

    // Make sure we add the ClusterId attribute to a new MarkovAttributeSet so that
    // we can tell the Classifier to classify that!
    FilteredClassifier fc = new FilteredClassifier();
    MarkovAttributeSet classifier_aset = new MarkovAttributeSet(aset);
    classifier_aset.add(cluster_attr);
    fc.setFilter(classifier_aset.createFilter(newData));
    fc.setClassifier(j48);
    
    // Bombs away!
    fc.buildClassifier(newData);
    
    return (fc);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:51,代码来源:FeatureClusterer.java


示例4: setUp

import weka.filters.unsupervised.attribute.NumericToNominal; //导入依赖的package包/类
@Override
    protected void setUp() throws Exception {
        super.setUp(ProjectType.TPCC);
        this.addPartitions(NUM_PARTITIONS);
        
        HStoreConf.singleton().site.markov_path_caching = false;
        
        if (workload == null) {
            catalog_proc = this.getProcedure(TARGET_PROCEDURE);
            
            File file = this.getWorkloadFile(ProjectType.TPCC);
            workload = new Workload(catalog);

            // Check out this beauty:
            // (1) Filter by procedure name
            // (2) Filter on partitions that start on our BASE_PARTITION
            // (3) Filter to only include multi-partition txns
            // (4) Another limit to stop after allowing ### txns
            // Where is your god now???
            edu.brown.workload.filters.Filter filter = new ProcedureNameFilter(false)
                    .include(TARGET_PROCEDURE.getSimpleName())
//                    .attach(new ProcParameterValueFilter().include(1, new Long(5))) // D_ID
//                    .attach(new ProcParameterArraySizeFilter(CatalogUtil.getArrayProcParameters(catalog_proc).get(0), 10, ExpressionType.COMPARE_EQUAL))
//                    .attach(new BasePartitionTxnFilter(p_estimator, BASE_PARTITION))
//                    .attach(new MultiPartitionTxnFilter(p_estimator))
                    .attach(new ProcedureLimitFilter(WORKLOAD_XACT_LIMIT));
            workload.load(file, catalog_db, filter);
            assert(workload.getTransactionCount() > 0);
            
            // Now extract the FeatureSet that we will use in our tests
            Map<Procedure, FeatureSet> fsets = new FeatureExtractor(catalogContext, p_estimator).calculate(workload);
            FeatureSet fset = fsets.get(catalog_proc);
            assertNotNull(fset);
            data = fset.export(catalog_proc.getName(), false);
            
            NumericToNominal weka_filter = new NumericToNominal();
            weka_filter.setInputFormat(data);
            data = Filter.useFilter(data, weka_filter);
        }
        assertNotNull(data);
        
        fclusterer = new FeatureClusterer(catalogContext, catalog_proc, workload, catalogContext.getAllPartitionIds());
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:44,代码来源:TestFeatureClusterer.java



注:本文中的weka.filters.unsupervised.attribute.NumericToNominal类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CaptureDeviceInfo类代码示例发布时间:2022-05-22
下一篇:
Java ServiceUnavailableException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap