SINDy shows AttributeError: module 'numpy' has no attribute 'math' when attempting to fit a SINDy model. #611
giopapanas
started this conversation in
Problems and Solutions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi PySINDy community! I am writing a prototype PySINDy code for my data. I have 11 variables called: 'CVD60','t2m', 'ws', 'wd', 'tp', 'blh', 'ssr', 'no2', 'o3', 'so2', 'pm10'. I have these measurements taken everyday across several years, hence my time step is t=1 (1 day).
However, I keep on getting the error: AttributeError: module 'numpy' has no attribute 'math'. I also get this error when I was fitting the models in the PySINDY examples. I believe I have installed the environment and its dependencies fine.
Here is my prototype code (which I aim to optimize later, after I make it to work). Note that the X shape is (9127, 11) and the dt shape is (9127,):
feature_names = ['CVD60','t2m', 'ws', 'wd', 'tp', 'blh', 'ssr', 'no2', 'o3', 'so2', 'pm10']
Extract the features from the dataframe
X = data1[feature_names].values
dt = data1['Date'].values
print(X.shape)
print(dt.shape)
Define the differentiation method, feature library, and optimization algorithm
differentiation_method = ps.FiniteDifference(order=2)
feature_library = ps.PolynomialLibrary(degree=3)
optimizer = ps.STLSQ(threshold=0.2)
Create a SIMPLE SINDy model
model = ps.SINDy(differentiation_method=differentiation_method,
feature_library=feature_library,
optimizer=optimizer,feature_names=feature_names)
Fit the model to the data
model.fit(X, t=dt)
model.print()`
I am actually get the following error (entire copy):
AttributeError Traceback (most recent call last)
Cell In[41], line 36
31 model = ps.SINDy(differentiation_method=differentiation_method,
32 feature_library=feature_library,
33 optimizer=optimizer,feature_names=feature_names)
35 # Fit the model to the data
---> 36 model.fit(X, t=dt)
37 model.print()
39 # Loop through the dataframes and fit a SINDy model to each
40 #for i, data in enumerate(data_list):
41 # Features to use in the SINDy model
(...) 62 # opt = ps.LASSO(threshold=0.1, alpha=0.1)
63 # opt = ps.Ridge(alpha=0.1)
File c:\Users\giorg\pysindy\venv\Lib\site-packages\pysindy\pysindy.py:343, in SINDy.fit(self, x, t, x_dot, u, multiple_trajectories, unbias, quiet, ensemble, library_ensemble, replace, n_candidates_to_drop, n_subset, n_models, ensemble_aggregator)
337 u = validate_control_variables(
338 x,
339 u,
340 trim_last_point=(self.discrete_time and x_dot is None),
341 )
342 self.n_control_features_ = u[0].shape[u[0].ax_coord]
--> 343 x, x_dot = self._process_multiple_trajectories(x, t, x_dot)
345 # Set ensemble variables
346 self.ensemble = ensemble
...
425 return char.chararray
--> 427 raise AttributeError("module {!r} has no attribute "
428 "{!r}".format(name, attr))
AttributeError: module 'numpy' has no attribute 'math'
Do you believe it has to do with how PySINDY reads the multiple trajectories across numerous variables in X or smg else? Thank you very much in advance!
Beta Was this translation helpful? Give feedback.
All reactions