Python division

前端 未结 12 1011
挽巷
挽巷 2020-11-21 06:23

I was trying to normalize a set of numbers from -100 to 0 to a range of 10-100 and was having problems only to notice that even with no variables at all, this does not evalu

12条回答
  •  忘了有多久
    2020-11-21 07:07

    Personally I preferred to insert a 1. * at the very beginning. So the expression become something like this:

    1. * (20-10) / (100-10)
    

    As I always do a division for some formula like:

    accuracy = 1. * (len(y_val) - sum(y_val)) / len(y_val)
    

    so it is impossible to simply add a .0 like 20.0. And in my case, wrapping with a float() may lose a little bit readability.

提交回复
热议问题