Machine Learning Practice, End Term
Given the following code snippet that preprocesses a dataset with both continuous and categorical features using sklearn.preprocessing tools, what will be the first row of the X_transformed array after preprocessing?
import numpy as npfrom sklearn.preprocessing import MinMaxScaler, OneHotEncoderfrom sklearn.compose import ColumnTransformer
X = np.array([[2.0, 'apple'], [5.0, 'banana'], [1.0, 'apple'], [4.0, 'cherry']])
preprocessor = ColumnTransformer( transformers=[('num', MinMaxScaler(), [0]), ('cat', OneHotEncoder(), [1])])
X_transformed = preprocessor.fit_transform(X)print(X_transformed[0])Given the following code snippet that preprocesses a dataset with both continuous and categorical features using sklearn.preprocessing tools, what will be the first row of the X_transformed array after preprocessing? import numpy as np from sklearn.preprocessing import MinMaxScaler, OneHotEncoder from sklearn.compose import ColumnTransformer X = np.array([[2.0, 'apple'], [5.0, 'banana'], [1.0, 'apple'], [4.0, 'cherry']]) preprocessor = ColumnTransformer( transformers=[('num', MinMaxScaler(), [0]), ('cat', OneHotEncoder(), [1])]) X_transformed = preprocessor.fit_transform(X) print(X_transformed[0]) What will be the output of the following code? import pandas as pd from sklearn.preprocessing import StandardScaler data = pd.DataFrame({ 'col1': [1, 2, 3, 4, 5], 'col2': [10, 20, 30, 40, 50] }) ss = StandardScaler() scaled_data = ss.fit_transform(data) print(ss.var_) Imagine you are using a Dummy Regressor with strategy=median. Given the following dataset: | S.No | $X_1$ | $X_2$ | $X_3$ | $Y$ | |---|---|---|---|---| | 1 | 2.3 | 4.5 | 3.2 | 10.5 | | 2 | 1.8 | 3.2 | 4.1 | 12.3 | | 3 | 2.5 | 4.1 | 2.9 | 11.1 | | 4 | 2.0 | 3.8 | 3.5 | 9.8 | | 5 | 1.9 | 3.6 | 3.0 | 10.9 | | 6 | 2.4 | 4.2 | 3.3 | 11.5 | What will be the predicted output for an input X = [2.1,3.9,3.2] ?