Class imbalance occurs when there is a disproportionate ratio of different classes in a dataset. In the context of cancer, it could mean that within a dataset of medical images, a large majority are healthy cases with only a few cases of a specific cancer type. This imbalance can cause machine learning algorithms to perform poorly, particularly in identifying the minority class, which in this case is often the cancerous samples.