Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Weka contextualizer for machine learning not working with explicit archetypes instantiated by randomly sampling a quality over space #13

Open
diegomvd opened this issue Sep 27, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@diegomvd
Copy link
Contributor

Context

Attempting to learn a Bayesian Network from distributed data (qualities and not instances of subjects) and explicitly defining an archetype by selecting learning instances via random spatial sampling. Minimal example:

Archetype definition:

model each earth:Site with im:High geography:Elevation,
    geography:Elevation in m,
    earth:AtmosphericTemperature in Celsius,
    geography:Slope in degree_angle
    observing
        geography:Elevation in m named elev,
        earth:AtmosphericTemperature in Celsius named temp,
        geography:Slope in degree_angle
        using gis.points.extract(select = [ elev > 1500 && random() > 0.999]); // randomly sampling space

Bayesian Network learning:

learn geography:Elevation within earth:Site
    observing
        @archetype earth:Site with im:High geography:Elevation,
        @predictor earth:AtmosphericTemperature,
        @predictor geography:Slope
    using im.weka.bayesnet(resource = elev.ml );    

Expected behavior

  1. Successful archetype instantiation : this works.
  2. Production of a Bayesian Network resource when executing the learner: this fails.

Error encountered

Directly executing the learner throws a java.lang.IllegalStateException: Weka: the archetype observations do not contain values for the learned quality and all predictors: missing [elevation, atmospheric_temperature_of_site, slope].

Instantiating the archetype and then executing the learner throws a warning: variable elev undefined. Defining as numeric no-data (NaN) for subsequent evaluations. and then the same error java.lang.IllegalStateException: Weka: the archetype observations do not contain values for the learned quality and all predictors: missing [elevation, atmospheric_temperature_of_site, slope]. The dataflow shows that the learner doesn't use the resolved archetype but instead resolves it again and seems to fail to extract correctly the points because does not recognize elev variable in the groovy expression.

What is working

Learning from a distributed context with an implicit archetype works:

learn geography:Elevation
	observing 
	@predictor earth:AtmosphericTemperature in Celsius
	@predictor geography:Slope in degree_angle
	using im.weka.bayesnet( learned.elevation )

Learning with an explicit archetype directly modeled from a dataset containing the learning instances also works. Note that the following code requires the import of an external resource to function, thus serves only for illustration.

/* The archetype: 
In the resource there are features named elev, temp and slope. 
These 2 features are semantically annotated by geogrpahy:Elevation, earth:AtmosphericTemperature and geography:Slope respectively.
*/
model each "elevation:URN" 
	as earth:Site with im:High geography:Elevation,
	elev as geography:Elevation,
	temp as earth:AtmosphericTemperature in Celsius,
	slope as geography:Slope in degree_angle;

learn geography:Elevation within earth:Site
	observing 
	@archetype earth:Site with im:High geography:Elevation
    @predictor earth:AtmosphericTemperature in Celsius
	@predictor geography:Slope in degree_angle
	using im.weka.bayesnet( learned.elevation )

@iperdomo iperdomo added the bug Something isn't working label Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants