数据预处理 --- 归一化
1、公式:2、APIsklearn.preprocessing.MinMaxScaler(feature_range=(0,1))MinMaxScaler.fit_transform(X)X:numpy array格式的数据 [n_samples,n_features]n_samples:样本数n_features:特征数(列)返回值:形状相同的array...
·
1、公式:
2、API
sklearn.preprocessing.MinMaxScaler(feature_range=(0,1))
MinMaxScaler.fit_transform(X)
X:numpy array格式的数据 [n_samples,n_features]
n_samples:样本数 n_features:特征数(列)
返回值:形状相同的array
3、缺点:由于归一化使用最大值最小值进行计算,若最大值、最小值缺失或错误,归一化结果的准确性就会大大降低,为此可采用标准化
ex_1
from sklearn.preprocessing import MinMaxScaler
import jieba
def minmax_demo():
'''
归一化
:return:
'''
data = pd.read_csv("data.txt")
data = data.iloc(:,:3)
transfer = MinMaxScaler()
data_new = transfer.fit_transform(data)
print("data_new:\n", data_new)
return None
更多推荐
已为社区贡献10条内容
所有评论(0)