機器學習 綜合評價_PyCaret:機器學習綜合

機器學習 綜合評價

Any Machine Learning project journey starts with loading the dataset and ends (continues ?!) with the finalization of the optimum model or ensemble of models for predictions on unseen data and production deployment.

任何機器學習項目的旅程都始于加載數據集,然后結束(繼續?!),最后確定最佳模型或模型集合,以預測看不見的數據和生產部署。

As machine learning practitioners, we are aware that there are several pit stops to be made along the way to arrive at the best possible prediction performance outcome. These intermediate steps include Exploratory Data Analysis (EDA), Data Preprocessing — missing value treatment, outlier treatment, changing data types, encoding categorical features, data transformation, feature engineering /selection, sampling, train-test split etc. to name a few — before we can embark on model building, evaluation and then prediction.

作為機器學習的從業者,我們意識到在達到最佳預測性能結果的過程中,有幾個進站。 這些中間步驟包括探索性數據分析(EDA),數據預處理-缺失值處理,離群值處理,更改數據類型,編碼分類特征,數據轉換,特征工程/選擇,采樣,訓練測試拆分等,僅舉幾例-在我們開始進行模型構建,評估然后進行預測之前。

We end up importing dozens of python packages to help us do this and this means getting familiar with the syntax and parameters of multiple function calls within each of these packages.

我們最終導入了數十個python軟件包來幫助我們完成此操作,這意味著要熟悉每個軟件包中的多個函數調用的語法和參數。

Have you wished that there could be a single package that can handle the entire journey end to end with a consistent syntax interface? I sure have!

您是否希望有一個包可以使用一致的語法接口來處理整個旅程,從頭到尾? 我肯定有!

輸入PyCaret (Enter PyCaret)

These wishes were answered with PyCaretpackage and it is now even more awesome with the release of pycaret2.0.

PyCaret軟件包滿足了這些愿望,現在pycaret2.0的發布pycaret2.0更加令人敬畏。

Starting with this Article, I will post a series on how pycaret helps us zip through the various stages of an ML project.

從本文開始,我將發布一系列有關pycaret如何幫助我們完成ML項目各個階段的文章。

安裝 (Installation)

Installation is a breeze and is over in a few minutes with all dependencies also being installed. It is recommended to install using a virtual environment like python3 virtualenv or conda environments to avoid any clash with other pre-installed packages.

安裝輕而易舉,幾分鐘后就結束了,同時還安裝了所有依賴項。 建議使用虛擬環境(例如python3 virtualenv或conda環境)進行安裝,以免與其他預裝軟件包沖突。

pip install pycaret==2.0

pip install pycaret==2.0

Once installed, we are ready to begin! We import the package into our notebook environment. We will take up a classification problem here. Similarly, the respective PyCaret modules can be imported for a scenario involving regression, clustering, anomaly detection, NLP and Association rules mining.

安裝完成后,我們就可以開始了! 我們將包導入到筆記本環境中。 我們將在這里處理分類問題。 同樣,可以針對涉及回歸,聚類,異常檢測,NLP和關聯規則挖掘的方案導入相應的PyCaret模塊。

Image for post

We will use the titanic dataset from kaggle.com. You can download the dataset from here.

我們將使用來自kaggle.com的titanic數據集。 您可以從此處下載數據集。

Image for post

Let's check the first few rows of the dataset using the head() function:

讓我們使用head()函數檢查數據集的前幾行:

Image for post
Image for post

建立 (Setup)

The setup() function of pycaret does most — correction, ALL, of the heavy-lifting, that normally is otherwise done in dozens of lines of code — in just a single line!

pycaretsetup()函數pycaret完成大部分工作-校正,全部進行繁重的工作,否則通常只需要一行幾十行代碼即可完成!

Image for post

We just need to pass the dataframe and specify the name of the target feature as the arguments. The setup command generates the following output.

我們只需要傳遞數據框并指定目標要素的名稱作為參數即可。 setup命令生成以下輸出。

Image for post

setup has helpfully inferred the data types of the features in the dataset. If we agree to it, all we need to do is hit Enter . Else, if you think the data types as inferred by setup is not correct then you can type quit in the field at the bottom and go back to the setup function to make changes. We will see how to do that shortly. For now, lets hit Enter and see what happens.

setup有助于推斷數據集中要素的數據類型。 如果我們同意,則只需按Enter 。 否則,如果您認為由setup程序推斷出的數據類型不正確,則可以在底部的字段中鍵入quit ,然后返回到setup功能進行更改。 我們將很快看到如何做。 現在,讓我們Enter ,看看會發生什么。

