Apply MinMaxScaler to column 0
Great question! Let's carefully analyze the preprocessing step by step.
Dataset
X = np.array([
[2.0, 'apple'],
[5.0, 'banana'],
[1.0, 'apple'],
[4.0, 'cherry']
])
-
Column 0 = numerical values:
[2.0, 5.0, 1.0, 4.0] -
Column 1 = categorical values:
['apple', 'banana', 'apple', 'cherry']
Step 1: Apply MinMaxScaler to column 0
MinMaxScaler scales values to range [0,1]:
-
min = 1.0
-
max = 5.0
So, scaled values:
-
For 2.0 →
-
For 5.0 →
-
For 1.0 →
-
For 4.0 →
So numerical column becomes: [0.25, 1, 0, 0.75]
Step 2: Apply OneHotEncoder to column 1
Unique categories: ['apple', 'banana', 'cherry']
-
"apple" → [1, 0, 0]
-
"banana" → [0, 1, 0]
-
"cherry" → [0, 0, 1]
Step 3: Combine results for the first row
First row = [2.0, 'apple']
-
Scaled numeric = 0.25
-
OneHot("apple") = [1, 0, 0]
Final transformed row = [0.25, 1, 0, 0]
✅ Correct Answer: Option 1 → [0.25, 1, 0, 0]
Would you like me to also break this into a small table showing how all rows look after transformation (not just the first)?
Comments
Post a Comment