TPM034A / Q2_2024

This is the official repo for Machine Learning for Socio-technical system course (TPM034a)
1 stars 0 forks source link

Issue with Infinite Loop During GridSearch Refitting #2

Open evalievanoijen opened 23 hours ago

evalievanoijen commented 23 hours ago

Dear TAs,

I ran into a problem while working on the lab assignments. Specifically, the following code cell seems to cause the model to get stuck in an infinite loop during the refitting process:

if the model RF_gridsearch.pickle does not exist, conduct the gridsearch, else load the grid_search object

if not Path('RF_gridsearch.pickle').exists():

# Fit the grid search object to the training data
# Note that this is computationally expensive! 
# It may take up to 5 minutes, since multiple models need to be trained multiple times
rf_gridsearch.fit(X_train, Y_train)

# Save the trained grid_search object
with open('RF_gridsearch.pickle', 'wb') as f:
    pickle.dump(rf_gridsearch, f)

else:

Load the trained grid_search object

with open('RF_gridsearch.pickle', 'rb') as f:
    rf_gridsearch = pickle.load(f)

Print the best parameters

print('Best parameters:') print(f'Tuned hyperparameters:\n{rf_gridsearch.bestparams}') print(f'Mean Squared Error:\t{(-rf_gridsearch.bestscore):0.3f}')

Despite waiting for a considerable amount of time and trying several potential fixes, I haven’t been able to resolve the issue. This is preventing me from completing the last three questions of the lab.

Could you help me identify what might be causing this issue and how to fix it?

Thank you in advance for your time and support!

Best regards, Evalie van Oijen

spierenbu commented 21 hours ago

Hi Evalie!

This issue does not seem to be easily fixed remotely. Could you come to us in the next lab session?

Have a nice evening!

evalievanoijen commented 20 hours ago

Hi Lucas,

Unfortunately, I can't make it to the lab session tomorrow because I have to attend another course for my master’s program. The error I ran into is from the lab session itself, so I think other students might run into it as well.

Best,

spierenbu commented 4 hours ago

Hello! I checked this morning, setting up the same virtual environment as the one provided in the course and I could not reproduce your issue...

I will see if other students have the same issue and post the solution here.

FGarridoV commented 2 hours ago

Hello @evalievanoijen!

I explored a bit, and I think this grid search could take considerable time depending on the computer resources. I've just updated a new pickle file with the results of the grid search. Can you clone again the repo, and run the code again. I think now it should run immediately for you as it will load the pickle file I added.

Let me know, Francisco