0

I'm using StandardScaler to transform data before providing training dataset to clustering model.

X = StandardScaler().fit_transform(X_train)

Assume, clf is the unsupervised cluster model, I'm predicting the labels as follows:

y = clf.predict(X)

Question: How do I combine "y" and "X_train" numpy arrays? I'm not sure if StandardScaler() maintains the order within the matrix. So, will this work?

df = pd.DataFrame(np.array(X_train), np.array(y))
Gordon Knot
  • 56
  • 1
  • 6

1 Answers1

1

Yes, all of the scikit-learn transformers maintain samples' ordering. Otherwise they would be useless.

lejlot
  • 64,777
  • 8
  • 131
  • 164