in [ ]from sklearn preprocessing import binarizer bn binarizer(threshold= pd_watched bn transform([popsong_df['listen_count']])[ popsong_df['pd_watched'pd_watched popsong_df head( figure - binarizing song counts you can clearly see from figure - that both the methods have produced the same results depicted in features watched and pd_watched thuswe have the song listen counts as binarized feature indicating if the song was listened to or not by each user rounding often when dealing with numeric attributes like proportions or percentageswe may not need values with high amount of precision hence it makes sense to round off these high precision percentages into numeric integers these integers can then be directly used as raw numeric values or even as categorical (discreteclass basedfeatures let' try applying this concept in dummy dataset depicting store items and their popularity percentages in [ ]items_popularity pd read_csv('datasets/item_popularity csv'encoding='utf- 'rounding off percentages items_popularity['popularity_scale_ 'np array(np round((items_popularity['pop_percent' ))dtype='int'items_popularity['popularity_scale_ 'np array(np round((items_popularity['pop_percent' ))dtype='int'items_popularity out[ ]item_id pop_percent popularity_scale_ popularity_scale_ it_ it_ it_ it_