<jupyter_start><jupyter_text>Eclart  Eclart is literally a simplified version of Apriori algorithm for association rule mining. Where Apriori algorithm first generates support which generally means for movie database how many people have seen this movie.It's the base or prior knowledge then move on to generate confidences which is kind of similar to Naive Bayes Approach for machine learning. Confidence for a movie database can be expressed as if a person saw a certain movie(often a bigger set/the movie significant portion of the database member are supposed to watch, how many among them have seen the previously defined movie. Then we move on to calculate lift which tries to test if applying confidence has improved performance or not. Now Eclart is pretty simplified than that it mainly tries to find sets and their support value,no confidence no lifting.  Importing the libraries<jupyter_code>!pip install apyori
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Data Preprocessing<jupyter_code>dataset = pd.read_csv('Market_Basket_Optimisation.csv', header = None)
transactions = []
for i in range(0, 7501):
  transactions.append([str(dataset.values[i,j]) for j in range(0, 20)])<jupyter_output><empty_output><jupyter_text>Training the Apriori model on the datasetmin_support=(3*7)/Totat_transactionsmin_confidence=0.8/default value but will use 0.2 it actually indicates if we use prior knowledge like buys x condition then how the result of buying y improves.<jupyter_code>from apyori import apriori
rules=apriori(transactions=transactions,min_support=0.003,min_confidence=0.2,min_lift=3,min_length=2,max_length=2)<jupyter_output><empty_output><jupyter_text>Visualising the results<jupyter_code>#Now viewing the results
results=list(rules)
results<jupyter_output><empty_output><jupyter_text>Displaying the first results coming directly from the output of the apriori function<jupyter_code>#Change happens actually here.
def inspects(results):
  lhs=[tuple(result[2][0][0])[0] for result in results]
  rhs=[tuple(result[2][0][1])[0] for result in results]
  support=[result[1] for result in results]
  return list(zip(lhs, rhs,support))
resultsinDataFrame = pd.DataFrame(inspects(results), columns = ['Product1', 'Product2', 'Support'])<jupyter_output><empty_output><jupyter_text>Putting the results well organised into a Pandas DataFrame<jupyter_code>resultsinDataFrame.head(10)<jupyter_output><empty_output><jupyter_text>**Displaying the results sorted by descending lifts**<jupyter_code>resultsinDataFrame.sort_values(by='Support',ascending=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07756024096385543, 'fraction_numerical': 0.01355421686746988, 'mean_word_length': 7.683006535947713, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '604435', 'license': 'MIT', 'n_tokens_mistral': 801, 'n_tokens_neox': 772, 'n_words': 265, 'path': 'Eclart.ipynb', 'repo_name': 'farhan1503001/Association-Rule-Mining-', 'size': '2656'}