-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Association Rule Leaning Models and dataset. Updated the README
- Loading branch information
Showing
3 changed files
with
7,674 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "1fziHl7Ar94J" | ||
}, | ||
"source": [ | ||
"# Apriori" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "eiNwni1xsEgT" | ||
}, | ||
"source": [ | ||
"## Importing the libraries" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": {}, | ||
"colab_type": "code", | ||
"id": "UJfitBClsJlT" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "vLt-7XUKsXBd" | ||
}, | ||
"source": [ | ||
"## Data Preprocessing" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": {}, | ||
"colab_type": "code", | ||
"id": "J_A-UFOAsaDf" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"dataset = pd.read_csv('../../datasets/Market_Basket_Optimisation.csv', header = None)\n", | ||
"transactions = []\n", | ||
"for i in range(0, 7501):\n", | ||
" transactions.append([str(dataset.values[i,j]) for j in range(0, 20)])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "1wYZdBd5sea_" | ||
}, | ||
"source": [ | ||
"## Training the Apriori model on the dataset" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": {}, | ||
"colab_type": "code", | ||
"id": "YzIk4vXZsj5i" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# WARNING: Make sure to upload the apyori.py file into this Colab notebook before running this cell\n", | ||
"from apyori import apriori\n", | ||
"rules = apriori(transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "b176YNwWspiO" | ||
}, | ||
"source": [ | ||
"## Visualising the results" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": {}, | ||
"colab_type": "code", | ||
"id": "a4ZyVYazsvWt" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"results = list(rules)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 54 | ||
}, | ||
"colab_type": "code", | ||
"executionInfo": { | ||
"elapsed": 941, | ||
"status": "ok", | ||
"timestamp": 1586415085286, | ||
"user": { | ||
"displayName": "Hadelin de Ponteves", | ||
"photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GhEuXdT7eQweUmRPW8_laJuPggSK6hfvpl5a6WBaA=s64", | ||
"userId": "15047218817161520419" | ||
}, | ||
"user_tz": -240 | ||
}, | ||
"id": "FdaOb_95tQoP", | ||
"outputId": "701cb6ce-3951-4c6e-9140-c867741bd885" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"print(results)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"colab": { | ||
"authorship_tag": "ABX9TyO41Q6DRmOTeVEfityPN5hB", | ||
"collapsed_sections": [], | ||
"name": "Apriori", | ||
"provenance": [], | ||
"toc_visible": true | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.