• 在运行集成学习的多数投票分类代码时,出现错误
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. sqlserver2008 必知必会技巧-- 快速索引对象

    对象资源管理器里面 -- 数据库 -- 表目录 ,然后按 f7 弹出 对象资源管理详细信息 , 里面有搜索栏 , 可以 使用 % 进行模糊查询 例如我们查包含 student的表 %student% ...

  2. 使用Lombok来优雅的编码

    介绍在项目中使用Lombok可以减少很多重复代码的书写.比如说getter/setter/toString等方法的编写. IDEA中的安装打开IDEA的Setting –> 选择Plugins选 ...

  3. NSUserDefaults的用法

    NSUserDefaults适合存储轻量级的本地数据,比如要保存一个登陆界面的数据,用户名.密码之类的,个人觉得使用NSUserDefaults是首选.下次再登陆的时候就可以直接从NSUserDefa ...

  4. zencart前台小语种后台英文 导入批量表 前后台不显示产品的问题

    admin\includes\init_includes\init_languages.php 前台小语种后台英文导致批量表导入后,前后台不显示产品的问题将红色部分修改成前台语言对应的值,前台语言对应 ...

  5. ubuntu 添加新用户并赋予root权限

    1 sudo adduser wolbo 2 sudo vim /etc/sudoers root ALL=(ALL) ALLwolbo ALL=(ALL) ALL wolbo ALL=(ALL) N ...

  6. uboot initf_dm函数分析

    initf_dm, static int initf_dm(void){#if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN) / ...

  7. public class Ex2

    写出输出的结果 A. 10 2 3 4 5B. 1 2 3 4 5C. 10 2 3 4 5 0 0 0 0 0D. 1 2 3 4 5 00 0 0 0 package com.yirose.jav ...

  8. HDU-1045-Fire Net(最大匹配)

    链接: https://vjudge.net/problem/HDU-1045#author=zzuli_contest 题意: 假设我们有一个有直街的广场城市.城市地图是一个方形板,有n行和n列,每 ...

  9. 【NOIP2014模拟8.17】Magical GCD

    题目 对于一个由正整数组成的序列, Magical GCD 是指一个区间的长度乘以该区间内所有数字的最大公约数.给你一个序列,求出这个序列最大的 Magical GCD. 分析 根据暴力的思想, \( ...

  10. NOIP2016提高A组模拟9.17总结

    第一题,典型的隔板问题, 但是我忘记隔板问题怎么打,一开始在花了1小时,还是没想出来,果断弃疗, 最后的40分钟,我打完了第二题,接着又用了20分钟推敲出一种极其猥琐的式子来代替,可惜预处理的阶乘忘记 ...