1
votes

I need to create a machine that will predict if a person survives in the Titanic or not. There are to files, the training file and the testing file. I never used Kmeans before so I used parameters that I found in tutorials

clf = KMeans(n_clusters=10)


acc_scorer = make_scorer(accuracy_score)

grid_obj = GridSearchCV(clf,parameters, scoring=acc_scorer)
grid_obj = grid_obj.fit(X_train, y_train)
clf = grid_obj.best_estimator_
clf.fit(X_train, y_train)

I get an error message:

ValueError: Invalid parameter criterion for estimator KMeans(algorithm='auto', copy_x=True, init='k-means++', max_iter=300, n_clusters=10, n_init=10, n_jobs=None, precompute_distances='auto',
random_state=None, tol=0.0001, verbose=0). Check the list of available parameters with estimator.get_params().keys().

1
Does the exception occur in this line clf = KMeans(n_clusters=10)? - rotem tal

1 Answers

0
votes

Assuming it is in R. The kmeans function takes atleast 2 arguments 1. The dataset that it has to operate on 2. and the no of initial centroids

This is the documentation says (for 2.0.4 version) Usage:

KMeans(x, centers, iter.max=10, num.seeds=10)

Arguments

x

A numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a dataframe with all numeric columns).

centers

The number of clusters in the solution.

iter.max

 The maximum number of iterations allowed.

num.seeds

The number of different starting random seeds to use. Each random seed results in a different k-means solution.

for more info refer