from weka.clusterers import Clusterer
import weka.core.converters as converters
data = converters.load_any_file("/home/ubuntu/test.csv")
data.class_is_last()
clusterer = Clusterer(classname="weka.clusterers.SimpleKMeans", options=["-N", "3"])
clusterer.build_clusterer(data)
print(clusterer)
# cluster the data
for inst in data:
cl = clusterer.cluster_instance(inst) # 0-based cluster index
dist = clusterer.distribution_for_instance(inst) # cluster membership distribution
print("cluster=" + str(cl) + ", distribution=" + str(dist))
我使用上面的代码做k意味着custering我无法执行程序
以下是我得到的错误
Traceback (most recent call last):
File "clus.py", line 6, in <module>
data = converters.load_any_file("/home/ubuntu/hello.csv")
File "/usr/local/lib/python2.7/dist-packages/weka/core/converters.py", line 255, in load_any_file
loader = loader_for_file(filename)
File "/usr/local/lib/python2.7/dist-packages/weka/core/converters.py", line 239, in loader_for_file
"(Ljava/lang/String;)Lweka/core/converters/AbstractFileLoader;", filename)
File "/usr/local/lib/python2.7/dist-packages/javabridge/jutil.py", line 932, in static_call
fn = make_static_call(class_name, method_name, sig)
File "/usr/local/lib/python2.7/dist-packages/javabridge/jutil.py", line 903, in make_static_call
klass = env.find_class(class_name)
AttributeError: 'NoneType' object has no attribute 'find_class'
我不知道为什么我会收到这些错误。有人可以帮我这个吗?
答案 0 :(得分:1)