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

How do I do it for multiple values of xi and yi? #96

Open
oq-9 opened this issue Mar 30, 2022 · 2 comments
Open

How do I do it for multiple values of xi and yi? #96

oq-9 opened this issue Mar 30, 2022 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@oq-9
Copy link

oq-9 commented Mar 30, 2022

How do I do it for multiple values of xi and yi? For example, I have:

X=
[[1.875, 1.875, 1.875, 2.5  ],
 [0.625, 3.125, 1.25 , 3.125],
 [3.125, 1.25 , 1.875, 0.625],
 [0.625, 1.25 , 0.625, 1.25 ],
 [0.625, 3.125, 0.625, 0.625]]
y=
[[3.],
[6.],
[9.],
[9.],
[6.]]

How do I calculate the weights for X that would fit y using the code above? Is there a way to calculate the error for each case and optimize accordingly from within the library?

@ahmedfgad ahmedfgad self-assigned this Mar 30, 2022
@ahmedfgad ahmedfgad added the question Further information is requested label Mar 30, 2022
@ahmedfgad
Copy link
Owner

This should be a multi-objective optimization problem. PyGAD only supports single-objective problems.

To do it in PyGAD, you should do the following:

  1. Set the number of genes in PyGAD to 20 (because X shape is 5x4=20).
  2. In the fitness function, reshape the solution into a 5x4 array.
  3. Multiply the solution by X, row by row, sum the results of each row to get only 5 outputs.
  4. Compare the 5 outputs to the y array and calculate the error for each y.
  5. Based on the 5 errors calculated, you should return a single value that represents the fitness.

I hope this helps. Please get back if further clarification is needed.

@Fern-Parker
Copy link

@oq-9 Hi, oq-9! Have you solved the problem? I've encountered the same problem with you. Could u share some experiences? Any help will be greatly appreciated!

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

No branches or pull requests

3 participants