模型越复杂越容易惰性

Hey, hope you are having a wonderful day!

嘿,希望您今天过得愉快!

Whenever I work on a new ML project. These lines always pop up in my mind every time

每当我从事新的ML项目时。 这些线每次都会在我的脑海中弹出

“I need to fit the data for every model then apply metrics to check which model has better accuracy for the available dataset ,then choose best model and also this process is time-consuming and even it might not be that much effective too“

“我需要为每个模型拟合数据,然后应用度量标准来检查哪个模型对可用数据集具有更好的准确性,然后选择最佳模型,而且此过程非常耗时,甚至可能效果也不那么好”

For this problem, I got a simple solution when surfing through python org, which is a small python library by name “lazypredict” and it does wonders

对于这个问题,我在通过python org进行浏览时得到了一个简单的解决方案,这是一个名为“ lazypredict”的小型python库,它的确令人惊讶

Let me tell you how it works:-

让我告诉你它是如何工作的:

安装库 (Install the library)

pip install lazypredict

注意 (Note)

  1. lazypredict only works for python version≥3.6lazypredict仅适用于Python版本≥3.6
  2. It's built on top of various other libraries so if you don't have those libraries in the system, python will throw ModuleError so interpret the error properly and install the required libraries.它建立在其他各种库的基础上,因此,如果系统中没有这些库,则python会抛出ModuleError,从而正确解释错误并安装所需的库。

lazypredict comes only for supervised learning (Classification and Regression)

lazypredict仅用于监督学习(分类和回归)

I will be using jupyter notebook in this article

我将在本文中使用Jupyter Notebook

码 (Code)

# import necessary modulesimport warningswarnings.filterwarnings('ignore')import time from sklearn.datasets import load_iris,fetch_california_housingfrom sklearn.model_selection import train_test_splitfrom lazypredict.Supervised import LazyClassifier,LazyRegressor
  • warnings: Package to handle warnings and ‘ignore’ is used when we need to filter out all the warnings警告:处理警告和“忽略”的包在我们需要过滤掉所有警告时使用
  • time: Package to handle time manipulationtime:处理时间的软件包
  • sklearn.datasets: Package to load datasets, today we gonna use the classic datasets which everyone works on it that are load_iris() for classification problem and fetch_california_housing() for a regression problemsklearn.datasets:打包以加载数据集,今天我们将使用每个人都可以处理的经典数据集,其中load_iris()用于分类问题,而fetch_california_housing()用于回归问题。
  • sklearn.model_selection.train_test_split:Used to split the dataset into train and splitsklearn.model_selection.train_test_split:用于将数据集拆分为训练并拆分
  • lazypredict:this is the package we gonna learn today in lazypredict.Supervised there are two main functions LazyClassifier for Classification and LazyRegressor for Regressionlazypredict:这是我们今天将要在lazypredict中学习的软件包。在监督下,有两个主要功能用于分类的LazyClassifier和用于回归的LazyRegressor

惰性分类器 (LazyClassifier)

# load the iris datasetdata=load_iris()X=data.dataY=data.target
  • The data is a variable with dictionary data type where there are two keys the data which contains independent features/column values and target which contains dependent feature value数据是具有字典数据类型的变量,其中有两个键,数据包含独立的要素/列值,目标包含相关的要素值
  • X has all the independent features valuesX具有所有独立特征值
  • Y has all the dependent features valuesY具有所有从属特征值
# split the dataset X_train, X_test, Y_train, Y_test =train_test_split(X,Y,test_size=.3,random_state =23)classi=LazyClassifier(verbose=0,predictions=True)
  • We will split the data into train and test using train_test_split()我们将数据分为train和使用train_test_split()进行测试
  • The test size will be 0.3(30%) of the dataset测试大小将为数据集的0.3(30%)
  • random_state will decide the splitting of data into train and test indices just choose any number you like!random_state将决定将数据拆分为训练索引和测试索引,只需选择您喜欢的任何数字即可!

Tip 1:If you want to see source code behind any function or object in the jupyter notebook then just add ? or ?? after the object or the function you want to check out and excute it

