推薦算法的先驗算法的連接_數據挖掘專注于先驗算法

推薦算法的先驗算法的連接

So here we are diving into the world of data mining this time, let’s begin with a small but informative definition;

因此,這一次我們將進入數據挖掘的世界,讓我們從一個小的但內容豐富的定義開始;

什么是數據挖掘? (What is data mining ?!)

It’s technically a profound dive into datasets searching for some correlations, rules, anomaly detection and the list goes on. It’s a way to do some simple but effective machine learning instead of doing it the hard way like using regular neural networks or the ultimate complex version that is convolutions and recurrent neural networks (we will definitely go through that thoroughly in future articles).

從技術上講,這是對數據集的深入研究,以尋找一些相關性,規則,異常檢測,并且列表還在繼續。 這是一種進行簡單但有效的機器學習的方法,而不是像使用常規神經網絡或卷積和遞歸神經網絡這樣的終極復雜版本那樣艱苦的方法來完成它(我們肯定會在以后的文章中全面介紹)。

Data mining algorithms vary from one to another, each one has it’s own privileges and disadvantages, i will not go through that in this article but the first one you should focus on must be the classical Apriori Algorithm as it is the opening gate to the data mining world.

數據挖掘算法因人而異,每種算法都有其自身的特權和劣勢,在本文中我不會進行介紹,但是您應該關注的第一個算法必須是經典的Apriori算法,因為它是數據的門戶采礦世界。

But before going any further, there’s some special data mining vocabulary that we need to get familiar with :

但是在進一步介紹之前,我們需要熟悉一些特殊的數據挖掘詞匯:

  • k-Itemsets : an itemset is just a set of items, the k refers to it’s order/length which means the number of items contained in the itemset.

    k-Itemsets:一個項目集只是一組項目, k表示它的順序/長度,這意味著該項目集中包含的項目數。

  • Transaction : it is a captured data, can refer to purchased items in a store. Note that Apriori algorithm operates on datasets containing thousands or even millions of transactions.

    交易:它是捕獲的數據,可以參考商店中購買的物品。 請注意,Apriori算法對包含數千甚至數百萬個事務的數據集進行操作。

  • Association rule : an antecedent → consequent relationship between two itemsets :

    關聯規則:兩個項目集之間的前→后關系:

Image for post

Implies the presence of the itemset Y (consequent) in the considered transaction given the itemset X (antecedent).

在給定項目集X(先行者)的情況下,表示在考慮的事務中存在項目集Y(因此)。

  • Support : represents the popularity/frequency of an itemset, calculated this way :

    支持:表示項目集的受歡迎程度/頻率,通過以下方式計算:

Image for post
  • Confidence ( X → Y ) : shows how much a rule is confident/true, in other words the likelihood of having the consequent itemset in a transaction, calculated this way :

    置信度(X→Y):顯示一條規則置信度/真實度的多少,換句話說,在交易中擁有后續項集的可能性,計算方式為:

Image for post

A rule is called a strong rule if its confidence is equal to 1.

如果規則的置信度等于1,則稱為強規則

  • Lift ( X → Y ) : A measure of performance, indicates the quality of an association rule :

    提升(X→Y):一種性能度量,表示關聯規則的質量:

Image for post
  • MinSup : a user-specified variable which stands for the minimum support threshold for itemsets.

    MinSup:用戶指定的變量 代表項目集的最低支持閾值。

  • MinConf : a user-specified variable which stands for the minimum confidence threshold for rules.

    MinConf:用戶指定的變量,代表規則的最小置信度閾值。

  • Frequent itemset : whose support is equal or higher than the chosen minsup.

    頻繁項目集:支持等于或大于選擇的minsup

  • Infrequent itemset : whose support is less than the chosen minsup.

    頻繁項目 集:其支持小于所選的minsup

那么... Apriori如何工作? (So…how does Apriori work ?)

Starting with a historical glimpse, the algorithm was first proposed by the computer scientists Agrawal and Srikant in 1994, it proceeds this way :

