Data Science & ML Experiments in Python
Data Science & ML Experiments in Python
DEPARTMENT OF INFORMATION
TECHNOLOGY
RITD505a
Objective
The objective of this experiment is to generate a dataset of student marks using Python,
store the data in a CSV file, read and analyze the dataset using statistical measures
such as mean, median, mode, minimum, maximum, and standard deviation, and finally
visualize the marks of students in different subjects using bar plots, line plots, pie charts,
and histograms.
Theory
Data analysis involves collecting, organizing, summarizing, and presenting data to extract
meaningful information. In this experiment, a CSV (Comma Separated Values) file is
used to store the marks of 20 students in three subjects: Maths, Science, and English.
Python’s csv module is used to generate and write data, while the pandas library is used
to load and analyze the dataset.
Descriptive statistics are applied to understand the distribution of Science marks:
• Minimum and Maximum: The smallest and largest values in the dataset.
• Standard Deviation: A measure of spread that shows how much the data varies
from the mean.
Data visualization is performed using matplotlib. Bar charts are used to compare
marks of different students across subjects, while line plots help observe trends when
the data is sorted. Pie charts show the distribution of total marks, and histograms help
analyze the frequency distribution of marks in each subject. These visualizations help
interpret the data more effectively and identify patterns or variations.
CODE and OUTPUT :
Assignment 1
file = "[Link]"
df = pd.read_csv("[Link]")
mean=df["Science"].mean()
print(mean)
median=df["Science"].median()
print(mean)
mode=df["Science"].mode()
print(mode)
min=df["Science"].min()
print(min)
max=df["Science"].max()
print(max)
std=df["Science"].std()
print(std)
48.7
48.7
0 37
1 53
Name: Science, dtype: int64
3
93
28.44033458978546
print("3(a)")
x=df["Student Name"]
y1=df["Science"]
y2=df["Maths"]
y3=df["English"]
3(a)
In [42]: print("3b")
df1=df.sort_values("Science")
[Link](df1["Student Name"], df1["Science"], label="Science Marks")
[Link]("Names")
[Link]("Marks")
[Link]("Science marks o the students")
[Link]()
[Link]()
3b
Objective
The objective of this experiment is to load, explore, and analyze a high-resolution elec-
tricity load dataset from smart meters across various cities in Morocco using Python.
Theory
Data analysis is an essential part of data science and energy analytics. In this experiment,
the Pandas library in Python is used to handle and analyze large datasets efficiently.
Pandas provides powerful data structures such as DataFrames, which allow users to store,
manipulate, and analyze tabular data with labeled axes (rows and columns).
The main steps involved in this analysis are:
1. Data Loading: Importing the dataset into a Pandas DataFrame using the read excel()
function.
2. Data Inspection: Using functions like head(), info(), and shape to view the first
few rows, column data types, number of entries, and overall structure.
3. Data Understanding: Identifying data columns — in this case, DateTime and en-
ergy readings from five zones (zone1 to zone5). This allows analysts to explore
temporal patterns in electricity usage and assess data completeness.
Such an exploratory analysis forms the foundation for more advanced data science
tasks like visualization, time series forecasting, and energy demand prediction.
CODE and OUTPUT:
In [1]: import pandas as pd
data=pd.read_excel("C:\\Users\\DELL\\Documents\\mtech\\1sem\\DS\\high-resolution+load+
In [2]: print([Link]())
zone5
0 102.922162
1 101.747520
2 102.074112
3 102.911361
4 102.546117
In [3]: print([Link]())
<class '[Link]'>
RangeIndex: 88890 entries, 0 to 88889
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 DateTime 88890 non-null datetime64[ns]
1 zone1 88890 non-null float64
2 zone2 88890 non-null float64
3 zone3 88890 non-null float64
4 zone4 88890 non-null float64
5 zone5 88890 non-null float64
dtypes: datetime64[ns](1), float64(5)
memory usage: 4.1 MB
None
In [5]: print([Link])
(88890, 6)
Conclusion
From this experiment, we successfully loaded and inspected a large electricity load dataset
consisting of 88,890 records and 6 columns. The dataset includes timestamped readings
for five energy consumption zones. The info() output confirmed that all entries are
complete, with no missing values, and that the data types are appropriate (datetime64[ns]
for time and float64 for numerical load readings).
This preliminary data analysis establishes a clear understanding of the dataset’s struc-
ture, enabling further analytical processes such as statistical analysis, visualization, and
forecasting of electricity demand patterns.
EXPERIMENT 3
Objective
The objective of this experiment is to handle missing and inconsistent data in a dataset
using Python and Pandas.
Theory
In real-world data analysis, missing and inconsistent data are common and can signif-
icantly affect the accuracy of any model or analysis. Data cleaning is the process of
detecting and correcting (or removing) corrupt or inaccurate records from a dataset.
In this experiment, the Pandas library in Python is used to perform data preprocess-
ing. The following concepts are applied:
1. Handling Missing Data: Missing values are imputed using the median of the re-
spective column through the fillna() function. The median is often preferred as
it is less sensitive to extreme values than the mean.
2. Outlier Detection and Removal: Outliers are detected using the standard devia-
tion method. Any value lying beyond three standard deviations from the mean is
considered an outlier and is removed using logical conditions.
3. Data Consistency: Once missing data and outliers are addressed, the resulting
dataset becomes more reliable and ready for further statistical or machine learning
analysis.
data = {
"Age": [21, 23, None, 22, 45, 24, 22, 23, 21, None],
"Salary": [30000, 32000, 31000, None, 150000, 29000, 30500, 31500, None, 33000
}
df = [Link](data)
print("Original Data:")
print(df)
df['Age'].fillna(df['Age'].median(), inplace=True)
df['Salary'].fillna(df['Salary'].median(), inplace=True)
mean_salary = df['Salary'].mean()
std_salary = df['Salary'].std()
print("\nCleaned Data:")
print(df_cleaned)
Original Data:
Age Salary
0 21.0 30000.0
1 23.0 32000.0
2 NaN 31000.0
3 22.0 NaN
4 45.0 150000.0
5 24.0 29000.0
6 22.0 30500.0
7 23.0 31500.0
8 21.0 NaN
9 NaN 33000.0
Cleaned Data:
Age Salary
0 21.0 30000.0
1 23.0 32000.0
2 22.5 31000.0
3 22.0 31250.0
4 45.0 150000.0
5 24.0 29000.0
6 22.0 30500.0
7 23.0 31500.0
8 21.0 31250.0
9 22.5 33000.0
Conclusion
In this experiment, a dataset containing missing and inconsistent values for Age and
Salary was successfully cleaned using Pandas. The missing values were replaced with the
median of each column, ensuring the dataset remained statistically balanced. Outliers
were removed using the standard deviation approach. The cleaned dataset provided a
more accurate and consistent representation of the data, forming a strong foundation for
subsequent analysis and visualization tasks.
EXPERIMENT 4
Objective
The objective of this experiment is to visualize data using different types of plots in
Python.
Theory
Data visualization is an important aspect of data analysis as it helps to understand
trends, patterns, and relationships in data. Python provides several libraries for creating
visualizations, with matplotlib, numpy, and seaborn being among the most widely used.
The following visualization techniques are demonstrated in this experiment:
1. Line Plot: Displays the relationship between two continuous variables, showing
trends over an interval.
2. Bar Chart: Represents categorical data using rectangular bars proportional to their
values.
3. Histogram: Shows the frequency distribution of numerical data, allowing for the
observation of data spread and skewness.
4. Scatter Plot: Displays relationships between two numerical variables, useful for
identifying correlations or clusters.
# 1. Line Plot
x = [Link](1, 11)
y1 = x ** 2
y2 = x ** 3
[Link](x, y1, label="x^2", color="blue")
[Link](x, y2, label="x^3", color="orange")
[Link]("Line Plot Example")
[Link]("X values")
[Link]("Y values")
[Link]()
[Link]()
# 2. Bar Chart
categories = ["A", "B", "C", "D"]
values = [23, 45, 56, 78]
[Link](categories, values, color="skyblue")
[Link]("Bar Chart Example")
[Link]("Categories")
[Link]("Values")
[Link]()
# 3. Histogram
data = [Link](1000)
[Link](data, bins=20, color="purple", alpha=0.7)
[Link]("Histogram Example")
[Link]("Value")
[Link]("Frequency")
[Link]()
# 4. Scatter Plot
x = [Link](100)
y = [Link](100)
[Link](x, y, color="green", alpha=0.6)
[Link]("Scatter Plot Example")
[Link]("X values")
[Link]("Y values")
[Link]()
# 5. Pie Chart
sizes = [20, 30, 25, 25]
labels = ["A", "B", "C", "D"]
[Link](sizes, labels=labels, autopct='%1.1f%%', startangle=140)
[Link]("Pie Chart Example")
[Link]()
# 6. Heatmap
data = [Link](6, 6)
corr_matrix = [Link](data)
[Link](corr_matrix, annot=True, cmap="coolwarm", fmt=".2f")
[Link]("Heatmap Example")
[Link]()
Conclusion
In this experiment, different data visualization techniques were implemented using Python
libraries such as Matplotlib, NumPy, and Seaborn. Each visualization type provided
unique insights into the data, from identifying trends and distributions to observing corre-
lations between variables. This experiment demonstrates the importance of visualization
in transforming raw data into meaningful information for analysis and interpretation.
EXPERIMENT 5
Objective
The objective of this experiment is to perform statistical analysis on a dataset containing
students’ marks in different subjects using Python.
Theory
Statistical analysis is a fundamental process in data science that helps summarize, inter-
pret, and draw insights from data. Descriptive statistics provide numerical summaries
that describe the main features of a dataset.
In this experiment, a dataset of students’ marks in subjects such as Maths, Science,
and English is analyzed using the Python libraries pandas and statistics. The key
measures used are:
1. Mean: Represents the average value of a dataset and indicates the central location
of the data.
2. Median: Refers to the middle value when data points are arranged in ascending
order, reducing the effect of outliers.
4. Variance: Measures the degree of spread in the data, showing how far values deviate
from the mean.
5. Standard Deviation: Indicates the average deviation from the mean and provides
insight into data variability.
print("Dataset:\n")
print(df, "\n")
Subject: Maths
Mean: 47.15
Variance: 926.7657894736842
Standard Deviation: 30.44282821082306
Median: 42.5
Mode: 20
Subject: Science
Mean: 48.70
Variance: 808.8526315789474
Standard Deviation: 28.44033458978546
Median: 52.0
Mode: 53
Subject: English
Mean: 51.90
Variance: 917.4631578947368
Standard Deviation: 30.289654304642315
Median: 49.0
Mode: 24
Conclusion
In this experiment, the marks dataset was analyzed using statistical measures to un-
derstand student performance in Maths, Science, and English. The calculated mean,
median, mode, variance, and standard deviation for each subject revealed variations in
performance levels. The analysis demonstrated that Python provides an efficient and
reliable approach to performing statistical computations, enabling quick insights into the
underlying trends and spread of data.
EXPERIMENT 6
Objective
The objective of this experiment is to apply and compare machine learning classification
algorithms, specifically Naive Bayes and Random Forest, on the Iris dataset using Python.
Theory
Machine learning classification is a supervised learning technique used to categorize data
into predefined classes. In this experiment, two different algorithms are applied to the
Iris dataset, a well-known dataset containing measurements of sepal and petal dimensions
for three species of flowers.
1. Naive Bayes Classifier: Based on Bayes’ theorem, this probabilistic classifier as-
sumes independence among predictors. It calculates the posterior probability of
each class and assigns the class with the highest probability. The Gaussian Naive
Bayes model is used here, as it assumes that features follow a normal distribution.
• Confusion Matrix: Displays the number of correct and incorrect predictions for each
class.
• Classification Report: Provides detailed metrics such as precision, recall, and F1-
score.
The visual representation of confusion matrices and feature importance helps in better
understanding of model performance and the influence of different features.
CODE and OUTPUT:
In [8]: # Import necessary libraries
import numpy as np
import [Link] as plt
import seaborn as sns
from [Link] import load_iris
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
from [Link] import RandomForestClassifier
from [Link] import accuracy_score, confusion_matrix, classification_report
# Load dataset
iris = load_iris()
X = [Link]
y = [Link]
feature_names = iris.feature_names
class_names = iris.target_names
# Split dataset
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state
accuracy 1.00 30
macro avg 1.00 1.00 1.00 30
weighted avg 1.00 1.00 1.00 30
accuracy 1.00 30
macro avg 1.00 1.00 1.00 30
weighted avg 1.00 1.00 1.00 30
C:\Users\DELL\AppData\Local\Temp\ipykernel_20232\[Link]: FutureWarnin
g:
Objective
To implement a linear regression model on the California Housing dataset in order to
predict the median house value based on various housing and demographic features, and
to evaluate the model’s performance using metrics such as Mean Squared Error (MSE),
Mean Absolute Error (MAE), and R-squared score.
Theory
Linear regression is a supervised machine learning algorithm used for predicting a contin-
uous dependent variable based on one or more independent variables. It assumes a linear
relationship between the input variables and the target variable, which can be expressed
as:
y = β0 + β1 x1 + β2 x2 + · · · + βn xn + ϵ
where y is the dependent variable, xi are the independent variables, βi are the coefficients,
and ϵ is the error term.
The goal of linear regression is to minimize the difference between the predicted and
actual values, typically achieved by minimizing the cost function — the Mean Squared
Error (MSE):
n
1X
M SE = (yi − ŷi )2
n i=1
• Mean Squared Error (MSE): Average squared difference between actual and pre-
dicted values.
• Mean Absolute Error (MAE): Average absolute difference between actual and pre-
dicted values.
In this experiment, the model uses the California Housing dataset, which includes features
like average income, house age, number of rooms, population, and geographic coordinates
to predict median house values.
CODE and OUTPUT:
In [1]: # Import libraries
import [Link] as plt
import seaborn as sns
from [Link] import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from [Link] import mean_squared_error, mean_absolute_error, r2_score
import pandas as pd
# Load dataset
data = fetch_california_housing()
X = [Link]
y = [Link]
feature_names = data.feature_names
# Predict
y_pred = lr_model.predict(X_test)
# 1 ⯑ True vs Predicted
[Link](figsize=(6,6))
[Link](y_test, y_pred, alpha=0.6)
[Link]([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'r--', lw=
[Link]("True Values")
[Link]("Predicted Values")
[Link]("Linear Regression: True vs Predicted")
[Link]()
# 2 ⯑ Feature Coefficients
coef_df = [Link]({'Feature': feature_names, 'Coefficient': lr_model.coef_
coef_df = coef_df.sort_values(by='Coefficient', key=abs, ascending=False)
[Link](figsize=(8,5))
[Link](x='Coefficient', y='Feature', data=coef_df, palette="coolwarm")
[Link]("Linear Regression Feature Coefficients")
[Link]()
C:\Users\DELL\AppData\Local\Temp\ipykernel_9308\[Link]: FutureWarning:
Objective
To perform clustering on the Iris dataset using K-Means and Hierarchical Agglomerative
Clustering (HAC) methods, visualize the resulting clusters, and compare their outcomes
to understand how different algorithms group similar data points based on their features.
Theory
Clustering is an unsupervised machine learning technique used to group similar data
points together based on feature similarity. Unlike classification, clustering does not use
labeled data. In this experiment, two clustering algorithms — K-Means and Hierarchical
Agglomerative Clustering — are applied to the Iris dataset.
1. K-Means Clustering: K-Means aims to partition data into k clusters such that
each observation belongs to the cluster with the nearest mean (centroid). The objective
function minimizes the within-cluster sum of squares:
k X
X
J= ||xj − µi ||2
i=1 xj ∈Ci
where µi is the centroid of cluster Ci . The algorithm iteratively updates cluster assign-
ments and centroids until convergence.
2. Hierarchical Agglomerative Clustering (HAC): HAC builds a hierarchy of clusters
using a bottom-up approach, starting with each data point as an individual cluster and
successively merging the two closest clusters based on a linkage criterion (such as Ward’s
method). The hierarchy is visualized using a dendrogram, where the height represents
the distance at which clusters are merged.
Before applying both algorithms, the features are standardized to ensure equal con-
tribution of all variables. The clustering performance is visualized using scatter plots for
both K-Means and HAC, and their cluster labels are compared.
CODE and OUTPUT:
In [2]: import pandas as pd
import numpy as np
import [Link] as plt
import seaborn as sns
from [Link] import load_iris
from [Link] import StandardScaler
from [Link] import KMeans, AgglomerativeClustering
from [Link] import dendrogram, linkage
# -------------------------------
# Step 1: Data Standardization
# -------------------------------
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# -------------------------------
# Step 2: K-Means Clustering
# -------------------------------
kmeans = KMeans(n_clusters=3, random_state=42)
kmeans_labels = kmeans.fit_predict(X_scaled)
df['KMeans_Cluster'] = kmeans_labels
# -------------------------------
# Step 3: Hierarchical Clustering
# -------------------------------
# Perform linkage
linked = linkage(X_scaled, method='ward')
# Plot Dendrogram
[Link](figsize=(10, 6))
dendrogram(linked,
orientation='top',
distance_sort='descending',
show_leaf_counts=True)
[Link]("Hierarchical Clustering Dendrogram")
[Link]("Samples")
[Link]("Distance")
[Link]()
# -------------------------------
# Step 4: Comparison of Clusters
# -------------------------------
print("\nCluster labels by both methods:")
print(df[['KMeans_Cluster', 'HAC_Cluster']].head())
Objective
The objective of this experiment is to perform time series analysis on the Airline Pas-
sengers dataset by checking stationarity, applying transformations such as differencing,
decomposing the series into trend and seasonality components, and building an ARIMA
model to forecast future passenger values.
Theory
Time series analysis involves studying data points collected or recorded at successive
points in time. It is used to identify underlying patterns such as trend, seasonality, and
cyclic behavior. A time series must be stationary for most forecasting models, meaning
its statistical properties remain constant over time.
The Augmented Dickey–Fuller (ADF) test is used to check stationarity. A high p-value
(greater than 0.05) indicates a non-stationary series. To achieve stationarity, differencing
is often applied:
Yt′ = Yt − Yt−1
where p is the autoregressive term, d is the degree of differencing, and q is the moving
average term. The ARIMA model forecasts future values by combining past observations
and past errors:
Yt = c + ϕ1 Yt−1 + · · · + θ1 ϵt−1 + · · ·
url = "[Link]
data = pd.read_csv(url)
[Link](figsize=(10,5))
[Link](data, label='Monthly Airline Passengers', color='blue')
[Link]("Original Time Series Data (AirPassengers)")
[Link]("Date")
[Link]("Passengers (in thousands)")
[Link]()
[Link]()
def adf_test(series):
result = adfuller(series)
print('ADF Statistic:', result[0])
print('p-value:', result[1])
print('Critical Values:')
for key, value in result[4].items():
print(f' {key}, {value}')
✅
if result[1] <= 0.05:
print(" Data is stationary (p < 0.05)")
❌
else:
🔍
print(" Data is NOT stationary (p > 0.05)")
print("\n Stationarity Check:")
adf_test(data['Value'])
🔍
diff_data = [Link]().dropna()
print("\n Stationarity Check after Differencing:")
adf_test(diff_data['Value'])
[Link](figsize=(10,5))
[Link](diff_data, label='Differenced Data', color='green')
[Link]("Differenced Time Series")
[Link]()
[Link]()
forecast = model_fit.forecast(steps=len(test))
[Link](figsize=(10,5))
[Link](train, label='Train')
[Link](test, label='Test')
[Link]([Link], forecast, label='Forecast', color='red')
[Link]("ARIMA Forecast vs Actual (AirPassengers)")
[Link]()
[Link]()
📊
mse = mean_squared_error(test, forecast)
print(f" Mean Squared Error: {mse:.4f}")
❌
10%, -2.578770059171598
Data is NOT stationary (p > 0.05)
❌
10%, -2.578770059171598
Data is NOT stationary (p > 0.05)
SARIMAX Results
==============================================================================
Dep. Variable: Value No. Observations: 115
Model: ARIMA(1, 1, 1) Log Likelihood -526.123
Date: Wed, 29 Oct 2025 AIC 1058.246
Time: 10:10:04 BIC 1066.454
Sample: 01-01-1949 HQIC 1061.577
- 07-01-1958
Covariance Type: opg
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
ar.L1 -0.5111 0.114 -4.488 0.000 -0.734 -0.288
ma.L1 0.9144 0.056 16.251 0.000 0.804 1.025
sigma2 592.7851 101.208 5.857 0.000 394.422 791.148
===============================================================================
====
Ljung-Box (L1) (Q): 0.09 Jarque-Bera (JB):
2.29
Prob(Q): 0.76 Prob(JB):
0.32
Heteroskedasticity (H): 5.22 Skew:
0.03
Prob(H) (two-sided): 0.00 Kurtosis:
2.31
===============================================================================
====
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-
step).
📊 Mean Squared Error: 9506.1758
Conclusion
The time series analysis of the Airline Passengers dataset revealed that the original se-
ries was non-stationary, as indicated by a high p-value in the ADF test. After applying
differencing, the series approached stationarity but still remained slightly above the sig-
nificance threshold. The ARIMA(1,1,1) model was successfully trained on the dataset,
and its forecasts followed the general upward trend of the original passenger data. How-
ever, the model produced a relatively high Mean Squared Error of 9506.17, indicating
that although it captured the general pattern, its predictive accuracy can be improved.
The experiment demonstrates the importance of stationarity, decomposition, and model
selection in time series forecasting.
EXPERIMENT 10
Objective
The objective of this experiment is to apply the Apriori algorithm on a transactional
dataset to identify frequent itemsets and generate association rules.
Theory
Association Rule Mining is a data mining technique used to discover interesting relation-
ships between items in large transactional datasets. It is widely applied in market basket
analysis to understand customer purchasing behaviour.
1. Apriori Algorithm: Apriori is a frequent itemset mining algorithm based on the
principle that if an itemset is frequent, all of its subsets must also be frequent. It uses
a bottom-up approach where frequent itemsets of size k are used to generate candidate
itemsets of size k + 1. The support of an itemset is given by:
2. Association Rules: After identifying frequent itemsets, association rules of the form
A → B are generated, where A and B are disjoint itemsets. The strength of these rules
is evaluated using:
• Confidence:
Support(A ∪ B)
Confidence(A → B) =
Support(A)
• Lift:
Confidence(A → B)
Lift(A → B) =
Support(B)
Lift greater than 1 indicates a strong positive association.
In this experiment, the dataset is encoded using one-hot encoding and processed using
the Apriori algorithm with a minimum support of 0.6. Association rules are generated
based on confidence, and strong rules are filtered using lift.
CODE and OUTPUT :
In [1]: !pip install mlxtend
import pandas as pd
from mlxtend.frequent_patterns import apriori, association_rules
dataset = [
['Milk', 'Bread', 'Butter'],
['Bread', 'Diaper', 'Beer', 'Eggs'],
['Milk', 'Diaper', 'Beer', 'Cola'],
['Bread', 'Milk', 'Diaper', 'Beer'],
['Bread', 'Milk', 'Diaper', 'Cola']
]
🔹
frequent_itemsets = apriori(df, min_support=0.6, use_colnames=True)
print("\n Frequent Itemsets:\n")
print(frequent_itemsets)
🔹
strong_rules = rules[rules['lift'] > 1]
print("\n Strong Association Rules (lift > 1):\n")
print(strong_rules[['antecedents', 'consequents', 'support', 'confidence', 'lift'
Requirement already satisfied: mlxtend in /usr/local/lib/python3.12/dist-packag
es (0.23.4)
Requirement already satisfied: scipy>=1.2.1 in /usr/local/lib/python3.12/dist-p
ackages (from mlxtend) (1.16.2)
Requirement already satisfied: numpy>=1.16.2 in /usr/local/lib/python3.12/dist-
packages (from mlxtend) (2.0.2)
Requirement already satisfied: pandas>=0.24.2 in /usr/local/lib/python3.12/dis
t-packages (from mlxtend) (2.2.2)
Requirement already satisfied: scikit-learn>=1.3.1 in /usr/local/lib/python3.1
2/dist-packages (from mlxtend) (1.6.1)
Requirement already satisfied: matplotlib>=3.0.0 in /usr/local/lib/python3.12/d
ist-packages (from mlxtend) (3.10.0)
Requirement already satisfied: joblib>=0.13.2 in /usr/local/lib/python3.12/dis
t-packages (from mlxtend) (1.5.2)
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/di
st-packages (from matplotlib>=3.0.0->mlxtend) (1.3.3)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-p
ackages (from matplotlib>=3.0.0->mlxtend) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/d
ist-packages (from matplotlib>=3.0.0->mlxtend) (4.60.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/d
ist-packages (from matplotlib>=3.0.0->mlxtend) (1.4.9)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dis
t-packages (from matplotlib>=3.0.0->mlxtend) (25.0)
Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-pack
ages (from matplotlib>=3.0.0->mlxtend) (11.3.0)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/di
st-packages (from matplotlib>=3.0.0->mlxtend) (3.2.5)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.1
2/dist-packages (from matplotlib>=3.0.0->mlxtend) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-p
ackages (from pandas>=0.24.2->mlxtend) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dis
t-packages (from pandas>=0.24.2->mlxtend) (2025.2)
Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.1
2/dist-packages (from scikit-learn>=1.3.1->mlxtend) (3.6.0)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packa
🔹
ges (from python-dateutil>=2.7->matplotlib>=3.0.0->mlxtend) (1.17.0)
Transaction Dataset (One-Hot Encoded):
🔹 Frequent Itemsets:
support itemsets
0 0.6 (Beer)
1 0.8 (Bread)
2 0.8 (Diaper)
3 0.8 (Milk)
4 0.6 (Beer, Diaper)
5 0.6 (Diaper, Bread)
6 0.6 (Bread, Milk)
7 0.6 (Diaper, Milk)
🔹 Association Rules:
antecedents consequents support confidence lift
0 (Beer) (Diaper) 0.6 1.00 1.2500
1 (Diaper) (Beer) 0.6 0.75 1.2500
2 (Diaper) (Bread) 0.6 0.75 0.9375
3 (Bread) (Diaper) 0.6 0.75 0.9375
4 (Bread) (Milk) 0.6 0.75 0.9375
5 (Milk) (Bread) 0.6 0.75 0.9375
6 (Diaper) (Milk) 0.6 0.75 0.9375
7 (Milk) (Diaper) 0.6 0.75 0.9375