generated from LufsX/Experiment-kNN
This commit is contained in:
+8
-3
@@ -1,6 +1,5 @@
|
||||
import numpy as np
|
||||
import os
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
|
||||
|
||||
"""
|
||||
@@ -103,8 +102,14 @@ def load_dataset(directory):
|
||||
labels.append(label)
|
||||
data_set.append(img_to_vector(os.path.join(root, file)))
|
||||
data_set = np.array(data_set).reshape(len(data_set), - 1)
|
||||
scaler = StandardScaler()
|
||||
data_set = scaler.fit_transform(data_set)
|
||||
|
||||
# 找到数据集中的最大值和最小值
|
||||
data_min = np.min(data_set)
|
||||
data_max = np.max(data_set)
|
||||
|
||||
# 归一化数据
|
||||
data_set = (data_set - data_min) / (data_max - data_min)
|
||||
|
||||
return data_set, np.array(labels)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user