File size: 1,449 Bytes
1f4cd2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Filename: _2_scale_transform.py <br>
Title: Custom scale transformer for new user input <br>
Author: Raghava | GitHub: @raghavtwenty <br>
Date Created: June 10, 2023 | Last Updated: May 13, 2024 <br>
Language: Python | Version: 3.10.14, 64-bit <br>
"""

# Importing required library
import numpy as np


# Transformation function
def transform_new_input(new_input):

    # Scaled minimum and maximum values from preprocessing
    scaled_min = np.array(
        [
            1.0,
            10.0,
            856.0,
            5775.0,
            42.0,
            26.0,
            0.0,
            278.0,
            4.0,
            1.0,
            -630355.0,
            4.0,
            50.0,
        ]
    )

    scaled_max = np.array(
        [
            4.0,
            352752.0,
            271591638.0,
            239241314.0,
            421552.0,
            3317.0,
            6302708.0,
            6302708.0,
            5.0,
            5.0,
            1746749.0,
            608.0,
            1012128.0,
        ]
    )

    new_input = np.array(new_input)

    # Formula for transformation
    scaled_input = (new_input - scaled_min) / (scaled_max - scaled_min)

    return scaled_input


# Main
if __name__ == "__main__":
    # Test case
    test_input = [
        [2, 209, 20671, 6316631, 274, 96, 3527, 2757949, 5, 2, 183877, 8, 90494]
    ]

    print("Scaled value: ")
    print(transform_new_input(test_input))