-
Notifications
You must be signed in to change notification settings - Fork 216
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
Refactor of PySRRegressor #146
Refactor of PySRRegressor #146
Conversation
Code now allows for better interoperability with scikit-learn.
Awesome contribution, thank you so much @tttc3! This is great. I am reviewing now. |
General comment: is there a way I can continue a search? In the current PySR, if you run Basically, it stores the Julia output into Edit: I thought about this some more. Maybe the best strategy is to have a parameter passed: |
I see this warning when I run
|
The following code produces an error with these changes when it doesn't on master. Something to do with feature selection? import numpy as np
import pandas as pd
from pysr import PySRRegressor
X = pd.DataFrame({f"k{i}": np.random.randn(1000) for i in range(30)})
y = X["k15"] ** 2 + np.cos(X["k20"])
model = PySRRegressor(unary_operators=["cos"], select_k_features=3)
model.fit(X, y)
ypred = model.predict(X) # Errors Edit: added this as a unit-test |
The latest commit should resolve the following: With respect to continuing a fit, the scikit-learn standard way is to inform the fit method via the |
Thanks! I'm still seeing some issues with the selection for some reason. For example, if I take the above example, and pass a numpy array instead of a pandas dataframe: import numpy as np
import pandas as pd
from pysr import PySRRegressor
X = pd.DataFrame({f"k{i}": np.random.randn(1000) for i in range(30)})
y = X["k15"] ** 2 + np.cos(X["k20"])
model = PySRRegressor(unary_operators=["cos"], select_k_features=3)
model.fit(X.values, y.values)
ypred = model.predict(X.values) # Errors Added as a unittest. |
Okay I got it working with the following "band-aid fix" to import platform
if platform.system() == "Darwin": # (macOS)
# Julia, then Torch
from pysr.julia_helpers import init_julia
Main = init_julia()
import torch
else:
# Torch, then Julia
import torch |
Okay looks like everything is working now. Let me know if you'd like to look over anything, otherwise I can merge. Also added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic! Thanks so much for this incredible contribution. I have reviewed all changes and it's looking great.
Thanks, glad to help! Just addressed some DeepSource issues but other than that, hopefully everything is good for merge. I'm investigating the pytorch issue and will follow up anything useful in your issue. |
Re Issue #143
Compatibility with scikit-learn should be improved.
Noteable breaking changes for users:
PySRRegressor.equations
is now calledPySRRegressor.equations_
Tests have been updated to allow compatibility with the refactored code but still assess the same functionality. All tests should pass.
Please let me know if there are any concerns or if you would like me to document/explain any of the changes in detail.