```import numpy as np
import pandas as pd
import sklearn.preprocessing as ps
a = np.array([[17,100,4000],
[20,80,5000],
[23,75,5500]])
one_process = ps.scale(a)
print(one_process )```

```mss = ps.MinMaxScaler(feature_range=(0,1))
mss_tm = mss.fit_transform(a)
print(mss_tm)
#范围缩放手写实现
new = []
num = 0
for i in a.T:
s = i.min()
b = i.max()
arr1 = np.array([[s,1],[b,1]])
arr2 = np.array([0,1])
solve = np.linalg.solve(arr1,arr2)
new.append(i*solve[0]+solve[1])
num += 1
new = np.array(new).T
print(new)```

```b = np.array([[12,3,9],[20,5,15],[1,3,20]])
p = ps.normalize(b,norm="l1")
print(p)```

```bins = ps.Binarizer(threshold=81)
anay = bins.transform(a)
print(anay)```

```from sklearn.datasets import fetch_olivetti_faces
import matplotlib.pyplot as plt
feaces = fetch_olivetti_faces()
plt.imshow(feaces.images[0],cmap="gray")```

```one = feaces.images[0]
mid = np.median(one)
ones = ps.Binarizer(threshold=mid)
ones_data = ones.fit_transform(one)
print(ones_data)```

`plt.imshow(ones_data,cmap="gray")`

```simple = np.array([[1,3,2],
[7,5,4],
[1,8,6],
[7,3,9]])
#当sparse=False时按照相应的数组形式输出。
ohe = ps.OneHotEncoder(sparse=False,dtype="int64")
rult = ohe.fit_transform(simple)
print(rult)
print(ohe.categories_)#显示每个离散值的顺序```

```#当sparse=FTrue时按照稀疏矩阵形式输出，即输出每个1的坐标。
simple = np.array([[1,3,2],
[7,5,4],
[1,8,6],
[7,3,9]])
ohe = ps.OneHotEncoder(sparse=True,dtype="int32")
rult = ohe.fit_transform(simple)
print(rult)```

```label = np.array(["香蕉","苹果","西瓜","香蕉","橙子","西瓜","西瓜","葡萄","杏子","梨子","猕猴桃"])
le = ps.LabelEncoder()
le_label = le.fit_transform(label)
print(le_label)```

```#inverse_transform():通过已经fit_transform()后的数字标签返回原始的标签。
i_list = [0,5,6,7]
inverse = le.inverse_transform(i_list)
print(inverse)```

```"""
feathers = np.array([["香蕉","猫","鸡"],
["葡萄","狗","鸭"],
["桃子","猫","鹅"],
["梨子","狗","鹅"]])
oe = ps.OrdinalEncoder(dtype="int64")
oe_feather = oe.fit_transform(feathers)
print(oe_feather)```

```from sklearn.impute import KNNImputer
df = np.array([[1,2,np.NaN,9],
[4,np.NaN,3,8],
[np.NaN,5,6,7],
[6,4,9,np.NaN]])
KI = KNNImputer(n_neighbors=3)
k_t=KI.fit_transform(df)
print(k_t)```