len(set(prediction)) from visuals_functions import three_d_scatter_rotation_gen,three_d_cluster_rotation_gen,binary_prediction cluster_plot_generator = three_d_cluster_rotation_gen(X_minus2[:,2:], rotation_angle=22.5,predictions=(prediction-1)) next(cluster_plot_generator) plt.show() # http://stackoverflow.com/questions/19633336/using-numbers-as-matplotlib-plot-markers gen=three_d_cluster_rotation_gen(X_minus2[:,2:],rotation_angle=22.5,predictions=binary_prediction(prediction)[0],type_marker="regular") next(gen) plt.show() max_d = 1.1 prediction = fcluster(single_hierarchy_minus2, max_d, criterion='distance') # number of unique clusters: len(set(prediction)) cluster_plot_generator = three_d_cluster_rotation_gen(X_minus2[:,2:], rotation_angle=22.5,predictions=(prediction-1))
def test5_binary(): pred = np.array([1, 2, 1, 1, 1, 1, 2, 2, 0]) output_pred = np.array([1, 0, 1, 1, 1, 1, 0, 0, 0]) assert_allclose(binary_prediction(pred)[0], output_pred) assert (binary_prediction(pred)[1], 1)