Image for post
output contd.,
輸出續
Image for post
output continued below
輸出繼續低于
Image for post
end of output
輸出結束

Whew! A whole lot seems to have happened under the hood in just one line of innocuous-looking code! Let's take stock:

ew! 似乎只有一行無害的代碼在幕后發生了很多事情! 讓我們盤點一下:

  • checked for missing values

    檢查缺失值
  • identified numeric and categorical features

    確定的數字和分類特征
  • created train and test data sets from the original dataset

    從原始數據集中創建訓練和測試數據集
  • imputed missing values in continuous features with mean

    連續特征中的插補缺失值
  • imputed missing values in categorical features with a constant value

    具有恒定值的分類特征中的推定缺失值
  • done label-encoding

    完成標簽編碼
  • ..and a whole host of other options seem to be available including outlier treatment, data scaling, feature transformation, dimensionality reduction, multi-collinearity treatment, feature selection and handling imbalanced data etc.!

    ..以及似乎還有許多其他選擇,包括異常值處理,數據縮放,特征轉換,降維,多重共線性處理,特征選擇和處理不平衡數據等!

But hey! what is that on lines 11 & 12? The number of features in the train and test datasets are 1745? Seems to be a case of label encoding gone berserk most probably from the categorical features like name, ticket and cabin. Further in this article and in the next, we will look at how we can control the setup as per our requirements to address such cases proactively.

但是,嘿! 第11和12行是什么? 訓練和測試數據集中的要素數量為1745? 似乎是標簽編碼的一種情況,很可能是從nameticketcabin等分類特征中消失了。 在本文的下一部分和下一部分中,我們將研究如何根據我們的要求控制設置,以主動解決此類情況。

定制setup (Customizing setup)

To start with how can we exclude features from model building like the three features above? We pass the variables which we want to exclude in the ignore_features argument of the setup function. It is to be noted that the ID and DateTime columns, when inferred, are automatically set to be ignored for modelling.

首先,我們如何像上面的三個功能那樣從模型構建中排除功能? 我們在setup函數的ignore_features參數中傳遞要排除的變量。 要注意的是,ID和DateTime列在推斷時會自動設置為忽略以進行建模。

Image for post

Note below that pycaret, while asking for our confirmation has dropped the above mentioned 3 features. Let's click Enter and proceed.

請注意,在pycaret下方,要求我們確認時已刪除了上述3個功能。 讓我們單擊Enter并繼續。

Image for post

In the resultant output (the truncated version is shown below), we can see that post setup, the dataset shape is more manageable now with label encoding done only of the remaining more relevant categorical features:

在結果輸出中(截斷的版本如下所示),我們可以看到設置后,現在僅使用其余更相關的分類特征進行標簽編碼,就更易于管理數據集形狀:

Image for post

In the next Article in this series we will look in detail at further data preprocessing tasks we can achieve on the dataset using this single setup function of pycaret by passing additional arguments.

在本系列的下一篇文章中,我們將詳細介紹通過使用pycaret的單個setup功能通過傳遞附加參數可以對數據集完成的進一步數據預處理任務。

But before we go, let’s do a flash-forward to the amazing model comparison capabilities of pycaret using the compare_model() function.

但是在開始之前,讓我們使用compare_model()函數pycaret驚人的模型比較功能。

Image for post
Model performance compared on various classification metrics.
在各種分類指標上比較模型性能。

Boom! All it takes is just compare_models() to get the results of 15 classification modelling algorithms compared across various classification metrics on cross-validation. At a glance, we can see that CatBoost classifier performs best across most of the metrics with Naive-Bayes doing well on recall and Gradient Boosting on precision. The top-performing model for each metric is highlighted automatically by pycaret.

繁榮! 它所compare_models()只是compare_models()來獲得15種分類建模算法的結果,這些算法在交叉驗證的各個分類指標之間進行了比較。 一目了然,我們可以看到CatBoost分類器在大多數指標上表現最佳,其中Naive-Bayes在召回率方面表現出色,而在精度方面則表現出Gradient Boostingpycaret自動突出顯示每個指標的性能最高的模型。

Depending on the model evaluation metric(s) we are interested in pycaret helps us to straightaway zoom in on the top-performing model which we can further tune using the hyper-parameters. More on this in the upcoming Articles.

根據模型評估指標,我們對pycaret感興趣,可以幫助我們Swift放大性能最高的模型,我們可以使用超參數進一步對其進行調整。 在即將到來的文章中對此有更多的了解。

In conclusion, we have briefly seen glimpses of how pycaret can help us to fast track through the ML project life cycle through minimal code combined with extensive and comprehensive customization of the critical data pre-processing stages.

總之,我們已經簡要了解了pycaret如何通過最少的代碼以及對關鍵數據預處理階段的廣泛而全面的自定義,可以幫助我們快速跟蹤ML項目生命周期。

You may also be interested in my other articles on awesome packages that use minimal code to deliver maximum results in Exploratory Data Analysis(EDA) and Visualization.

您可能還對我的其他有關超棒軟件包的文章感興趣,這些文章使用最少的代碼來在探索性數據分析(EDA)和可視化中提供最大的結果。

Thanks for reading and would love to hear your feedback. Cheers!

感謝您的閱讀,并希望聽到您的反饋。 干杯!

翻譯自: https://towardsdatascience.com/pycaret-the-machine-learning-omnibus-dadf6e230f7b

機器學習 綜合評價

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388858.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388858.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388858.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

silverlight 3D 游戲開發

http://www.postvision.net/SilverMotion/DemoTech.aspx silverlight 3D 游戲開發 時間:2010-10-22 06:33來源:開心銀光 作者:黎東海 點擊: 562次意外發現一個silverlight的實時3D渲染引擎。性能比開源那些強很多。 而且支持直接加載maya,3Dmax等主流3D模型文件。 附件附上它的…

redis終端簡單命令

keys * 獲取所有鍵lRange hongbao:44 0 -1獲取該鍵的所有值del hongbao:44 刪除該鍵的所有值 hgetAll user:44 獲取該鍵的所有隊列hget hongbao:44 8 獲取該隊列用戶為8的值hset hongbao:44 7 asdf設置該隊列用戶為7的值hdel user:44 8 刪除該隊列用戶為8的值 flushall 清空red…

python中ix用法_Python中使用ix的數據幀子集

您可以使用X[var2].iloc[[0,1]]:In [280]: X[var2].iloc[[0,1]]Out[280]:0 NaN4 9Name: var2, dtype: float64由于X[var2]是X的視圖,因此X[var2].iloc[[0,1]]對兩者都是安全的訪問和分配。但是如果你使用這種“鏈式索引”要小心模式(例如這里使用的index…

LintCode 16. 帶重復元素的排列

寫在前面:這題和全排列不含重復元素的那題幾乎一樣,我比較垃圾,就用HashSet去掉了重復的元素但是看了九章算法的答案也沒看懂,他寫的很有感覺。 用了hash,本來想著怎么寫hashcode()和equal()方法的,哪知道都…

皮爾遜相關系數 相似系數_皮爾遜相關系數

皮爾遜相關系數 相似系數數據科學和機器學習統計 (STATISTICS FOR DATA SCIENCE AND MACHINE LEARNING) In the last post, we analyzed the relationship between categorical variables and categorical and continuous variables. In this case, we will analyze the relati…

【洛谷】P1641 [SCOI2010]生成字符串(思維+組合+逆元)

題目 傳送門&#xff1a;QWQ 分析 不想畫圖。 https://www.luogu.org/problemnew/solution/P1641 好神仙的題啊。 代碼 1 // luogu-judger-enable-o22 #include <bits/stdc.h>3 using namespace std;4 typedef long long ll;5 const int maxn15000000;6 const ll MOD2010…

Kubernetes持續交付-Jenkins X的Helm部署

Jenkins X 是一個集成化的 CI / CD 平臺&#xff0c;可用于 部署在Kubernetes集群或云計算中心。支持在云計算環境下簡單地開發和部署應用。本項目是在Kubernetes上的安裝支持工具集。 本工具集中包含&#xff1a; Jenkins - 定制好的流水線和運行環境&#xff0c;完全整合CI/C…

中國石油大學(華東)暑期集訓--二進制(BZOJ5294)【線段樹】

問題 C: 二進制 時間限制: 1 Sec 內存限制: 128 MB提交: 8 解決: 2[提交] [狀態] [討論版] [命題人:]題目描述 pupil發現對于一個十進制數&#xff0c;無論怎么將其的數字重新排列&#xff0c;均不影響其是不是3的倍數。他想研究對于二進制&#xff0c;是否也有類似的性質。于…

2018年10個最佳項目管理工具及鏈接

要在任何業務中取得成功&#xff0c;對項目進行適當的管理非常重要。 項目管理是一系列活動&#xff0c;包括計劃&#xff0c;執行&#xff0c;控制和完成項目。項目管理工具有助于簡化此過程。這里是Best 10項目管理工具及其功能和下載鏈接的精選列表。1&#xff09;AsanaAsan…

Java 8 新特性之Stream API

1. 概述 1.1 簡介 Java 8 中有兩大最為重要的改革&#xff0c;第一個是 Lambda 表達式&#xff0c;另外一個則是 Stream API&#xff08;java.util.stream.*&#xff09;。 Stream 是 Java 8 中處理集合的關鍵抽象概念&#xff0c;它可以指定你希望對集合進行的操作&#xff0c…

[Python設計模式] 第17章 程序中的翻譯官——適配器模式

github地址:https://github.com/cheesezh/python_design_patterns 適配器模式 適配器模式&#xff0c;將一個類的接口轉換成客戶希望的另外一個接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些類可以一起工作[DP]。 當系統的數據和行為都正確&#xff0c;但是接口…

Ubuntu中NS2安裝詳細教程

前言&#xff1a; NS2是指 Network Simulator version 2&#xff0c;NS&#xff08;Network Simulator&#xff09; 是一種針對網絡技術的源代碼公開的、免費的軟件模擬平臺&#xff0c;研究人員使用它可以很容易的進行網絡技術的開發&#xff0c;而且發展到今天&#xff0c;它…

es6核心特性圖

轉載于:https://juejin.im/post/5c19e188e51d452db4753925

帶你利用一句話完成轉場動畫

這篇文章主要給大家介紹了關于iOS如何利用一句話完成轉場動畫的相關資料&#xff0c;文中通過示例代碼介紹的非常詳細&#xff0c;對大家的學習或者工作具有一定的參考學習價值&#xff0c;需要的朋友們下面來一起學習學習吧前言本文介紹SS_AnimationTransition 的使用方法,利用…

14.vue路由腳手架

一.vue路由&#xff1a;https://router.vuejs.org/zh/ 1、定義 let router new VueRouter({mode:"history/hash",base:"基本路徑" 加一些前綴 必須在history模式下有效linkActiveClass:"active", 范圍選擇linkExactActiveClass:"exact&qu…

工程師、產品經理、數據工程師是如何一起工作的?

做為一名工程師&#xff0c;免不了與產品經理打交道&#xff0c;如果公司大一些&#xff0c;數據量多一些&#xff0c;還會有數據工程師這個角色。今天會和你主要聊一聊在工作中&#xff0c;產品經理和數據工程師在哪些方面對我們工程師的幫助最大&#xff0c;以及我從他們身上…

linux-buff/cache過大導致內存不足-程序異常

2019獨角獸企業重金招聘Python工程師標準>>> 問題描述 Linux內存使用量超過閾值&#xff0c;使得Java應用程序無可用內存&#xff0c;最終導致程序崩潰。即使在程序沒有掛掉時把程序停掉&#xff0c;系統內存也不會被釋放。 找原因的過程 這個問題已經困擾我好幾個月…

Android 適配(一)

一、Android適配基礎參數1.常見分辨率&#xff08;px&#xff09;oppx 2340x1080oppR15 2280x1080oppor11sp 2160*10801080*1920 (主流屏幕16&#xff1a;9)1080*216018:9 手機主流分辨率&#xff1a; 1080*2160高端 16:9 手機主流分辨率&#xff1a; 1080P (1080*1920) 或 2K …

Source Insight 創建工程(linux-2.6.22.6內核源碼)

1. 軟件設置 安裝完Source Insight&#xff0c;需要對其進行設置添加對“.S”匯編文件的支持&#xff1a; 2. 新建linux-2.6.22.6工程 1&#xff09;選擇工程存放的路徑&#xff1a; 2&#xff09;下載linux-2.6.22.6內核源碼&#xff0c;并解壓。在Source Insight中 指定源碼的…

課時20:內嵌函數和閉包

目錄&#xff1a; 一、global關鍵字 二、內嵌函數 三、閉包 四、課時20課后習題及答案 ******************** 一、global關鍵字 ******************** 全局變量的作用域是整個模塊&#xff08;整個代碼段&#xff09;&#xff0c;也就是代碼段內所有的函數內部都可以訪問到全局…