sklearn-port 库在window下安装

sklearn-port 库在window下安装

  • anaconda python3.7下安装报错
      • 安装步骤:
      • 参考

anaconda python3.7下安装报错

“UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0x93 in position 3136: illegal multibyte sequence”

安装步骤:

1、新建环境
>conda create -n sklearn-port python=3.7 #python 最新版
>conda activate sklearn-port

2、下载软件
>git clone -b stable https://github.com/nok/sklearn-porter.git
>cd sklearn-porter

3、修改setup.py
将 readme = open(readme_path, ‘r’).read().strip()
改为 readme = open(readme_path, ‘r’, encoding=‘utf-8’).read().strip()

4、使用setup.py安装
>python setup.py install

5、测试test_sklean_porter.py

from sklearn import svm
from sklearn import datasets
from sklearn_porter import Porter

clf = svm.SVC(gamma='scale')
iris = datasets.load_iris()
X, y = iris.data, iris.target
clf.fit(X, y)  

porter = Porter(clf, language='c')
output = porter.export(embed_data=True)
print(output)

提示同样错误。修改报错的下载文件夹下 sklearn_porter\_init_.py
将readme = open(readme_path, ‘r’).read().strip()
改为readme = open(readme_path, ‘r’, encoding=‘utf-8’).read().strip()
再次运行,产生C源文件

参考

.
[1]: https://blog.csdn.net/wwangfabei1989/article/details/80401272
[2]: https://github.com/sparklingpandas/sparklingpandas/wiki/setup.py-Install-for-Anaconda-Python

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