【机器学习系列】libsvm的使用问题收集

【1】

我用grid.py进行参数寻优时,出现如下错误:
  D:\libsvm-2.89\tools>grid.py german_scale
  [local] 5 -7 76.9 <best C=32.0,g=0.0078125 rate=76.9>
  Timeout:gnuplot is not ready
  [local] -1 -7 70.0 <best C=32.0,g=0.0078125 rate=76.9>
  Traceback <most recent call last>:
  File "D:\libsvm-2.89\tools>grid.py",line 362,in<module>
  main<>
  File "D:\libsvm-2.89\tools>grid.py",line 357,in main
  redraw(db,[best_c1, best_g1, best_rate])
  File "D:\libsvm-2.89\tools>grid.py",line 135,in redraw
  gnuplot.write("set term windows""\n")
  IOError:[errno 22] invalid argument
上面选用的数据是在Chih-Chung Chang and Chih-Jen Lin网站下载的数据german_scale,可是用heart_scale试过了,一点错误都没有,gnuplot也能正常运行,因此路径应该不会错误(我看过看过好多次了,路径确实没错)。也曾怀疑是数据格式错误,用checkdata.py测试,german_scale数据格式正确。我又不懂python语言,实在是招不出改正方法,哎!急啊!各位大牛们广泛发表意见救救我吧!感激不尽,感激不尽!

 

answer:


简单试试按下编辑grid.py:
第 9行插入import time
第95行插入time.sleep(3) #3秒延迟

 

 


【2】

easy.py error 
Hi there,
I'm having problems getting easy.py to work. I've formatted my data according to the details in README and passed it to easy.py as
python easy.py train.txt. test.txt
but I get the following output
Scaling training data...
Cross validation...
Traceback (most recent call last):
File "easy.py", line 61, in ?
c,g,rate = map(float,last_line.split())
ValueError: need more than 0 values to unpack
I've done some Googling and a search on this forum and every answer I find suggests that this is because i'm on Windows and that gnuplot is in the wrong place.
I've read through the README in the python directory and made sure that pgnuplot is in the directory specified in there (and made sure that the code matches in easy.py).
Anyone have any ideas what could be causing this

 

 

answer:

I've done some further investigation and I think I've found the problem. For some reason .py files have stopped being associated with the python interpreter so the command that calls grid.py does nothing and thus easy.py cannot continue.

It'll be a while before the run finishes so I can't be certain this has fixed everything but its looking good.

So for anyone who encounters this problem in future -

Associated .py files with your Python interpreter or change this line -

cmd = "%s -svmtrain %s -gnuplot %s %s" % (grid_py, svmtrain_exe, gnuplot_exe, scaled_file)

to this -

cmd = "python %s -svmtrain %s -gnuplot %s %s" % (grid_py, svmtrain_exe, gnuplot_exe, scaled_file)

Hope someone finds this useful,


转载自:http://bingxinye1.blog.163.com/blog/static/16879709820122253614555/

你可能感兴趣的:(机器学习,libsvm)