從歷史的一瞥開始,該算法由計算機科學家Agrawal和Srikant于1994年首次提出,它以這種方式進行:

  • Generates possible combinations of k-itemsets (starts with k=1)

    生成k個項目集的可能組合(以k = 1開頭)

  • Calculates support according to each itemset

    根據每個項目集計算支持
  • Eliminates infrequent itemsets

    消除不頻繁的項目集
  • Increments k and repeats the process

    遞增k并重復該過程

Now, how to generate those itemsets ?!!

現在,如何生成這些項目集?

For itemsets of length k=2, it is required to consider every possible combination of two items (no permutation is needed). For k > 2, two conditions must be satisfied first :

對于長度為k = 2的項目集,需要考慮兩個項目的每種可能的組合(不需要排列)。 對于k> 2 ,必須首先滿足兩個條件:

  • The combined itemset must be formed of two frequent ones of length k-1, let’s call’em subsets.

    組合的項目集必須由兩個長度為k-1的 頻繁項組成我們稱它們為em 子集

  • Both subsets must have the same prefix of length k-2

    兩個子集必須具有相同的長度k-2前綴

If you think about it, these steps will just extend the previously found frequent itemsets, this is called the ‘bottom up’ approach. It also proves that Apriori algorithm respects the monotone property :

如果您考慮一下,這些步驟將僅擴展先前發現的頻繁項目集,這稱為“自下而上”方法。 這也證明Apriori算法尊重單調性

All subsets of a frequent itemset must also be frequent.

頻繁項目集的所有子集也必須是頻繁的。

As well as the anti-monotone property :

以及抗單調特性

All super-sets of an infrequent itemset must also be infrequent.

罕見項目集的所有超集也必須是不頻繁的。

Okay, but wait a minute, this seems infinite !!

好的,但是等等,這似乎是無限的!

No, luckily it is not infinite, the algorithm stops at a certain order k if :

不,幸運的是它不是無限的,如果滿足以下條件,該算法將以某個順序k停止:

  • All the generated itemsets of length k are infrequent

    生成的所有長度為k的項目集很少

  • No found prefix of length k-2 in common which makes it impossible to generate new itemsets of length k

    找不到長度為k-2的前綴,這使得無法生成長度為k的新項目集

Sure…it’s not rocket science ! but how about an example to make this clearer ?

當然……這不是火箭科學! 但是如何使這個例子更清楚呢?

Here’s a small transaction table in binary format, the value of an item is 1 if it’s present in the considered transaction, otherwise it’s 0.

這是一個二進制格式的小交易表,如果項目存在于所考慮的交易中,則該項目的值為1 ,否則為0

Image for post

太好了……是時候進行一些關聯規則挖掘了! (Great…It’s time for some association rule mining !)

Image for post

Once you reach this part, all there’s left to do is to take one frequent k-itemset at a time and generate all its possible rules using binary partitioning.

一旦達到這一部分,剩下要做的就是一次獲取一個頻繁的k項集,并使用二進制分區生成所有可能的規則。

If the 3-itemset {Almonds-Sugar-Milk} from the previous example were a frequent itemset, then the generated rules would look like :

如果前面示例中的3個項目集{Almonds-Sugar-Milk}是一個頻繁項集,則生成的規則將如下所示:

Image for post

我的Apriori模擬概述! 使用Python (An overview of my Apriori simulation !! Using Python)

數據集 (Dataset)

Of format csv (Comma separated values), containing 7501 transactions of purchased items in a supermarket. Restructuring the dataset with the transaction encoder class from mlxtend library made the use and manipulation much easier. The resulting structure is occupying an area of ??871.8 KB with 119 columns indexed respectively by food name from “Almonds” to “Zucchini”.

格式為csv (逗號分隔值),包含在超市中的7501個已購買商品的交易。 使用mlxtend庫中的事務編碼器類重構數據集 使使用和操作更加容易。 最終的結構占據了871.8 KB的區域,其中119列分別由食品名稱從``杏仁''到``西葫蘆''索引。

Here’s an overview of the transaction table before and after :

這是之前和之后的事務表的概述:

Image for post

實現算法 (Implementing the algorithm)

I will not be posting any code fragments as it was a straight forward approach, the procedure is recursive, calls the responsible functions for the itemsets generation, support calculation, elimination and association rule mining in the mentioned order.

我不會發布任何代碼片段,因為這是一種直接的方法,該過程是遞歸的,并按上述順序調用負責項集生成,支持計算,消除和關聯規則挖掘的負責功能。

