• anaconda ( jupyter notebook ) 虚拟环境安装 lazypredict


    安装lazypredict

    点击 Anaconda Prompt
    在这里插入图片描述

    1.创建虚拟环境

    conda create -n py3.9 python=3.9
    
    • 1

    2.激活虚拟环境

    conda activate py3.9
    
    • 1

    3.安装lazypredict

    pip3 install lazypredict==0.2.7 numpy pandas tqdm scikit-learn xgboost lightgbm
    
    • 1

    4.安装ipykernel (第一次导入虚拟环境的要下载)

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ipykernel
    
    • 1

    5.将虚拟环境py3.9导入jupyter的kernel中(自己设置显示的名字为python3.9)

    python -m ipykernel install --name py3.9 --display-name python3.9
    
    • 1

    6.查看kernel

    jupyter kernelspec list
    
    • 1

    7.修改配置文件

    进入 D:\mystudysoft\Anaconda3\envs\py3.9\Lib\site-packages\lazypredict 目录下

    修改Supervised.py文件

    修改import部分

    # from sklearn.utils.testing import all_estimators
    from sklearn.utils import all_estimators
    
    • 1
    • 2

    在 removed_classifiers中修改如下内容

    # sklearn.ensemble.gradient_boosting.GradientBoostingClassifier
    sklearn.ensemble.GradientBoostingClassifier
    
    # sklearn.gaussian_process.gpc.GaussianProcessClassifier
    sklearn.gaussian_process._gpc.GaussianProcessClassifier
    
    # sklearn.neural_network.multilayer_perceptron.MLPClassifier
    sklearn.neural_network.MLPClassifier
    
    # sklearn.linear_model.logistic.LogisticRegressionCV
    sklearn.linear_model.LogisticRegressionCV
    
    # sklearn.neighbors.classification.RadiusNeighborsClassifier
    sklearn.neighbors.RadiusNeighborsClassifier
    
    # sklearn.ensemble.voting.VotingClassifier
    sklearn.ensemble.VotingClassifier
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    在removed_regressors中修改如下内容

    # removed_regressors = [('TheilSenRegressor', sklearn.linear_model.theil_sen.TheilSenRegressor),
    removed_regressors = [('TheilSenRegressor', sklearn.linear_model.TheilSenRegressor),
    
    # 去掉这一行
    ('_SigmoidCalibration', sklearn.calibration._SigmoidCalibration)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    保存退出

    8.在jupyter中测试是否安装成功

    选择python3.9
    在这里插入图片描述

    import lazypredict
    from lazypredict.Supervised import LazyRegressor
    from sklearn.datasets import load_breast_cancer
    from sklearn.model_selection import train_test_split
    data = load_breast_cancer()
    x = data.data
    y = data.target
    x_train,x_test,y_train, y_test = train_test_split(x,y,test_size =.5,random_state =123)
    clf = LazyRegressor(verbose=0,ignore_warnings=True, custom_metric=None)
    models,predictions = clf.fit(x_train, x_test, y_train, y_test)
    print(models)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    在这里插入图片描述

    其他的命令

    1.退出当前虚拟环境(anaconda返回至base):

    conda deactivate
    
    • 1

    2.查看当前环境中有哪些包

    conda list
    
    • 1

    3.查看当前有哪些虚拟环境

    conda info --envs
    
    • 1

    4.删除虚拟环境(py3.9是虚拟环境名)

    conda remove -n py3.9 --all
    
    • 1

    5.删除内核(python3.9是环境名)

    jupyter kernelspec remove python3.9
    
    • 1
  • 相关阅读:
    关于windows上运行bitsandbytes老是报错的(说cuda版本有问题)解决方案
    【小程序】解决浮点数精度损失问题
    第3章:运行时数据区概述及线程 详细详解
    考研回忆录【二本->211】
    React 中的 ref 如何操作 dom节点,使输入框获取焦点
    编译速度谁“最快”?25岁的 C++Builder 还能打
    基于音视频通信产品的点对点视频呼叫方案
    2. 计算WPL
    白鹭群优化算法(ESOA)附matlab代码
    leetcode:189. 轮转数组(python3解法)
  • 原文地址:https://blog.csdn.net/qq_52691614/article/details/128112380