-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Hi, I'm exploring this tool as a part of my research on RCN and wanted to see if this would help me learn and test for my application. But so far I'm unable to get anywhere with this. I'm currently using the dev branch as the main branch is also similar issues. I have all the required pip packages installed and yet I'm unable to run the provided examples. Most of the time the issue lie within the ESNClassifier and ESNRegressor classes. I'm attaching the error logs below. I'm sorry, that I couldn't contribute more, it's because I'm not very familiar with Python and Machine Learning. Hopefully these logs should help to fix the issues.
From setup_local.ipynb
from sklearn.datasets import load_iris, load_digits
from sklearn.preprocessing import LabelBinarizer
from sklearn.model_selection import train_test_split
from pyrcn.extreme_learning_machine import ELMRegressor
def test_iris():
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.05)
lb = LabelBinarizer().fit(y)
y_train_numeric = lb.transform(y_train)
classifier = ELMClassifier(hidden_layer_size=10)
classifier.fit(X_train, y_train_numeric)
y_predicted_numeric = classifier.predict(X_test)
y_predicted = lb.inverse_transform(y_predicted_numeric)
for record in range(len(y_test)):
print('predicted: {0} \ttrue: {1}'.format(y_predicted[record], y_test[record]))
test_iris()
Error Log:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 22
18 for record in range(len(y_test)):
19 print('predicted: {0} \ttrue: {1}'.format(y_predicted[record], y_test[record]))
---> 22 test_iris()
Cell In[4], line 14, in test_iris()
12 y_train_numeric = lb.transform(y_train)
13 classifier = ELMClassifier(hidden_layer_size=10)
---> 14 classifier.fit(X_train, y_train_numeric)
15 y_predicted_numeric = classifier.predict(X_test)
16 y_predicted = lb.inverse_transform(y_predicted_numeric)
File ~\Documents\Code\ReservoirComputing\PyRCN\src\pyrcn\extreme_learning_machine\_elm.py:500, in ELMClassifier.fit(self, X, y, n_jobs, transformer_weights)
478 def fit(self, X: np.ndarray, y: np.ndarray,
479 n_jobs: Union[int, np.integer, None] = None,
480 transformer_weights: Optional[np.ndarray] = None) -> ELMClassifier:
481 """
482 Fit the classifier.
483
(...) 498 self : Returns a trained ELMClassifier model.
499 """
--> 500 self._validate_data(X, y, multi_output=True)
501 self._encoder = LabelBinarizer().fit(y)
502 super().fit(X, self._encoder.transform(y), n_jobs=n_jobs,
503 transformer_weights=None)
AttributeError: 'ELMClassifier' object has no attribute '_validate_data'
Another example:
From stock-price-prediction.ipynb
Echo State Network preparation
base_input_to_nodes = InputToNode(hidden_layer_size=100, input_activation='identity',
k_in=1, input_scaling=0.6, bias_scaling=0.0)
base_nodes_to_nodes = NodeToNode(hidden_layer_size=100, spectral_radius=0.9, leakage=1.0, k_rec=10)
esn = ESNRegressor(input_to_node=base_input_to_nodes,
node_to_node=base_nodes_to_nodes,
regressor=IncrementalRegression(alpha=1e-8), random_state=10)
Training and Prediction.
X_train = X[0:train_len, :]
y_train = X[0+1:train_len+1, :]
X_test = X[0:train_len+future_total - future_len, :]
y_test = X[future_len:train_len+future_total, :]
esn.fit(X=X_train, y=y_train.ravel())
y_train_pred = esn.predict(X=X_train)
y_test_pred = esn.predict(X=X_test)
Error log:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[9], line 6
3 X_test = X[0:train_len+future_total - future_len, :]
4 y_test = X[future_len:train_len+future_total, :]
----> 6 esn.fit(X=X_train, y=y_train.ravel())
7 y_train_pred = esn.predict(X=X_train)
8 y_test_pred = esn.predict(X=X_test)
File ~\Documents\Code\ReservoirComputing\PyRCN\src\pyrcn\echo_state_network\_esn.py:308, in ESNRegressor.fit(self, X, y, n_jobs, transformer_weights)
285 def fit(self, X: np.ndarray, y: np.ndarray,
286 n_jobs: Union[int, np.integer, None] = None,
287 transformer_weights: Optional[np.ndarray] = None) -> ESNRegressor:
288 """
289 Fit the regressor.
290
(...) 306 self : Returns a trained ESNRegressor model.
307 """
--> 308 self._validate_hyperparameters()
309 if self.requires_sequence == "auto":
310 self._check_if_sequence(X, y)
File ~\Documents\Code\ReservoirComputing\PyRCN\src\pyrcn\echo_state_network\_esn.py:427, in ESNRegressor._validate_hyperparameters(self)
423 raise ValueError('Invalid value for requires_sequence, got {0}'
424 .format(self._requires_sequence))
426 if not is_regressor(self._regressor):
--> 427 raise TypeError("The last step should be a regressor and "
428 "implement fit and predict '{0}' (type {1})"
429 "doesn't".format(self._regressor,
430 type(self._regressor)))
TypeError: The last step should be a regressor and implement fit and predict 'IncrementalRegression(alpha=1e-08)' (type <class 'pyrcn.linear_model._incremental_regression.IncrementalRegression'>)doesn't
Even the intro notebook is having issues with the InputToNode, NodeToNode and NodeToOutput classes