https://github.com/aclai-lab/soledecisiontreeinterface.jl
Sole interface for trees trained via JuliaAI/DecisionTree.jl.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.0%) to scientific vocabulary
Repository
Sole interface for trees trained via JuliaAI/DecisionTree.jl.
Basic Info
Statistics
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 6
Metadata Files
README.md
Warning: This repository is deprecated. All functionalities have been moved to (a package extension of) SoleModels.jl. Please refer to that repository for continued support and updates.
SoleDecisionTreeInterface.jl
Ever wondered what to do with a trained decision tree? Start by inspecting its knowledge, and end up evaluating it in a dedicated framework! This package allows you to convert learned DecisionTree models to Sole decision tree models. With a Sole model in your hand, you can then treat the extracted knowledge in symbolic form, that is, as a set of logical formulas, which allows you to: - Evaluate them in terms of + accuracy (e.g., confidence, lift), + relevance (e.g., support), + interpretability (e.g., syntax height, number of atoms); - Modify them; - Merge them.
Usage
Converting to a Sole model
```julia using MLJ using MLJDecisionTreeInterface using DataFrames
X, y = @load_iris X = DataFrame(X)
train, test = partition(eachindex(y), 0.8, shuffle=true); Xtrain, ytrain = X[train, :], y[train]; Xtest, ytest = X[test, :], y[test];
Train a model
learneddttree = begin Tree = MLJ.@load DecisionTreeClassifier pkg=DecisionTree model = Tree(maxdepth=-1, ) mach = machine(model, Xtrain, ytrain) fit!(mach) fittedparams(mach).tree end
using SoleDecisionTreeInterface
Convert to Sole model
soledt = solemodel(learneddt_tree) ```
Model inspection & rule study
```julia-repl julia> using Sole;
julia> # Make test instances flow into the model, so that test metrics can, then, be computed. apply!(soledt, Xtest, y_test);
julia> # Print Sole model printmodel(soledt; showmetrics = true); ▣ V4 < 0.8 ├✔ setosa : (ninstances = 7, ncovered = 7, confidence = 1.0, lift = 1.0) └✘ V3 < 4.95 ├✔ V4 < 1.65 │├✔ versicolor : (ninstances = 10, ncovered = 10, confidence = 1.0, lift = 1.0) │└✘ V2 < 3.1 │ ├✔ virginica : (ninstances = 2, ncovered = 2, confidence = 1.0, lift = 1.0) │ └✘ versicolor : (ninstances = 0, ncovered = 0, confidence = NaN, lift = NaN) └✘ V3 < 5.05 ├✔ V1 < 6.5 │├✔ virginica : (ninstances = 0, ncovered = 0, confidence = NaN, lift = NaN) │└✘ versicolor : (ninstances = 0, ncovered = 0, confidence = NaN, lift = NaN) └✘ virginica : (ninstances = 11, ncovered = 11, confidence = 0.91, lift = 1.0)
julia> # Extract rules that are at least as good as a random baseline model interestingrules = listrules(soledt, minlift = 1.0, minninstances = 0);
julia> printmodel.(interestingrules; showmetrics = true); ▣ (V4 < 0.8) ∧ (⊤) ↣ setosa : (ninstances = 30, ncovered = 7, coverage = 0.23, confidence = 1.0, natoms = 1, lift = 4.29) ▣ (¬(V4 < 0.8)) ∧ (V3 < 4.95) ∧ (V4 < 1.65) ∧ (⊤) ↣ versicolor : (ninstances = 30, ncovered = 10, coverage = 0.33, confidence = 1.0, natoms = 3, lift = 2.73) ▣ (¬(V4 < 0.8)) ∧ (V3 < 4.95) ∧ (¬(V4 < 1.65)) ∧ (V2 < 3.1) ∧ (⊤) ↣ virginica : (ninstances = 30, ncovered = 2, coverage = 0.07, confidence = 1.0, natoms = 4, lift = 2.5) ▣ (¬(V4 < 0.8)) ∧ (¬(V3 < 4.95)) ∧ (¬(V3 < 5.05)) ∧ (⊤) ↣ virginica : (ninstances = 30, ncovered = 11, coverage = 0.37, confidence = 0.91, natoms = 3, lift = 2.27)
julia> # Simplify rules while extracting and prettify result interestingrules = listrules(soledt, minlift = 1.0, minninstances = 0, normalize = true);
julia> printmodel.(interestingrules; showmetrics = true, syntaxstringkwargs = (; thresholddigits = 2)); ▣ V4 < 0.8 ↣ setosa : (ninstances = 30, ncovered = 7, coverage = 0.23, confidence = 1.0, natoms = 1, lift = 4.29) ▣ (V4 ∈ [0.8,1.65)) ∧ (V3 < 4.95) ↣ versicolor : (ninstances = 30, ncovered = 10, coverage = 0.33, confidence = 1.0, natoms = 2, lift = 2.73) ▣ (V4 ≥ 1.65) ∧ (V3 < 4.95) ∧ (V2 < 3.1) ↣ virginica : (ninstances = 30, ncovered = 2, coverage = 0.07, confidence = 1.0, natoms = 3, lift = 2.5) ▣ (V4 ≥ 0.8) ∧ (V3 ≥ 5.05) ↣ virginica : (ninstances = 30, ncovered = 11, coverage = 0.37, confidence = 0.91, natoms = 2, lift = 2.27)
julia> # Directly access rule metrics readmetrics.(listrules(soledt; minlift=1.0, min_ninstances = 0)) 4-element Vector{NamedTuple{(:ninstances, :ncovered, :coverage, :confidence, :natoms, :lift), Tuple{Int64, Int64, Float64, Float64, Int64, Float64}}}: (ninstances = 30, ncovered = 7, coverage = 0.23333333333333334, confidence = 1.0, natoms = 1, lift = 4.285714285714286) (ninstances = 30, ncovered = 10, coverage = 0.3333333333333333, confidence = 1.0, natoms = 3, lift = 2.7272727272727275) (ninstances = 30, ncovered = 2, coverage = 0.06666666666666667, confidence = 1.0, natoms = 4, lift = 2.5) (ninstances = 30, ncovered = 11, coverage = 0.36666666666666664, confidence = 0.9090909090909091, natoms = 3, lift = 2.2727272727272725)
julia> # Show rules with an additional metric (syntax height of the rule's antecedent) printmodel.(sort(interestingrules, by = readmetrics); showmetrics = (; rounddigits = nothing, additionalmetrics = (; height = r->SoleLogics.height(antecedent(r)))));
▣ (V4 ≥ 1.65) ∧ (V3 < 4.95) ∧ (V2 < 3.1) ↣ virginica : (ninstances = 30, ncovered = 2, coverage = 0.06666666666666667, confidence = 1.0, height = 2, lift = 2.5) ▣ V4 < 0.8 ↣ setosa : (ninstances = 30, ncovered = 7, coverage = 0.23333333333333334, confidence = 1.0, height = 0, lift = 4.285714285714286) ▣ (V4 ∈ [0.8,1.65)) ∧ (V3 < 4.95) ↣ versicolor : (ninstances = 30, ncovered = 10, coverage = 0.3333333333333333, confidence = 1.0, height = 1, lift = 2.7272727272727275) ▣ (V4 ≥ 0.8) ∧ (V3 ≥ 5.05) ↣ virginica : (ninstances = 30, ncovered = 11, coverage = 0.36666666666666664, confidence = 0.9090909090909091, height = 1, lift = 2.2727272727272725)
julia> # Pretty table of rules and their metrics metricstable(interestingrules; metricskwargs = (; rounddigits = nothing, additionalmetrics = (; height = r->SoleLogics.height(antecedent(r))))) ┌────────────────────────────────────────┬────────────┬────────────┬──────────┬───────────┬────────────┬────────┬─────────┐ │ Antecedent │ Consequent │ ninstances │ ncovered │ coverage │ confidence │ height │ lift │ ├────────────────────────────────────────┼────────────┼────────────┼──────────┼───────────┼────────────┼────────┼─────────┤ │ V4 < 0.8 │ setosa │ 30 │ 7 │ 0.233333 │ 1.0 │ 0 │ 4.28571 │ │ (V4 ∈ [0.8,1.65)) ∧ (V3 < 4.95) │ versicolor │ 30 │ 10 │ 0.333333 │ 1.0 │ 1 │ 2.72727 │ │ (V4 ≥ 1.65) ∧ (V3 < 4.95) ∧ (V2 < 3.1) │ virginica │ 30 │ 2 │ 0.0666667 │ 1.0 │ 2 │ 2.5 │ │ (V4 ≥ 0.8) ∧ (V3 ≥ 5.05) │ virginica │ 30 │ 11 │ 0.366667 │ 0.909091 │ 1 │ 2.27273 │ └────────────────────────────────────────┴────────────┴────────────┴──────────┴───────────┴────────────┴────────┴─────────┘ ```
Owner
- Name: Applied Computational Logic and Artificial Intelligence Laboratory
- Login: aclai-lab
- Kind: organization
- Email: aclai@unife.it
- Location: Italy
- Website: aclai.unife.it
- Repositories: 14
- Profile: https://github.com/aclai-lab
Applied Computational Logic and Artificial Intelligence (ACLAI) Laboratory of the Department of Mathematics and Computer Science, University of Ferrara
GitHub Events
Total
- Release event: 2
- Watch event: 3
- Delete event: 1
- Issue comment event: 14
- Push event: 10
- Pull request review event: 3
- Pull request event: 4
- Fork event: 1
- Create event: 5
Last Year
- Release event: 2
- Watch event: 3
- Delete event: 1
- Issue comment event: 14
- Push event: 10
- Pull request review event: 3
- Pull request event: 4
- Fork event: 1
- Create event: 5
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: about 2 months
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: about 2 months
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- JuliaTagBot (1)
Pull Request Authors
- Perro2110 (1)
- giopaglia (1)
- dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 6
juliahub.com: SoleDecisionTreeInterface
Sole interface for trees trained via JuliaAI/DecisionTree.jl.
- Documentation: https://docs.juliahub.com/General/SoleDecisionTreeInterface/stable/
- License: MIT
-
Latest release: 0.1.5
published over 1 year ago
Rankings
Dependencies
- actions/checkout v4 composite
- codecov/codecov-action v4 composite
- julia-actions/cache v2 composite
- julia-actions/julia-buildpkg v1 composite
- julia-actions/julia-docdeploy v1 composite
- julia-actions/julia-processcoverage v1 composite
- julia-actions/julia-runtest v1 composite
- julia-actions/setup-julia v2 composite
- JuliaRegistries/TagBot v1 composite