# 特征01归一化处理 ProcessDataSet1 = preprocess(dataset1, feature1, True) ProcessDataSet1_x = ProcessDataSet1.drop( ['user_id', 'label', 'coupon_id'], axis=1) for i in ProcessDataSet1_x.columns: ProcessDataSet1_x[i] = MinMaxScaler(copy=True, feature_range=(0, 1)).fit_transform(ProcessDataSet1_x[i].values.reshape(-1, 1)) ProcessDataSet1_norm = pd.concat([ProcessDataSet1['user_id'], ProcessDataSet1['label'], ProcessDataSet1['coupon_id'], ProcessDataSet1_x], axis=1) ProcessDataSet1_norm.to_csv(os.path.join(DataPath, 'ProcessDataSet1_norm.csv'), index=None)将上述代码改写,功能不变
时间: 2024-03-22 10:39:16 浏览: 97
以下是修改后的代码,其功能与原代码相同:
```
ProcessDataSet1 = preprocess(dataset1, feature1, True)
ProcessDataSet1_x = ProcessDataSet1.drop(['user_id', 'label', 'coupon_id'], axis=1)
scaler = MinMaxScaler(feature_range=(0, 1))
ProcessDataSet1_x = pd.DataFrame(scaler.fit_transform(ProcessDataSet1_x), columns=ProcessDataSet1_x.columns)
ProcessDataSet1_norm = pd.concat([ProcessDataSet1['user_id'], ProcessDataSet1['label'], ProcessDataSet1['coupon_id'], ProcessDataSet1_x], axis=1)
ProcessDataSet1_norm.to_csv(os.path.join(DataPath, 'ProcessDataSet1_norm.csv'), index=None)
```
阅读全文