# plot number of samples in each class# Assuming 'data' is your numpy array with class labelsunique_elements = np.unique(ar=images_label, return_counts=True)classes = unique_elements[0]counts = unique_elements[1]print(f"Classes: {classes}")print(f"Counts: {counts}")
Code
# Plotting the bar graphplt.bar(x=classes, height=counts)plt.xlabel(xlabel="Class")plt.ylabel(ylabel="Number of samples")plt.title(label="Number of samples in each class")plt.show()
Code
images_array: NDArray[float64] = np.array(object=images_array)images_label: NDArray = np.array(object=images_label)print(f"shape of images array: {images_array.shape}, dtype: {images_array.dtype}")print(f"shape of images label: {images_label.shape}, dtype: {images_label.dtype}")
Code
plt.figure(figsize=(20, 7))for i, data_ inenumerate(iterable=images_array[:10]): plt.subplot(2, 5, i +1) plt.imshow(X=data_.astype(uint)) plt.xlabel(xlabel=images_label[i])plt.show()
print(f"train input shape: {x_train.shape}, with type: {x_train.dtype}")print(f"train output shape: {y_train.shape}, with type: {y_train.dtype}")print(f"test input shape: {x_test.shape}, with type: {x_test.dtype}")print(f"test output shape: {y_test.shape}, with type: {y_test.dtype}")
Code
%timetrain_features_with_centroid: NDArray[float64] = np.nan_to_num( x=np.array(object=[extract_features_with_centroid(image=image) for image in x_train] ))test_features_with_centroid: NDArray[float64] = np.nan_to_num( x=np.array(object=[extract_features_with_centroid(image=image) for image in x_test]))