java未定义,Java类型的方法未定义

Having real trouble figuring out where i'm going wrong on this one. Building a system using WEKA in java to study associations and am trying to implement the Apriori algorithm. Currently this is the code:

package model;

import weka.associations.*;

import weka.core.Instances;

import weka.core.converters.ConverterUtils.DataSource;

public class Apriori {

public static void main(String args[]) throws Exception {

String dataset = "/Users/andrew/workspace/Movies/src/data/tagsfinal.arff";

DataSource dsource = new DataSource(dataset);

Instances dapriori = dsource.getDataSet();

Apriori apriori = new Apriori();

apriori.buildAssociations(dapriori);

System.out.println(apriori);

}

}

From looking at several implementations across the web this seems to be a widely accepted method of doing this however i receive an error on the "apriori.buildAssociations" line telling me that the method is undefined for the type Apriori. Furthermore, the import statement i use for the associations only works as the package type and when trying to extend it to :

import weka.associations.Apriori;

this throws an error message that "The import weka.associations.Apriori conflicts with a type defined in the same file". I have scoured StackOverflow alongside other resources and realize there is a lot of type undefined questions out there however have yet to find a solution to this problem. Any help/pointers would be greatly appreciated.

解决方案

Your class is also named Apriori, so you are experiencing a name clash.

You should change the name of your own class to a different name (e.g. AprioriTest). In the unprobable case where you would really need your class to be named Apriori, then you would have to refer to the library's implementation by it's full name:

weka.associations.Apriori apriori = new weka.associations.Apriori();

apriori.buildAssociations(dapriori);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值