Skip to content

Instantly share code, notes, and snippets.

View mxposed's full-sized avatar

Nick Markov mxposed

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# сохранить предсказания в переменную predictions
predictions = clf.predict(test_input)
# создать из предсказаний объект DataFrame (и назвать колонку в нём Label) и сохранить в переменную predictions_df
predictions_df = pd.DataFrame(predictions, columns=['Label'])
# обозвать индексную колонку ImageId
predictions_df.index.name = 'ImageId'
# записать в файлик
# таблица с результатами и параметрами
clf.grid_scores_
# отфильтровать из неё записи, где параметр p был 2, а параметр weights был distance и положить результат в переменную means
means = filter(lambda x: x[0]['p'] == 2 and x[0]['weights'] == 'distance', clf.grid_scores_)
# нарисовать график, в котором по оси абсцисс параметр n_neighbors, а по оси ординат score
plt.plot([x[0]['n_neighbors'] for x in means], [x[1] for x in means])
@mxposed
mxposed / gist:3918196
Created October 19, 2012 13:21
Update endpoint bug proof
std::vector<cocaine_endpoint_t> new_endpoints;
std::vector<cocaine_endpoint_t> missing_endpoints2;
get_endpoints_diff(endpoints, new_endpoints, missing_endpoints);
if (!missing_endpoints.empty()) {
for (size_t i = 0; i < m_endpoints.size(); ++i) {
if (false == std::binary_search(endpoints_tmp.begin(), endpoints_tmp.end(), m_endpoints[i])) {
missing_endpoints2.push_back(m_endpoints[i]);
}