March 2020
Beginner to intermediate
352 pages
8h 40m
English
Although the quality column is numerical, here, we are interested in taking quality as the class. To make it clear, let's convert numerical values into categorical values in this subsection.
To do so, we need a set of rules. Let's define a set of rules:

That sounds doable, right? Of course, it is. Let's check the code, given as follows:
df_red['quality_label'] = df_red['quality'].apply(lambda value: ('low' if value <= 5 else 'medium') if value <= 7 else 'high')df_red['quality_label'] = pd.Categorical(df_red['quality_label'], categories=['low', 'medium', 'high'])df_white['quality_label'] = df_white['quality'].apply(lambda ...Read now
Unlock full access