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

spread_min of hyperectangle_csr is not respected (Nested config problem?) #111

Closed
dpaetzel opened this issue Dec 1, 2023 · 3 comments · Fixed by #112
Closed

spread_min of hyperectangle_csr is not respected (Nested config problem?) #111

dpaetzel opened this issue Dec 1, 2023 · 3 comments · Fixed by #112

Comments

@dpaetzel
Copy link
Contributor

dpaetzel commented Dec 1, 2023

The spread_min setting is somehow not respected. For example,

import xcsf
import json

model = xcsf.XCS(max_trials=10, condition={"args": {"spread_min": 0.5}})

pop = json.loads(model.json())["classifiers"]

spreads = [rule["condition"]["spread"][0] for rule in pop]
print(np.min(spreads))

prints 0.10028… but I would expect this to be a number greater than 0.5.

Interestingly, the spread_min does not get propagated to the internal_params upon initialization

print(model.get_params()["condition"]["args"]["spread_min"])
# 0.5
print(model.internal_params()["condition"]["args"]["spread_min"])
# 0.1

and also not after during fitting

import numpy as np
X = np.random.random((100, 1))
y = np.random.random(100)
model.fit(X, y)
print(model.internal_params()["condition"]["args"]["spread_min"])
# 0.1

Since eta is not propagated through either, this may have something to do with the nested dict in the condition parameter?

model = xcsf.XCS(max_trials=10, condition={"args": {"eta": 0.5}})
print(model.get_params()["condition"]["args"]["eta"])
# 0.5
print(model.internal_params()["condition"]["args"]["eta"])
# 0
@rpreen
Copy link
Member

rpreen commented Dec 1, 2023

I believe this is because the condition dict doesn't include the type: if you use the following it will set the parameters:

model = xcsf.XCS(max_trials=10, condition={"type": "hyperrectangle_csr", "args": {"spread_min": 0.5}})

@rpreen
Copy link
Member

rpreen commented Dec 1, 2023

So probably there should be some better input checking to test for this...

@dpaetzel
Copy link
Contributor Author

dpaetzel commented Dec 1, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants