我已经安装了python的elm库。此链接http://elm.readthedocs.io/en/latest/usage.html中提供了一个示例。代码是:
import elm
# download an example dataset from
# https://github.com/acba/elm/tree/develop/tests/data
# load dataset
data = elm.read("iris.data")
# create a classifier
elmk = elm.ELMKernel()
# search for best parameter for this dataset
# define "kfold" cross-validation method, "accuracy" as a objective function
# to be optimized and perform 10 searching steps.
# best parameters will be saved inside 'elmk' object
elmk.search_param(data, cv="kfold", of="accuracy", eval=10)
# split data in training and testing sets
# use 80% of dataset to training and shuffle data before splitting
tr_set, te_set = elm.split_sets(data, training_percent=.8, perm=True)
#train and test
# results are Error objects
tr_result = elmk.train(tr_set)
te_result = elmk.test(te_set)
print(te_result.get_accuracy)
当我运行代码时,我显示此错误。如果有人能够指出造成问题的原因,对我来说会有很大的帮助。我已经从链接中提供的给定URL下载了数据集。我的elm包的版本是0.1.1,python版本是3.5.2。提前致谢。 错误是:
Traceback (most recent call last):
File "F:\7th semester\machine language\thesis work\python\Applying ELM in iris dataset\elm1.py", line 17, in <module>
elmk.search_param(data, cv="kfold", of="accuracy", eval=10)
File "C:\Users\maisha\AppData\Local\Programs\Python\Python35\lib\site-packages\elm\elmk.py", line 489, in search_param
param_kernel=param_ranges[1])
File "C:\Users\maisha\AppData\Local\Programs\Python\Python35\lib\site-packages\optunity\api.py", line 212, in minimize
pmap=pmap)
File "C:\Users\maisha\AppData\Local\Programs\Python\Python35\lib\site-packages\optunity\api.py", line 245, in optimize
solution, report = solver.optimize(f, maximize, pmap=pmap)
File "C:\Users\maisha\AppData\Local\Programs\Python\Python35\lib\site-packages\optunity\solvers\CMAES.py", line 139, in optimize
sigma=self.sigma)
File "C:\Users\maisha\AppData\Local\Programs\Python\Python35\lib\site-packages\deap\cma.py", line 90, in __init__
self.dim = len(self.centroid)
TypeError: len() of unsized object