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

SymbolicRegressor output support for multi-dimensional y #220

Open
superminghui opened this issue Feb 3, 2021 · 9 comments
Open

SymbolicRegressor output support for multi-dimensional y #220

superminghui opened this issue Feb 3, 2021 · 9 comments

Comments

@superminghui
Copy link

My outputnode corresponds to an array, not a single value. So my y is a two-dimensional array
But when I was training, something went wrong, he told me:
ValueError: y should be a 1d array, got an array of shape (15, 1600) instead.
My output y looks like this:
[[0. 0. 0. ... 0. 0. 0.] --------> y1
[0. 0. 0. ... 0. 0. 0.] --------> y2
[0. 0. 0. ... 0. 0. 0.] --------> y3
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]
Each individual array represents an output.

So I want to ask if there is any way to solve this problem?

@superminghui
Copy link
Author

The output y in example SymbolicRegressor like :
[1,
2,
4,
5,
...
n]
But my output y is array like this:
[[0. 0. 0. ... 0. 0. 0.] --------> y1
[0. 0. 0. ... 0. 0. 0.] --------> y2
[0. 0. 0. ... 0. 0. 0.] --------> y3
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]

So i met problem....
How could i solve this?

@superminghui
Copy link
Author

I find the from sklearn.multioutput imported MultiOutputRegressor may can solve this problem
but how could i add it to the gplearn?
Is there any way? Please advise
Thanks soooo much

@trevorstephens
Copy link
Owner

It looks like gplearn should be compatible with that wrapper, do you run into any issues when trying to follow the syntax in that example with your data? Or maybe a small slice of your data to test with? https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.MultiOutputRegressor.html

@superminghui
Copy link
Author

It looks like gplearn should be compatible with that wrapper, do you run into any issues when trying to follow the syntax in that example with your data? Or maybe a small slice of your data to test with? https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.MultiOutputRegressor.html

By using MultiOutputRegressor like this?:

est_gp = MultiOutputRegressor(SymbolicRegressor(
    population_size=500,
    generations=80, stopping_criteria=0.1,
    p_crossover=0.6,
    p_subtree_mutation=0.2, p_hoist_mutation=0.1,
    p_point_mutation=0.1,
    max_samples=0.9, verbose=1,
    parsimony_coefficient=0.01, random_state=0
))

est_gp.fit(train_x, train_y)

Is this correct? Can run

@superminghui
Copy link
Author

It looks like gplearn should be compatible with that wrapper, do you run into any issues when trying to follow the syntax in that example with your data? Or maybe a small slice of your data to test with? https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.MultiOutputRegressor.html

But if i use MultiOutputRegressor like this:
est_gp = MultiOutputRegressor(SymbolicRegressor(
population_size=500,
generations=80, stopping_criteria=0.1,
p_crossover=0.6,
p_subtree_mutation=0.2, p_hoist_mutation=0.1,
p_point_mutation=0.1,
max_samples=0.9, verbose=1,
parsimony_coefficient=0.01, random_state=0
))

est_gp.fit(train_x, train_y)

then i cant use the funciton _program to get the solution.

@trevorstephens
Copy link
Owner

With this module in sklearn there will be several estimators, one for each target. You will need to access the estimators_ attribute which will be a list of n_output gplearn estimators which will each have a _program attribute hopefully 🤞

@galenseilis
Copy link

Any progress in understanding how to setup having multiple outputs since this thread was last updated?

@trevorstephens
Copy link
Owner

Also requested in #218

@trevorstephens
Copy link
Owner

No progress right now @galenseilis , going through the issue traker right now to determine what makes it to the next release though.

@trevorstephens trevorstephens changed the title For SymbolicRegressor, my output y must be a one-dimensional array, can't it be multi-dimensional? SymbolicRegressor output support for multi-dimensional y Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants