【问题标题】:How to install svmutil in Jupyter notebook on Google Colaboratory?如何在 Google Colaboratory 的 Jupyter notebook 中安装 svmutil?
【发布时间】:2019-05-24 16:30:40
【问题描述】:
【问题讨论】:
标签:
python
jupyter-notebook
google-colaboratory
【解决方案1】:
首先下载 svmutil.py 文件并将其保存在运行 jupyter notebook 的位置。然后使用
导入 svmutil 函数
from svmutil import *
你可以使用它的功能
svm_train() : train an SVM model
svm_predict() : predict testing data
svm_read_problem() : read the data from a LIBSVM-format file.
svm_load_model() : load a LIBSVM model.
svm_save_model() : save model to a file.
evaluations() : evaluate prediction results.
【解决方案2】:
您需要先安装库。这是一个完整的例子:
https://colab.research.google.com/drive/1svYMGnV7HdeqXpN15T5ajxbLijLmBeSm
关键位:
# Clone the git repo.
!git clone https://github.com/Netflix/vmaf.git
# Build the library.
%cd vmaf/
!make && make install
# Build Python-specific bits.
%cd /content/vmaf/libsvm/python/
!make
# Add the Python module to the path.
import sys
sys.path.append('/content/vmaf/libsvm/python')
# Switch back to the base directory. (This is a convenience
# and isn't required.)
%cd /content
【解决方案3】:
接受的答案会下载许多其他内容,而不仅仅是 libsvm。如果您只想安装 libsvm 库,您必须执行以下操作:
!git clone https://github.com/cjlin1/libsvm
%cd libsvm/
!make && make install
%cd /content/libsvm/python/
!make
import sys
sys.path.append('/content/libsvm/python')
%cd /content