-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from zStupan/main
Updated RuleList
- Loading branch information
Showing
4 changed files
with
111 additions
and
148 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Example usage of the RuleList class. The RuleList class is a wrapper around a python list, with some added features, mainly | ||
getting statistical data of rule metrics and sorting by metric. | ||
""" | ||
|
||
|
||
from niaarm import NiaARM, Dataset | ||
from niapy.algorithms.basic import DifferentialEvolution | ||
from niapy.task import Task, OptimizationType | ||
|
||
|
||
if __name__ == '__main__': | ||
# Load the dataset and run the algorithm | ||
data = Dataset("datasets/Abalone.csv") | ||
problem = NiaARM(data.dimension, data.features, data.transactions, metrics=('support', 'confidence')) | ||
task = Task(problem=problem, max_iters=30, optimization_type=OptimizationType.MAXIMIZATION) | ||
algo = DifferentialEvolution(population_size=50, differential_weight=0.5, crossover_probability=0.9) | ||
algo.run(task=task) | ||
|
||
# print the RuleList to get basic data about the mined rules. | ||
print(problem.rules) | ||
|
||
# RuleList also provides methods for getting the min, max, mean and std. dev. of metrics: | ||
print('Min support', problem.rules.min('support')) | ||
print('Max support', problem.rules.max('support')) | ||
print('Mean support', problem.rules.mean('support')) | ||
print('Std support', problem.rules.std('support')) | ||
|
||
# you can also use RuleList.get to get all values of a metric as a numpy array: | ||
print(problem.rules.get('support')) |
This file contains 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