How to get model attributes in scikit learn (not hyper parameters)
I believe you are trying to access &quot;labels_&quot; before fitting the data.
from sklearn.cluster import KMeans
import numpy as np
X = np.array([[1, 2], [1, 4], [1, 0],
               [10, 2], [10, 4], [10, 0]])
kmeans = KMeans(n_clusters=2, random_state=0).fit(X)

def get_properies(model):   
  return [i for i in model.__dict__ if i.endswith(‘_’)] 

get_properies(kmeans)


['n_clusters',
'init',
'max_iter',
'tol',
'precompute_distances',
'n_init',
'verbose',
'random_state',
'copy_x',
'n_jobs',
'algorithm',
'cluster_centers_',
'labels_',
'inertia_',
'n_iter_']