Apriori in Python – Step 2.) Train Apriori Model

with No Comments

Training the Apriori Model

Since we have to Apyori library installed, it is super easy to train an Apriori Model.

We are going to import Apriori from Apyori.

The Apriori comes with function that allow users to train a model easily with parameters.

Users can set the min support, min confidence, min lift and min length at parameter section of the function

# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Import Dataset 
dataset = pd.read_csv(‘apriori_data2.csv’, header = None)
records = [] for i in range(0, 11):
records.append([str(dataset.values[i,j]) for j in range(0, 10)])

# Train Apriori Model
from apyori import apriori
rules = apriori(records, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)

Other Sections on Apriori :

Step 1.) Import Libraries and Import Dataset 

Step 2.) Train a Apriori Model

Step 3.) Visualize Apriori Results 

Other Topics – Multivariate Analysis : 
Other Topics – Association Rule : 
  • Apriori
  • Eclat
Other Topics – Artifical Inteligent : 

Leave a Reply