提示1:如果要查看jupyter笔记本中任何函数或对象背后的源代码,则只需添加? 要么 ?? 在要检出并执行的对象或功能之后

  • Next, we will call LazyClassifier() and initialize to classic with two parameters verbose and prediction接下来,我们将调用LazyClassifier()并使用详细信息和预测两个参数将其初始化为经典
  • verbose: int data type, if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level. If it more than 10, all iterations are reported. I would suggest you try different values based on your depth of analysis详细:int数据类型,如果非零,则显示进度消息。 高于50时,输出将发送到stdout。 消息的频率随着详细程度而增加。 如果大于10,则报告所有迭代。 我建议您根据您的分析深度尝试其他值
  • predictions: boolean data type if it is set to True then it will return all the predicted values from the models预测:布尔数据类型,如果将其设置为True,则它将返回模型中的所有预测值
# fit and train the model start_time_1=time.time()models_c,predictions_c=classi.fit(X_train, X_test, Y_train, Y_test)end_time_1=time.time()
  • we gonna fit train and test data to the classi object我们将训练和测试数据拟合到classi对象
  • classic will return two values:经典版将返回两个值:
  • models_c: will have all the models and with some metricsmodels_c:将具有所有模型并具有一些指标
  • predictions_c: will have all the predicted values that is ŷ

    projections_c :将具有所有预测值ŷ

# to check which model did better on the iris dataset models_c
model_c output
model_c输出
  • To be honest I didn't know some of these models even exist for classification until I saw this老实说,我不知道其中一些模型可以分类,直到我看到了
  • I know that your mind would be thinking why is ROC AUC is None is this function not giving proper output nope that's not the case here, ROC AUC is None because we have taken multi-classification dataset我知道您的大脑会在思考为什么ROC AUC为None是该函数没有提供适当的输出空间吗,这里不是这种情况,ROC AUC为None是因为我们采用了多分类数据集

Tip 2: For the above dataset or multi-classification we can use roc_auc_score rather than ROC AUC

提示2:对于上述数据集或多分类,我们可以使用roc_auc_score而不是ROC AUC

# to check the predications for the models predictions_c
predictions_c output
projections_c输出
  • This is just a few sample predictions from the models这只是来自模型的一些样本预测

惰性回归器 (LazyRegressor)

  • So we checked out LazyClassifier it will be sad if we didn't pay some attention to LazyRegressor因此,我们检查了LazyClassifier,如果我们不注意LazyRegressor将会很可惜
  • The following code is similar to LazyClassifier so let's pick up the phase and skip some explanations以下代码与LazyClassifier相似,因此让我们开始阶段并跳过一些解释。
# load the fetch_california_housing datasetdata1=fetch_california_housing()X1=data1.dataY1=data1.target
  • data1 is dict data type with data and target as keysdata1是dict数据类型,数据和目标为键
# split the dataset X_train1, X_test1, Y_train1, Y_test1 =train_test_split(X1,Y1,test_size=.3,random_state =23)regr=LazyRegressor(verbose=0,predictions=True)
  • after fitting the model next we will train拟合模型之后,我们将进行训练
# fit and train the model start_time_2=time.time()models_r,predictions_r=regr.fit(X_train1, X_test1, Y_train1, Y_test1)end_time_2=time.time()

注意 (Note)

1. Before running the above cell make sure you clear all the unnecessary background process because it takes a lot of computation power

1.在运行上面的单元格之前,请确保清除所有不必要的后台进程,因为这需要大量的计算能力

2. I would suggest if you have low computation power(RAM, GPU) then use Google Colab, This is the simplest solution you can get

2.我建议如果您的计算能力(RAM,GPU)低,那么请使用Google Colab,这是您可以获得的最简单的解决方案

# to check which model did better on the fetch_california_housing datasetmodels_r
models_r output
models_r输出
  • And again I didn't know there were so many models for regression再一次,我不知道有这么多回归模型
# to check the predications for the models predictions_r
predictions_r output
projections_r输出

时间复杂度 (Time Complexity)

  • We should talk about time complexity because that's the main goal for all us to reduce it as much as possible我们应该谈论时间复杂性,因为这是我们所有人尽可能降低时间的主要目标
# time complexity print("The time taken by LazyClassifier for {0} samples is {1} ms".format(len(data.data),round(end_time_1-start_time_1,0)))print("The time taken by LazyRegressor for {0} samples is {1} ms".format(len(data1.data),round(end_time_2-start_time_2,0)))
time complexity output
时间复杂度输出

Tip 3: Add %%time to check the execution time of the current jupyter cell

提示3:添加%% time以检查当前jupyter单元的执行时间

注意 (Note)

  • Use this library in the first iteration of your ML project before hypertunning models在对模型进行超调整之前,请在ML项目的第一个迭代中使用此库
  • lazypredict only works for Python versions ≥3.6lazypredict仅适用于Python版本≥3.6
  • If you don’t have the computational power just use Google colab如果您没有计算能力,请使用Google colab

