-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMinMaxScaler.m
36 lines (29 loc) · 904 Bytes
/
MinMaxScaler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
classdef MinMaxScaler < handle
% Min-max Scaler. The vector or matrix
% is standardized using the formula
% X = (X - min) / (max - min)
% where mu is the mean and sigma is the
% standard deviation.
properties
mmin
mmax
end
methods
function scaler = MinMaxScaler()
end
function fit(scaler, X, dim)
scaler.mmin = min(X, [], dim);
scaler.mmax = max(X, [], dim);
end
function Y = transform(scaler, X)
Y = (X - scaler.mmin) ./ (scaler.mmax - scaler.mmin);
end
function Y = fittransform(scaler, X, dim)
scaler.fit(X, dim);
Y = scaler.transform(X);
end
function X = inversetransform(scaler, Y)
X = Y .* (scaler.mmax - scaler.mmin) + scaler.mmin;
end
end
end