• 在运行集成学习的多数投票分类代码时,出现错误
from sklearn import datasets
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import VotingClassifier
iris = datasets.load_iris()
X, y = iris.data[:, 1:3], iris.target
clf1 = LogisticRegression(solver='lbfgs', multi_class='multinomial', random_state=1)
clf2 = RandomForestClassifier(n_estimators=50, random_state=1)
clf3 = GaussianNB() ensemble_clf = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb',clf3)], voting='hard')
for clf, label in zip([clf1, clf2, clf3, ensemble_clf], ['Logistic Regression', 'Random Forest', 'naive Bayes', 'Ensemble']):
scores = cross_val_score(clf, X, y, cv = 5, scoring='accuracy')
# scoring里面的有效参数有['accuracy', 'adjusted_rand_score', 'average_precision', 'f1', 'f1_macro', 'f1_micro', 'f1_samples',
# 'f1_weighted', 'neg_log_loss', 'neg_mean_absolute_error', 'neg_mean_squared_error', 'neg_median_absolute_error',
# 'precision', 'precision_macro', 'precision_micro', 'precision_samples', 'precision_weighted',
# 'r2', 'recall', 'recall_macro', 'recall_micro', 'recall_samples', 'recall_weighted', 'roc_auc']
print('Accuracy: %0.2f (+/- %0.2f) ------- %s' %(scores.mean(), scores.std(), label))
  • 运行结果

  • 出错原因

如果遇到错误:ImportError: DLL load failed: 找不到指定的模块

出现错误原因:安装包的来源问题,也可以理解为包版本兼容问题,有的包使用官方出版,有的包使用whl文件安装

解决方案:将所有包都统一来源,要么全部使用官方出版的包,要么全部使用whl里面的包,问题就解决了

解决方法

  • (1)先卸载原始版本Scikit-Learn,Numpy和Scipy

pip uninstall scikit-learn

pip uninstall numpy

pip uninstall scipy

pip install numpy-1.16.5+mkl-cp36-cp36m-win_amd64.whl

pip install scipy-1.3.3-cp36-cp36m-win_amd64.whl

pip install scikit_learn-0.21.3-cp36-cp36m-win_amd64.whl



  • 重新运行上述代码 成功运行

参考资料1:https://www.cnblogs.com/hamish26/p/10985139.html

参考资料2:https://blog.csdn.net/a593651986/article/details/72178463

from sklearn import datasets运行错误:ImportError: DLL load failed: 找不到指定的程序------解决办法的更多相关文章

  1. python中导入sklearn中模块提示ImportError: DLL load failed: 找不到指定的程序。

    python版本:3.7 平台:windows 10 集成环境:Anaconda3.7 64位 在jupyter notebook中导入sklearn的相关模块提示ImportError: DLL l ...

  2. Scrapy模块使用出错,出现builtins.ImportError: DLL load failed: 找不到指定的程序

    问题描述:初次学习scrapy,使用scrapy官方文档创建爬虫项目出错, 出现builtins.ImportError: DLL load failed: 找不到指定的程序, ImportError ...

  3. 关于python 3.x import matplotlib as plt ImportError: DLL load failed: 找不到指定的模块

    windows 10下使用conda update --all更新过后,就出现这样的问题了,各种包不能用了,然后在stackoverflow上搜到有人也遇到相同的问题,并通过其中的回答找到了原因,这里 ...

  4. 问题解决:import paddle.fluid出错:DLL load failed: 找不到指定的模块

    问题描述: 使用Pycharm编程,导入paddlepaddle库出错.即:import paddle.fluid出错:DLL load failed: 找不到指定的模块 解决方法: 补上缺失的DLL ...

  5. 运行Scrapy项目提示“import win32api ImportError: DLL load failed: 找不到指定的模块。”

    安装完成Scrapy时候,终端导入Scrapy时候,发现没有任何报错,但是在运行Scrapy的项目的时候提示“import win32api ImportError: DLL load failed: ...

  6. ImportError: DLL load failed: 找不到指定的模块;ImportError: numpy.core.multiarray failed to import 报错解决

    python程序运行出错,出错的两行主要信息如下: ImportError: DLL load failed: 找不到指定的模块 ImportError: numpy.core.multiarray ...

  7. 终于解决了python 3.x import cv2 “ImportError: DLL load failed: 找不到指定的模块” 及“pycharm关于cv2没有代码提示”的问题

    终于解决了python 3.x import cv2 “ImportError: DLL load failed: 找不到指定的模块” 及“pycharm关于cv2没有代码提示”的问题   参考 :h ...

  8. from .cv2 import * ImportError: DLL load failed: 找不到指定的模块。 >>>

    from .cv2 import * ImportError: DLL load failed: 找不到指定的模块. >>> 昨天看项目的时候遇到这个问题,折腾到深夜,网上的各种方法 ...

  9. from _sqlite3 import * ImportError: DLL load failed: 找不到指定的模块。

    *Error creating Django application: Error on python side. Exit code: 1, err: Traceback (most recent ...

随机推荐

  1. QtSpim使用Tips

    QtSpim使用记录 垃圾QtSpim,输入中文会死机 MIPS的中文资料奇缺,如果有问题建议google参考英文资料,许多外国大学的网站上有对MIPS各方面的详细介绍 QtSpim是MIPS处理器的 ...

  2. java.lang.IllegalArgumentException: id to load is required for loading

    java.lang.IllegalArgumentException: id to load is required for loading at org.hibernate.event.LoadEv ...

  3. 三、Vue CLI-单页面

    一.单页面 代码如下: <template> <div class="header">{{title}}</div> </template ...

  4. 使用switchshow/supportshow命令确认Brocade交换机型号(转载)

    switchshow命令(或supportshow日志)中的switchType是以数字来代表不同的交换机型号,完整的对应表格如下: Switchtype EMC / Brocade名称 / 端口 / ...

  5. Instr()函数用法

    返回 Variant (Long),指定一字符串在另一字符串中最先出现的位置. 语法 InStr([start, ]string1, string2[, compare]) InStr 函数的语法具有 ...

  6. (转) Windows下MySQL免安装版的下载与配置

    本人在尊重原著的前提下.针对在实践中所遇到的问题加以整理和完善,如有不足之处,还请各位大神指点江山O(∩_∩)O~ 主要是因为平时自己学习时候会用到.及免安装版本的方便.对于个人开发者挺实用的! 安装 ...

  7. Codeforces 987 K预处理BFS 3n,7n+1随机结论题/不动点逆序对 X&Y=0连边DFS求连通块数目

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  8. Ubuntu打开中文输入法

    方法/步骤: 1.从system settings 进入language support 在keyboard input method system 中选择 ibus (这里以ibus为例) 然后cl ...

  9. Python核心技术与实战——十七|Python并发编程之Futures

    不论是哪一种语言,并发编程都是一项非常重要的技巧.比如我们上一章用的爬虫,就被广泛用在工业的各个领域.我们每天在各个网站.App上获取的新闻信息,很大一部分都是通过并发编程版本的爬虫获得的. 正确并合 ...

  10. ansj分词器使用记录

    //最简单实例 String ruiec = “分词测试123456100名”; //剔除指定的分词 s.insertStopWords("100名"); //剔除标点符号(w) ...