擅长:python、mysql、java
<p>基于这篇文章:<a href="https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range">https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range</a></p>
<p>您可以执行以下操作:</p>
<pre><code>def normalize(df):
result = df.copy()
for feature_name in df.columns:
max_value = df[feature_name].max()
min_value = df[feature_name].min()
result[feature_name] = (df[feature_name] - min_value) / (max_value - min_value)
return result
</code></pre>
<p>你不需要一直担心你的价值观是消极的还是积极的。值应该很好地分布在0和1之间。</p>