This file contains hidden or 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
| 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'] |
This file contains hidden or 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
| #!../venv/bin/python | |
| import json | |
| import math | |
| import collections | |
| import pandas as pd | |
| def entropy(target_col): |
This file contains hidden or 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
| 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( |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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.
This file contains hidden or 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
| #!/usr/bin/python | |
| import argparse | |
| import itertools | |
| import collections | |
| sample = [ | |
| ['Butter', 'Bread', 'Milk'], | |
| ['Bread', 'Milk'], |
This file contains hidden or 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
| #!/usr/bin/python | |
| import argparse | |
| import itertools | |
| import collections | |
| def get_frequent_itemsets(transactions, min_support): | |
| # Count individual items | |
| freq = collections.defaultdict(int) |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| #!../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'}, |
NewerOlder