安装lazypredict
点击 Anaconda Prompt
1.创建虚拟环境
conda create -n py3.9 python=3.9
2.激活虚拟环境
conda activate py3.9
3.安装lazypredict
pip3 install lazypredict==0.2.7 numpy pandas tqdm scikit-learn xgboost lightgbm
4.安装ipykernel (第一次导入虚拟环境的要下载)
pip install -i https://pypi.tuna./simple ipykernel
5.将虚拟环境py3.9导入jupyter的kernel中(自己设置显示的名字为python3.9)
python -m ipykernel install --name py3.9 --display-name python3.9
6.查看kernel
jupyter kernelspec list
7.修改配置文件
进入 D:\mystudysoft\Anaconda3\envs\py3.9\Lib\site-packages\lazypredict 目录下
修改Supervised.py文件
修改import部分
# from sklearn.utils.testing import all_estimatorsfrom sklearn.utils import all_estimators
在 removed_classifiers中修改如下内容
# sklearn.ensemble.gradient_boosting.GradientBoostingClassifiersklearn.ensemble.GradientBoostingClassifier# sklearn.gaussian_process.gpc.GaussianProcessClassifiersklearn.gaussian_process._gpc.GaussianProcessClassifier# sklearn.neural_network.multilayer_perceptron.MLPClassifiersklearn.neural_network.MLPClassifier# sklearn.linear_model.logistic.LogisticRegressionCVsklearn.linear_model.LogisticRegressionCV# sklearn.neighbors.classification.RadiusNeighborsClassifiersklearn.neighbors.RadiusNeighborsClassifier# sklearn.ensemble.voting.VotingClassifiersklearn.ensemble.VotingClassifier
在removed_regressors中修改如下内容
# removed_regressors = [('TheilSenRegressor', sklearn.linear_model.theil_sen.TheilSenRegressor),removed_regressors = [('TheilSenRegressor', sklearn.linear_model.TheilSenRegressor),# 去掉这一行('_SigmoidCalibration', sklearn.calibration._SigmoidCalibration)
保存退出
8.在jupyter中测试是否安装成功
选择python3.9
import lazypredictfrom lazypredict.Supervised import LazyRegressorfrom sklearn.datasets import load_breast_cancerfrom sklearn.model_selection import train_test_splitdata = load_breast_cancer()x = data.datay = data.targetx_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.退出当前虚拟环境(anaconda返回至base):
conda deactivate
2.查看当前环境中有哪些包
conda list
3.查看当前有哪些虚拟环境
conda info --envs
4.删除虚拟环境(py3.9是虚拟环境名)
conda remove -n py3.9 --all
5.删除内核(python3.9是环境名)
jupyter kernelspec remove python3.9