如何在 Google Colaboratory 上的 Jupyter notebook 中安装 svmutil?
How to install svmutil in Jupyter notebook on Google Colaboratory?
我想在运行在 Google Colaboratory 上的 Jupyter 笔记本中使用 https://github.com/Netflix/vmaf/tree/master/libsvm/python 中的 svmutil 函数。
运行
import svmutil
给出以下错误:
ModuleNotFoundError: No module named 'svmutil'
如何在 colab 中安装此 github 存储库?
首先下载 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.
您需要先安装库。这是一个完整的例子:
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
接受的答案会下载许多其他东西,而不仅仅是 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
我想在运行在 Google Colaboratory 上的 Jupyter 笔记本中使用 https://github.com/Netflix/vmaf/tree/master/libsvm/python 中的 svmutil 函数。
运行
import svmutil
给出以下错误:
ModuleNotFoundError: No module named 'svmutil'
如何在 colab 中安装此 github 存储库?
首先下载 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.
您需要先安装库。这是一个完整的例子:
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
接受的答案会下载许多其他东西,而不仅仅是 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