The execution took 177 seconds which seemed optimised and efficient thanks to Pandas and NumPy’s ability to perform quick element-wise operations. All found association rules were saved in an html file for later use.

由于Pandas和NumPy能夠執行快速的按元素操作,因此執行過程耗時177秒,這似乎是優化和高效的。 找到的所有關聯規則都保存在html文件中,以備后用。

現在,去超市逛逛怎么樣? 通過Plotly使用Dash (Now, how about a tour in the supermarket ? Using Dash by Plotly)

Finally, i got to use the previously saved rules to suggest food items based on what my basket contains. Here’s a quick preview :

最后,我必須使用之前保存的規則根據購物籃中的食物來建議食物。 快速預覽:

Feel free to check my source code here.

請在此處隨意檢查我的源代碼。

翻譯自: https://medium.com/the-coded-theory/data-mining-a-focus-on-apriori-algorithm-b201d756c7ff

推薦算法的先驗算法的連接

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

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

相關文章

Android 頁面多狀態布局管理

一、現狀 頁面多狀態布局是開發中常見的需求,即頁面在不同狀態需要顯示不同的布局,實現的方式也比較多,最簡單粗暴的方式就是在 XML 中先將不同狀態對應的布局隱藏起來,根據需要改變其可見狀態,如果多個界面公用相同的…

Tensorflow入門神經網絡代碼框架

Tensorflow—基本用法 使用圖 (graph) 來表示計算任務.在被稱之為 會話 (Session) 的上下文 (context) 中執行圖.使用 tensor 表示數據.通過 變量 (Variable) 維護狀態.使用 feed 和 fetch 可以為任意的操作(arbitrary operation)賦值或者從其中獲取數據。 ? TensorFlow 是一…

手把手教你把代碼丟入github 中

手把手教你把代碼丟入github 中 作為一個小運維一步步教你們怎么把代碼放入到github 中 首先呢我們下載一個git的客戶端 https://git-scm.com/downloads/ 下載一個最新版的2.16.2 下載后那就安裝吧。如果看不懂英文就選擇默認安裝的方式吧。但是你得記住你的軟件安裝的位置 小…

時間序列模式識別_空氣質量傳感器數據的時間序列模式識別

