Own minmax scaler VS scikit

Hej community

This is slightly concerning DQ course and this screen but I just curious. Please don’t waste too much time on answering :slightly_smiling_face:

I’ve used scikit library to calculate minmax scaling, here’s my code:

from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()

best_churn['scaled_tran'] = None
best_churn['scaled_amount'] = None

best_churn[['scaled_tran', 'scaled_amount']] = scaler.fit_transform(best_churn[['nr_of_transactions', 'amount_spent']])
    
best_churn['score'] = 100*(.5 * best_churn['scaled_tran'] + .5 * best_churn['scaled_amount'])

best_churn.sort_values(by='score',inplace=True,ascending=False)

But when I’ve checked the answer I’ve got a message that solution is wrong. After some time digging I’ve found out that difference in calculated result lies in 16th digit after the floating point. f.eks

0.4816810344827586 (own solution)
0.4816810344827587 (scikit)

I’m just curious why?!? :slight_smile: Thanks in advance

Alas, our answer checking has some issues with precision. Your solution is correct, don’t worry about it :slight_smile:

1 Like