Invert MinMaxScaler from scikit_learn

前端 未结 3 1368
青春惊慌失措
青春惊慌失措 2021-02-20 06:15

To feed my generative neural net, I need to normalize some data between -1 and 1.

I do it with MinMaxScaler from Sklearn and it works great. Now, my generat

3条回答
  •  無奈伤痛
    2021-02-20 06:57

    def rev_min_max_func(scaled_val):
        max_val = max(df['target'])
        min_val = min(df['target'])
        og_val = (scaled_val*(max_val - min_val)) + min_val
        return og_val
    df['pred_target'] = scaled_labeled_df['pred_scaled_target'].apply(lambda x: rev_min_max_func(x))
    

    Even this works for me!

提交回复
热议问题