The Github link is here for the code.

Github链接在此处提供代码。

If you want to read the official docs

如果您想阅读官方文档

That's all the things you need to know about lazypredict library for now

这就是您现在需要了解的关于lazypredict库的所有信息

Hope you learned new things from this article today and will help you to make your ML projects a bit easier

希望您今天从本文中学到了新东西,并可以帮助您简化ML项目

Thank you for dedicating a few mins of your day

感谢您奉献您的几分钟时间

If you have any doubts just comment down below I will be happy to help you out!

如果您有任何疑问,请在下方留言,我们将竭诚为您服务!

Thank you!

谢谢!

-Mani

-马尼

翻译自: https://medium.com/swlh/lazy-predict-for-ml-models-c513a5daf792

模型越复杂越容易惰性


http://www.taodudu.cc/news/show-863566.html

相关文章:

  • vgg 名人人脸图像库_您看起来像哪个名人? 图像相似度搜索模型
  • 机器学习:贝叶斯和优化方法_Facebook使用贝叶斯优化在机器学习模型中进行更好的实验
  • power-bi_在Power BI中的VertiPaq内-压缩成功!
  • 模型 标签数据 神经网络_大型神经网络和小数据的模型选择
  • 学习excel数据分析_为什么Excel是学习数据分析的最佳方法
  • 护理方面关于人工智能的构想_如何提出惊人的AI,ML或数据科学项目构想。
  • api数据库管理_API管理平台如何增强您的数据科学项目
  • batch lr替代关系_建立关系的替代方法
  • ai/ml_您本周应阅读的有趣的AI / ML文章(8月9日)
  • snowflake 使用_如何使用机器学习模型直接从Snowflake进行预测
  • 统计 python_Python统计简介
  • ios 图像翻转_在iOS 14中使用计算机视觉的图像差异
  • 熔池 沉积_用于3D打印的AI(第3部分):异常熔池分类的纠缠变分自动编码器
  • 机器学习中激活函数和模型_探索机器学习中的激活和丢失功能
  • macos上的硬盘检测工具_如何在MacOS上使用双镜头面部检测器(DSFD)实现90%以上的精度
  • 词嵌入应用_神经词嵌入的法律应用
  • 谷歌 colab_使用Google Colab在Python中将图像和遮罩拆分为多个部分
  • 美国人口普查年收入比赛_训练网络对收入进行分类:成人普查收入数据集
  • NLP分类
  • 解构里面再次解构_解构后的咖啡:焙炒,研磨和分层,以获得更浓的意式浓缩咖啡
  • 随机森林算法的随机性_理解随机森林算法的图形指南
  • 南加州大学机器视觉实验室_机器学习带动南加州爱迪生的变革
  • 机器学习特征构建_使用Streamlit构建您的基础机器学习Web应用
  • 数学建模算法:支持向量机_从零开始的算法:支持向量机
  • 普元部署包部署找不到构建_让我们在5分钟内构建和部署AutoML解决方案
  • 基于决策树的多分类_R中基于决策树的糖尿病分类—一个零博客
  • csdn无人驾驶汽车_无人驾驶汽车100年历史
  • 无监督学习 k-means_无监督学习-第2部分
  • regex 正则表达式_使用正则表达式(Regex)删除HTML标签
  • 精度,精确率,召回率_了解并记住精度和召回率

