帮我转为python语言:[P_train, ps_input] = mapminmax(P_train, 0, 1); P_test = mapminmax('apply', P_test, ps_input); t_train = categorical(T_train)'; t_test = categorical(T_test )';
时间: 2023-12-22 14:04:06 浏览: 69
python语言转换
当然可以!
```python
from sklearn.preprocessing import MinMaxScaler
import numpy as np
scaler = MinMaxScaler(feature_range=(0, 1))
P_train = np.array(P_train)
P_test = np.array(P_test)
P_train_scaled = scaler.fit_transform(P_train)
P_test_scaled = scaler.transform(P_test)
ps_input = scaler.get_params()
t_train = np.array(T_train)
t_train_categorical = np.array(pd.get_dummies(t_train)).T
t_test = np.array(T_test)
t_test_categorical = np.array(pd.get_dummies(t_test)).T
```
请注意,此处假设你已经导入了必要的库(例如sklearn和numpy)。此外,我还假设输入数据P_train和P_test已经存在,并且T_train和T_test是对应的目标变量。
阅读全文