diff --git a/BML_project/active_learning/__pycache__/ss_active_learning.cpython-311.pyc b/BML_project/active_learning/__pycache__/ss_active_learning.cpython-311.pyc index 45c9875..8d691ba 100644 Binary files a/BML_project/active_learning/__pycache__/ss_active_learning.cpython-311.pyc and b/BML_project/active_learning/__pycache__/ss_active_learning.cpython-311.pyc differ diff --git a/BML_project/active_learning/ss_active_learning.py b/BML_project/active_learning/ss_active_learning.py index 98b9425..4442a34 100644 --- a/BML_project/active_learning/ss_active_learning.py +++ b/BML_project/active_learning/ss_active_learning.py @@ -57,6 +57,30 @@ def run_minibatch_kmeans(data_loader, n_clusters, device, batch_size=100): return minibatch_kmeans +""" from sklearn.cluster import MiniBatchKMeans +import numpy as np + +def run_minibatch_kmeans(data_loader, n_clusters, device, batch_size=100, n_init='auto'): + # Initialize MiniBatchKMeans with explicit n_init to suppress the FutureWarning + minibatch_kmeans = MiniBatchKMeans(n_clusters=n_clusters, n_init=n_init, random_state=0, batch_size=batch_size) + + # Prepare an empty list to collect all data for fitting + all_data = [] + + # Iterate through data_loader and collect data + for batch in data_loader: + # Assuming 'data' is a key in your batch dict that contains the features + data = batch['data'].view(batch['data'].size(0), -1).cpu().numpy() # Adjust as necessary + all_data.append(data) + + # Concatenate all data collected from the batches + all_data_np = np.concatenate(all_data, axis=0) + + # Fit MiniBatchKMeans with all collected data at once + minibatch_kmeans.fit(all_data_np) + + return minibatch_kmeans """ + # def compare_kmeans_gp_predictions(kmeans_model, gp_model, data_loader, device): # # Compare K-Means with GP model predictions # all_data, all_labels = [], [] diff --git a/BML_project/models/__pycache__/ss_gp_model.cpython-311.pyc b/BML_project/models/__pycache__/ss_gp_model.cpython-311.pyc index 7ea0e5a..75ee3d4 100644 Binary files a/BML_project/models/__pycache__/ss_gp_model.cpython-311.pyc and b/BML_project/models/__pycache__/ss_gp_model.cpython-311.pyc differ diff --git a/BML_project/utils_gp/__pycache__/ss_evaluation.cpython-311.pyc b/BML_project/utils_gp/__pycache__/ss_evaluation.cpython-311.pyc index 14c7dfa..46b1836 100644 Binary files a/BML_project/utils_gp/__pycache__/ss_evaluation.cpython-311.pyc and b/BML_project/utils_gp/__pycache__/ss_evaluation.cpython-311.pyc differ diff --git a/BML_project/utils_gp/__pycache__/visualization.cpython-311.pyc b/BML_project/utils_gp/__pycache__/visualization.cpython-311.pyc index a8c3afd..f53ef75 100644 Binary files a/BML_project/utils_gp/__pycache__/visualization.cpython-311.pyc and b/BML_project/utils_gp/__pycache__/visualization.cpython-311.pyc differ