Repository navigation
Conversation
…e intervals according to found distribution
…feature refinement, add permutation feature importance
…tolearn into forest_learner
TripleStoreReasoner.instances rewrote every "?x a " occurrence in the generated SPARQL to the same "?some_cls" variable. For class expressions placing multiple such occurrences in different scopes (e.g. inside vs. outside a FILTER NOT EXISTS block, as with (¬Daughter) ⊓ Female), the shared variable name let occurrences bind to each other instead of being scoped independently, producing incorrect results. Each occurrence now gets its own uniquely numbered ?some_cls_N variable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tests/test_triplestore_indirect_instances_sparql.py mocks the HTTP layer (matching the existing tests/test_triplestore_sparql_optimizations.py pattern) so it exercises TripleStoreReasoner.instances' query-construction logic without needing a live triplestore. Verified the tests fail against the pre-fix code (both occurrences share "?some_cls") and pass against the fix (each gets its own "?some_cls_N"). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix variable capture in indirect instance retrieval SPARQL (#575)
…) as optional hook - CELOE._add_node_evald (celoe.py) was a near-duplicate of _add_node with zero call sites anywhere in the repo; removed along with the now-unused EvaluatedConcept import. - BaseConceptLearner.train() was a no-op stub whose docstring claimed "Train RL agent ... Returns: self" while returning None, and trainable learners (Drill, NCES, NCES2, ROCES, CLIP) each define their own train() with unrelated signatures. It now returns self as documented and its docstring states the real contract: an optional, learner-specific hook that defaults to a no-op so untrainable learners work in generic pipelines like Experiments.carry_out_kfold_cross_validation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Fx5MeTtkbrDshy6vQs3LY
Fixes the Improvements.md error-handling item: two bare `except:` blocks (data_struct.py) that swallowed everything including KeyboardInterrupt/ SystemExit are narrowed to the specific exception they're actually guarding against (ValueError, KeyError). SPARQLQueryLearner's _http_request now raises requests.exceptions.HTTPError instead of a bare Exception, letting _compute_f1_score narrow its catch to the query's actual failure modes. TDL's three feature-extraction methods (tree_learner.py) no longer let a bug in OWL-object construction hide behind the same except as a benign reasoner miss, and now always log the caught exception instead of only when verbose>0. CELOE's `updating_node`/`heuristic_queue.discard` ValueError, previously a silent `pass` next to an unresolved TODO, is now documented (SortedSet keyed by a mutable heuristic value; ValueError means queue membership and the node's heuristic went out of sync) and logged instead of ignored. The remaining nces.py/nces2.py broad catches are left as Exception with clarifying comments: they wrap parsing of raw, unconstrained neural model output, where the failure surface is inherently unbounded by design. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zxtYvm4ti1QCNsxMYvES8
Addresses the first bullet of Improvements.md's "Error handling & logging" section: knowledge_base.py, semantic_caching.py, learners/tree_learner_refinement_inherit.py, learners/spell_kit/structures.py, and learners/drill.py now emit info/warning/debug/error through logging.getLogger(__name__) instead of unconditionally printing to stdout. structure_to_dot's print()s are left untouched since they're the function's actual DOT-graph output, not log messages. Remaining offenders (nces.py, nces2.py, tree_learner.py, celoe.py, sparql_query_learner.py, data_struct.py) overlap with the broad-except cleanup and are left for that pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…train-stub Remove dead CELOE._add_node_evald
Narrow bare/broad except clauses in learners and data_struct
Route print() calls through module loggers in the worst offenders
Removed one email contact from the README.
ontolearn.lp_generator.LPGen/KB2Data synthesize learning problems bottom-up by refining owl:Thing and keeping whatever non-redundant concepts fall out, with no way to target specific DL constructs or a complexity budget. Add GoalDirectedLPGenerator: samples target concepts top-down from an explicit DL-construct grammar (ComplexityProfile controls which of intersection/union/exists/forall/cardinality/has-value/negation are allowed, plus length/depth/arity bounds), retrieves pos/neg via the reasoner, and filters out trivially-solvable problems (where a cheap one-step hypothesis already separates pos/neg). generate_benchmark() runs a curriculum of profiles at once. examples/benchmark_complexity_lp_generator_with_tdl.py demonstrates the generator end-to-end: a 6-step complexity curriculum on the Family KG, fitting TDL on each generated problem and scoring its learned hypothesis against the target's ground-truth (E+, E-). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extend GoalDirectedLPGenerator to actively search for hard learning problems, not just non-trivial ones: - DifficultyWeights/ComplexityProfile.difficulty_score combines normalized target length/depth, (1 - baseline F1), and near-miss-negative density (individuals satisfying the target with one top-level conjunct dropped, e.g. right class but wrong relation) into one score. - generate() oversamples candidates (profile.oversample_factor) and keeps the num_lps hardest by that score, instead of the first num_lps that clear the minimum bar. - Negative examples are biased towards near-miss negatives (hard_negative_ratio), the negatives most likely to trip up a greedy top-down learner. - The DL-construct grammar now degrades gracefully on a knowledge base with no object properties (e.g. Lymphography) instead of crashing: relation-based constructs (exists/forall/cardinality/has-value) are silently dropped from what's sampled. Verified across Family (dense relational), Lymphography (zero object properties), Biopax (ontology-heavy, many properties) and Mutagenesis (14k individuals) - each KB's own signature drives generation, so the same ComplexityProfile curriculum runs unmodified on all of them. examples/benchmark_complexity_lp_generator_with_tdl.py now sweeps a list of knowledge bases (--kb accepts multiple paths, defaulting to Family, Mutagenesis, Carcinogenesis, Biopax, Lymphography) and reports difficulty alongside TDL's F1 per (kb, profile). On Biopax this surfaces a real TDL weakness invisible on Family: mean F1 drops to 0.40 on the "conjunctive" profile, including one target TDL misses entirely (F1=0.0). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The {} default was mutated in place via setdefault('cv', 10), leaking
state between learner instances and into caller-supplied dicts. Default
is now None and each instance gets its own copy. Adds a regression test
and prunes the item from Improvements.md.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…id-search Fix shared mutable default kwargs_grid_search in TDL/TDL_refinement
Add goal-directed, complexity-controlled learning-problem generator
datapoint_neg was looked up with embeddings.loc[pos]; use neg. Adds a regression test that compares values, not just shapes. Fixes #638. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Targets three of the weakest-covered modules listed in Improvements.md: quality_funcs 31% -> 100%, nces_utils 39% -> 87%, incomplete_kb 8% -> 91%. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
data_struct ~60% -> 97%, value_splitter 33% -> 100%, utils/static_funcs 37% -> 92%. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fix CLIPDatasetInference using positive examples for the negative tensor
Add unit tests for quality_funcs, nces_utils, incomplete_kb, data_struct, value_splitter, static_funcs
Add regression guard for explicit owl:Thing patterns in generated SPARQL (#581)
…used logging_tentris.conf Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Prepare 0.11.0 release
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ontolearn 0.11.0
A stability and correctness release: a new goal-directed learning-problem generator, reproducible Drill runs, a long list of bug fixes across TDL, CELOE, TripleStore, NCES and CLIP, and a much better-tested codebase.
Highlights
GoalDirectedLPGenerator(ontolearn.lp_generator). Generates learning problems top-down from an explicit DL-construct grammar instead of refiningowl:Thingbottom-up likeLPGen/KB2Data.ComplexityProfile/DLConstructcontrol which constructors (⊓, ⊔, ∃, ∀, cardinality, has-value, ¬) and which length/depth/arity bounds are used.generate()oversamples and keeps the hardest problems by a difficulty score (target length/depth, baseline F1, near-miss negatives).generate_benchmark()runs a whole curriculum of profiles.examples/benchmark_complexity_lp_generator_with_tdl.py.Drill(random_state=...)seeds a dedicated RNG plustorch/CUDA (DRILL quality assertion in test_example_concept_learning_evaluation.py is flaky #624), andLPGen/KB2Datatake arandom_seedbacked by their own RNG instead of the globalrandommodule (LPGen not deterministic #595). (EvoLearneris still unseeded.)∃r.⊤on triplestores without reasoning (Difference in F1 Score Results Between KnowledgeBase and TripleStore Using Same OWL Ontology #581), correct variable scoping for indirect instances (Issue with indirect instance retrieval on TripleStore #575), andindividuals_count/most_general_object_propertiesnow use server-sideCOUNT/ASKinstead of pulling whole result sets (TripleStore.individuals_count / most_general_object_properties fetch full SPARQL result sets instead of using COUNT/ASK #613).Upgrade notes
owlready2an optional extra.ontolearn.incomplete_kbandontolearn.semantic_cachingimport it lazily; install it explicitly if you use them with owlready2.ontolearn/tentris.py(not importable since the owlapy 1.1.0 migration),CELOE._add_node_evald,ontolearn/logging_tentris.conf.TDL/TDL_refinementno longer share a mutablekwargs_grid_searchdefault between instances.TDL/TDL_refinementdata-property filtering gained a toggle for boolean data properties (use_data_properties_boolean, Data property filtering logic for TDL and some fixes for TDL++ #588); TDL's feature-matrixmax_runtimenow defaults toNone(Tdl max runtime implementation #585).print()ed inknowledge_base,semantic_caching,drilland a few more modules now goes throughlogging(configure levels as usual).Fixed
TDL_refinement.classification_reportalways raisedAttributeError(Deduplicate TDL_refinement.fit() against TDL via shared template-method hooks #616).DRILLSearchTreePriorityQueue.get_top_ncrashed (Fix AttributeError in DRILLSearchTreePriorityQueue.get_top_n #605);LengthBasedRefinementnever skipped disjoint refinements (Fix dead disjointness check in LengthBasedRefinement.refine_atomic_co… #604).ALCSAT/SPELLcrashed on ontologies with illegal punning such as Biopax (ALC-SAT/Spell crashing during KnowledgeBase initialization #598, via owlapy 1.6.6).EvoLearnerinstances no longer clobber each other's DEAP types (Fix EvoLearner clobbering DEAP creator types across concurrent instances #609).NCESTrainer/NCES/NCES2/ROCESmultiprocessing DataLoader deadlocks (CI hangs for hours in NCESTrainer.train() — repeated num_workers=8 DataLoader creation deadlocks under coverage #610, CI: NCES tests intermittently hang for 1h+ in GitHub Actions #622).TripleStore.peek()crash for properties without domain/range axioms.ConceptAbstractSyntaxTreeBuilderrepairs.LearningProblemGeneratorworks again (Learning problem generator issue_576 #589); TDL++ integer handling (Added example generation of learning problems with numeric data properties, fixes for TDL++ (after ruff version change) #593).exceptclauses narrowed so real errors are no longer swallowed.Performance
ModifiedCELOERefinementcomputesmax_nr_fillerslazily instead of sweeping every property against every individual up front (ModifiedCELOERefinement._setup does an eager O(properties×individuals) reasoner sweep for card-restriction setup #612).TDL_refinementrenders each feature's DL syntax once instead of per example (TDL_refinement: DL-syntax rendering repeated per-example instead of per-feature in _merge_binary_feature_matrices #611).COUNT/ASKqueries (see above).Internal
TDL_refinement.fit()/create_training_datadeduplicated into sharedTDLhooks (Deduplicate TDL_refinement.fit() against TDL via shared template-method hooks #616);abox(),get_top_nandquality_funcsdeduplicated.quality_funcs(31→100%),nces_utils(39→87%),incomplete_kb(8→91%),data_struct(~60→97%),value_splitter(33→100%) andutils/static_funcs(37→92%).>=0.16with an explicitruff.toml; CI job has a 90-minute safety timeout.Full changelog: https://github.com/dice-group/Ontolearn/blob/develop/CHANGELOG.md
Compare: 0.10.0...0.11.0
🤖 Generated with Claude Code