libsvm - 如何让grid.py更快?

0 投票
2 回答
721 浏览
提问于 2025-04-18 03:28

LIBSVM 有一个 Python 函数 grid.py,我理解它是用来选择参数的,使用了一种叫做 grid-search 的方法。

用法:grid.py [网格选项] [SVM选项] 数据集

这个过程需要多长时间呢?我有一个很大的数据集(一个有 8 万行的 CSV 文件),到现在为止已经花了超过 24 小时。有没有办法让这个脚本运行得更快一些?

2 个回答

1

在grid.py文件中,你可以找到一些参数设置。

telnet_workers = []
ssh_workers = []
nr_local_worker = 1

在这里,你可以配置外部助手和本地线程的数量。试着增加本地线程的数量,直到你的机器的使用率接近100%。

1

限制范围

-log2c {begin,end,step | "null"} : set the range of c (default -5,15,2)
-log2g {begin,end,step | "null"} : set the range of g (default 3,-15,-2)

减少n折交叉验证的次数

-v n : n-fold cross validation (default 5)

当然,代码还是需要优化,但首先可以简单地限制一下范围。

更新

试试subset.py来减少数据集,然后运行grid.py。这样我能更快给你一些建议!

撰写回答