模型越复杂越容易惰性_ML模型的惰性预测相关推荐

  1. 交叉熵损失函数的通用性(为什么深度学习DL普遍用它):预测输出与 y 差得越多,L 的值越大,也就是说对当前模型的 “ 惩罚 ” 越大,而且是非线性增大是一种类似指数增长的级别,结论:它对结果有引导性

    交叉熵损失函数的通用性(为什么深度学习DL普遍用它):预测输出与 y 差得越多,L 的值越大,也就是说对当前模型的 " 惩罚 " 越大,而且是非线性增大是一种类似指数增长的级别,结 ...

  2. 推荐模型是怎样由窄变宽、越变越深的?

    星标/置顶小屋,带你解锁 最萌最前沿的NLP.搜索与推荐技术 文 | 邢智皓 编 | 兔子酱 当前,深度学习推荐模型已经成功应用于推荐.广告.搜索等领域,但在了解它之前,简单回顾传统推荐模型仍是有必要 ...

  3. 空间计量模型_Stata中的空间计量回归模型应用

    在Stata 15中,推出了最新的空间计量官方命令,均以sp开头,表示 spatial data),可以处理横截面与面板形式的空间数据.本文主要为大家介绍空间计量横截面及面板模型的应用,全文分为两部分 ...

  4. 【AI初识境】深度学习模型评估,从图像分类到生成模型

    文章首发于微信公众号<有三AI> [AI初识境]深度学习模型评估,从图像分类到生成模型 这是<AI初识境>第10篇,这次我们说说深度学习模型常用的评价指标.所谓初识,就是对相关 ...

  5. 【经验】刚读硕士怎么感觉学机器学习和深度学习越学越不懂?

    有同学问:研一,在学机器学习和深度学习,为什么感觉越学越不会,怎么解决这个问题? 我搜集了一些意见和建议,供参考. 高赞回答一 作者:曲終人不散丶 来源:知乎 我的研一我记得是先找了一本比较薄的,通俗 ...

  6. transformer模型_【经典精读】Transformer模型深度解读

    文字长度: ★★★★★ 阅读难度: ★★☆☆☆ 原创程度: ★★★★☆ Transformer是2017年的一篇论文<Attention is All You Need>提出的一种模型架构 ...

  7. matlab画地震复杂模型,基于MATLAB的地震正演模型实现

    总 第 237 期2009 年 第 7 期计 算 机 与 数 字 工 程 37 7132 基 于 L 地 震 正 演 模 型 实 现 3贾 跃 玮 1) 杨 锐 2)(中 国 地 质 大 学 地 下 ...

  8. revit模型怎么在手机上看_沙盘模型应该怎么看?一定要警惕这些问题

    买期房的话肯定会经历看沙盘模型这个步骤,虽然说沙盘模型只是呈现楼盘整体规划的一种设计,时机验收房屋可能存在差别,但是买房子还是应该结合沙盘来选房子的,毕竟关系到自己今后的居住环境,在售楼处展示的东西里 ...

  9. 不等距双杆模型_搜索中的深度匹配模型(下)

    由于知乎字数限制,单篇文章字数限制不超过5万字,这篇文章主要为上一篇的延续 前文链接: 搜索中的深度匹配模型 4.3 match function模型总结 5.搜索中query和doc的相关性匹配模型 ...

最新文章

  1. [转] Leaving patterns practices
  2. java接口匿名内部类_JAVA技术分享:接口,内部类,匿名内部类
  3. Spring aop 实现异常拦截
  4. 实验三 循环结构设计
  5. mysql tcp ip_通过TCP/IP连接Mysql数据库
  6. c++ ftp服务端_FTP客户端软件介绍及使用
  7. TCP 协议的三次握手、四次分手
  8. Pytest自定义标记mark及特定运行方式
  9. 机器学习之欠拟合与过拟合
  10. mac上sublime配置php环境,Mac下sublime text3如何配置php编译环境?
  11. 基于人人网的简单爬虫(一)——正则表达式
  12. python函数拟合求导_python – 使用scipy curve_fit通过两个数据点拟合指数函数
  13. APT***实例研究与企业现有防御体系缺陷分析
  14. mac nginx映射ip和端口_南京课工场IT培训:Nginx虚拟主机 (基于域名 基于端口 基于ip)...
  15. 任鑫:提前布局,不做轻公司
  16. js鼠标经过切换图片
  17. 设计模式-外观模式(家庭影院你值得拥有)
  18. http://blog.csdn.net/pizi0475/article/details/48286579 -------------(Collada 快速入门)
  19. ubuntu unity 3D桌面效果
  20. 伦敦大学国王学院 计算机phd,伦敦大学国王学院招收博士(CSC资助博士或者NUS/HKU与KCL联培博士) - 公派出国 - 小木虫 - 学术 科研 互动社区...

热门文章

  1. 网络转型临界点 带你看瞻博网络的创新步伐
  2. 《开源思索集》一黑客的胜利——读《增长黑客》有感
  3. C++Builder 2010深入TApplication类之属性
  4. 浅析商业银行“业务连续性管理体系”的构建
  5. IntelliJ idea 12的初次约会
  6. 企业能为员工储蓄点什么呢
  7. python操作mongodb语法_python操作mongodb怎么找到所有的集合
  8. cocos2d 屏幕適配_Cocos2d-x 3.1 一步步做屏幕适配
  9. java 程序执行后 强制gc_【GC系列】JVM的常用GC参数及GC日志解析
  10. CIKM 2021 | 多场景下的星型CTR预估模型STAR