Unable to apply SFS to a sklearn-wrapped Keras classifier neuralnet #777
Answered
by
rasbt
leowang396
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
rasbt
Feb 8, 2021
Replies: 1 comment 3 replies
-
Hi @shengdiWang , I was trying to reproduce your Iris example but can't get it to reproduce your error because of a different error: logs---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-15-e0bffb350382> in <module>
42
43 # Apply SFS to identify best feature subset
---> 44 sffs = sffs.fit(iris_train,
45 iris_test)
...
110 # Running inside `run_distribute_coordinator` already.
~/miniconda3/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1102 end_step = step + data_handler.step_increment
1103 callbacks.on_train_batch_end(end_step, )
-> 1104 epoch_logs = copy.copy()
1105
1106 # Run validation.
UnboundLocalError: local variable 'logs' referenced before assignmentlogs
Regarding your error, a)One hypothesis is that it has something to do with your X_train, x_test inputs to # Apply SFS to identify best feature subset
sffs = sffs.fit(iris_train,
iris_test) because the from sklearn.model_selection import train_test_split
dataset = load_iris()
X_train, X_test, y_train, y_test = train_test_split(dataset.data, dataset.target, test_size=0.2)
sfs.fit(X_train, y_train) b)The other hypothesis is that keras may return incompatible outputs. I remember there was some reshaping necessary in a PR recently: https://github.com/rasbt/mlxtend/pull/725/files |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
rasbt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @shengdiWang ,
I was trying to reproduce your Iris example but can't get it to reproduce your error because of a different error: