def kmeans_classifier(prediction, ticket_predict_weights, ticket_target_list, tickets_to_weights_matrix):
kmeans = MiniBatchKMeans(n_clusters=len(ticket_target_list), init_size=len(tickets_to_weights_matrix) + 1)
kmeans.fit(tickets_to_weights_matrix)
predicted_class = kmeans.predict(ticket_predict_weights)[0]
print "kmeans prediction: {}".format(ticket_target_list[predicted_class])
if prediction is not None:
prediction.append([ticket_target_list[predicted_class]])
评论列表
文章目录