优化一下代码x_temp_feature_names =[i for i in x.columns if 'firstorder' in i or 'glszm'in i or 'glrlm' in i or 'glcm' in i or 'gldm' in i or 'ngtdm' in i or 'shape' in i] x_temp = x[x_temp_feature_names].copy()
时间: 2023-12-21 07:06:28 浏览: 62
可以使用以下方法对代码进行优化:
```
feature_types = ['firstorder', 'glszm', 'glrlm', 'glcm', 'gldm', 'ngtdm', 'shape']
x_temp_feature_names = [i for i in x.columns if any(feature_type in i for feature_type in feature_types)]
x_temp = x[x_temp_feature_names].copy()
```
这样做可以将多个条件合并为一个any语句,从而使代码更简洁。
阅读全文