Skip to content

Instantly share code, notes, and snippets.

View rhoit's full-sized avatar
🎪
An empty shell

rho rhoit

🎪
An empty shell
View GitHub Profile
import sklearn.tree
import sklearn.metrics
import matplotlib.pyplot as plt
import sklearn.tree
import sklearn.preprocessing
import pandas as pd
df = pd.read_csv('./data/cricket.csv')
labelEncoder = sklearn.preprocessing.LabelEncoder()
features = ['outlook', 'temperature', 'humidity', 'wind']
@rhoit
rhoit / id3.py
Created February 16, 2026 03:09
#!../venv/bin/python
import json
import math
import collections
import pandas as pd
def entropy(target_col):
import sklearn.tree
import sklearn.preprocessing
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('data/movie.csv')
labelEncoder = sklearn.preprocessing.LabelEncoder()
fig, axes = plt.subplots(1, 2, layout='tight')
for i, name in enumerate(('popcorn', 'coke')):
decisionTreeClassifier = sklearn.tree.DecisionTreeClassifier(
popcorn coke age watch
Yes Yes 7 No
Yes No 12 No
No Yes 18 Yes
No Yes 35 Yes
Yes Yes 38 Yes
Yes No 50 No
No No 83 No
outlook temperature humidity wind play
sunny hot high weak no
sunny hot high strong no
overcast hot high weak yes
rain mild high weak yes
rain cool normal weak yes
rain cool normal strong no
overcast cool normal strong yes
sunny mild high weak no
sunny cool normal weak yes
This file has been truncated, but you can view the full file.
#!/usr/bin/python
import argparse
import itertools
import collections
sample = [
['Butter', 'Bread', 'Milk'],
['Bread', 'Milk'],
#!/usr/bin/python
import argparse
import itertools
import collections
def get_frequent_itemsets(transactions, min_support):
# Count individual items
freq = collections.defaultdict(int)
shrimp almonds avocado vegetables mix green grapes whole weat flour yams cottage cheese energy drink tomato juice low fat yogurt green tea honey salad mineral water salmon antioxydant juice frozen smoothie spinach olive oil
burgers meatballs eggs
chutney
turkey avocado
mineral water milk energy bar whole wheat rice green tea
low fat yogurt
whole wheat pasta french fries
soup light cream shallot
frozen vegetables spaghetti green tea
french fries
#!../venv/bin/python
import pandas as pd
import mlxtend.preprocessing
import mlxtend.frequent_patterns
# 1. Prepare the dataset (list of lists)
dataset = [
{'Butter', 'Bread', 'Milk'},
{'Bread', 'Milk'},