時間序列模式識別 1. Introduction 2. Exploratory Data Analysis ° 2.1 Pattern Changes ° 2.2 Correlation Between Features 3. Anomaly Detection and Pattern Recognition ° 3.1 Point Anomaly Detection (System Fault) ° 3.2 Collective Anomaly Detection (Externa…

oracle 性能優化 07_診斷事件

2019獨角獸企業重金招聘Python工程師標準>>> 一、診斷事件 診斷事件無官方技術文檔支持,使用存在風險,慎用。使用診斷事件可以獲取問題更多的信息,調整系統運行 特性,啟用某些內部功能。用于系統故障的診斷。跟蹤應…

Tensorflow框架:卷積神經網絡實戰--Cifar訓練集

Cifar-10數據集包含10類共60000張32*32的彩色圖片,每類6000張圖。包括50000張訓練圖片和 10000張測試圖片 代碼分為數據處理部分和卷積網絡訓練部分: 數據處理部分: #該文件負責讀取Cifar-10數據并對其進行數據增強預處理 import os impo…

計算機科學速成課36:自然語言處理

詞性 短語結構規則 分析樹 語音識別 譜圖 快速傅里葉變換 音素 語音合成 轉載于:https://www.cnblogs.com/davidliu2018/p/9149252.html

linux內存初始化初期內存分配器——memblock

2019獨角獸企業重金招聘Python工程師標準>>> 1.1.1 memblock 系統初始化的時候buddy系統,slab分配器等并沒有被初始化好,當需要執行一些內存管理、內存分配的任務,就引入了一種內存管理器bootmem分配器。 當buddy系統和slab分配器初始化好后&…

數據科學學習心得_學習數據科學

數據科學學習心得蘋果 | GOOGLE | 現貨 | 其他 (APPLE | GOOGLE | SPOTIFY | OTHERS) Editor’s note: The Towards Data Science podcast’s “Climbing the Data Science Ladder” series is hosted by Jeremie Harris. Jeremie helps run a data science mentorship startup…

Keras框架:Alexnet網絡代碼實現

網絡思想: 1、一張原始圖片被resize到(224,224,3); 2、使用步長為4x4,大小為11的卷積核對圖像進行卷積,輸出的特征層為96層, 輸出的shape為(55,55,96); 3、使用步長為2的最大池化層進行池化,此時…

PHP對象傳遞方式

<?phpheader(content-type:text/html;charsetutf-8);class Person{public $name;public $age;}$p1 new Person;$p1->name 金角大王;$p1->age 400;//這個地方&#xff0c;到底怎樣?$p2 $p1;$p2->name 銀角大王;echo <pre>;echo p1 name . $p1->n…

微軟Azure CDN現已普遍可用

微軟宣布Azure CDN一般可用&#xff08;GA&#xff09;&#xff0c;客戶現在可以從微軟的全球CDN網絡提供內容。最新版本是對去年五月份發布的公眾預覽版的跟進。\\今年5月&#xff0c;微軟與Verizon和Akamai一起推出了原生CDN產品。現在推出了GA版本&#xff0c;根據發布博文所…

數據科學生命周期_數據科學項目生命周期第1部分

數據科學生命周期This is series of how to developed data science project.這是如何開發數據科學項目的系列。 This is part 1.這是第1部分。 All the Life-cycle In A Data Science Projects-1. Data Analysis and visualization.2. Feature Engineering.3. Feature Selec…

Keras框架:VGG網絡代碼實現

VGG概念&#xff1a; VGG之所以經典&#xff0c;在于它首次將深度學習做得非常“深”&#xff0c;達 到了16-19層&#xff0c;同時&#xff0c;它用了非常“小”的卷積核&#xff08;3X3&#xff09;。 網絡框架&#xff1a; VGG的結構&#xff1a; 1、一張原始圖片被resize…

Django筆記1

內容整理1.創建django工程django-admin startproject 工程名2.創建APPcd 工程名python manage.py startapp cmdb3.靜態文件project.settings.pySTATICFILES_dirs {os.path.join(BASE_DIR, static),}4.模板路徑DIRS > [os.path.join(BASE_DIR, templates),]5.settings中mid…

BZOJ 2003 [Hnoi2010]Matrix 矩陣

題目鏈接 https://www.lydsy.com/JudgeOnline/problem.php?id2003 題解 考慮搜索。 確定了第一行和第一列&#xff0c;那么就確定了整個矩陣&#xff0c;因此搜索的范圍可以降到399個位置。 首先搜索第一行&#xff0c;顯然每個不是第一行第一列的位置都可以由三個位置唯一確定…

Keras框架:resent50代碼實現

Residual net概念 概念&#xff1a; Residual net(殘差網絡)&#xff1a;將靠前若干層的某一層數據輸出直接跳過多層引入到后面數據層的輸入 部分。 殘差神經單元&#xff1a;假定某段神經網絡的輸入是x&#xff0c;期望輸出是H(x)&#xff0c;如果我們直接將輸入x傳到輸出作…

MySQL數據庫的回滾失敗(JAVA)

這幾天在學習MySQL數據的知識&#xff0c;有一個小測試&#xff0c;用來測試數據庫的提交和回滾。 剛開始的時候真的沒把這個當回事&#xff0c;按照正常的步驟來講的話&#xff0c;如下所示&#xff0c;加載驅動&#xff0c;獲取數據庫的連接&#xff0c;并且把數據庫的自動提…

條件概率分布_條件概率

條件概率分布If you’re currently in the job market or looking to switch careers, you’ve probably noticed an increase in popularity of Data Science jobs. In 2019, LinkedIn ranked “data scientist” the №1 most promising job in the U.S. based on job openin…

MP實戰系列(十七)之樂觀鎖插件

聲明&#xff0c;目前只是僅僅針對3.0以下版本&#xff0c;2.0以上版本。 意圖&#xff1a; 當要更新一條記錄的時候&#xff0c;希望這條記錄沒有被別人更新 樂觀鎖實現方式&#xff1a; 取出記錄時&#xff0c;獲取當前version 更新時&#xff0c;帶上這個version 執行更新時…