我需要创建一台能够预测一个人是否在泰坦尼克号中生存的机器。有文件,培训文件和测试文件。我以前从未使用过Kmeans
,所以我使用了在教程中找到的参数
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)
我收到一条错误消息:
ValueError:估算器的无效参数标准 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,详细= 0)。查看可用清单 参数estimator.get_params().keys()
。
答案 0 :(得分:0)
假设它在R中。 kmeans函数采用至少2个参数 1.必须对其进行操作的数据集 2.以及初始质心的数量
这是文档说的(对于2.0.4版本) 用法:
KMeans(x, centers, iter.max=10, num.seeds=10)
参数
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).
中心
The number of clusters in the solution.
iter.max
The maximum number of iterations allowed.
种子数
The number of different starting random seeds to use. Each random seed results in a different k-means solution.
有关更多信息,refer