Traceback (most recent call last):
File "/Users/tracer/Desktop/Courses/2024 Fall/机器学习/Labs/lab1/src/trainC.py", line 140, in <module>
main()
File "/Users/tracer/Desktop/Courses/2024 Fall/机器学习/Labs/lab1/src/trainC.py", line 115, in main
dataset = data_preprocessing_classification(cfg.data_dir, cfg.mean)
File "/Users/tracer/Desktop/Courses/2024 Fall/机器学习/Labs/lab1/src/submission.py", line 409, in data_preprocessing_classification
df['label'] = df['Run_time'].apply(lambda x: 1 if x > mean else 0)
File "/opt/anaconda3/envs/ml24/lib/python3.9/site-packages/pandas/core/series.py", line 4917, in apply
return SeriesApply(
File "/opt/anaconda3/envs/ml24/lib/python3.9/site-packages/pandas/core/apply.py", line 1427, in apply
return self.apply_standard()
File "/opt/anaconda3/envs/ml24/lib/python3.9/site-packages/pandas/core/apply.py", line 1507, in apply_standard
mapped = obj._map_values(
File "/opt/anaconda3/envs/ml24/lib/python3.9/site-packages/pandas/core/base.py", line 921, in _map_values
return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
File "/opt/anaconda3/envs/ml24/lib/python3.9/site-packages/pandas/core/algorithms.py", line 1743, in map_array
return lib.map_infer(values, mapper, convert=convert)
File "lib.pyx", line 2972, in pandas._libs.lib.map_infer
File "/Users/tracer/Desktop/Courses/2024 Fall/机器学习/Labs/lab1/src/submission.py", line 409, in <lambda>
df['label'] = df['Run_time'].apply(lambda x: 1 if x > mean else 0)
TypeError: '>' not supported between instances of 'float' and 'NoneType'
使用
python trainC.py --results_path"..\results\train\"
运行trainC.py
时,mean
为None
. 检查发现原因是trainC.py
中--mean
参数的默认值为None
:,也就是说传入
submission.py
中data_preprocessing_classification()
方法的mean
为None
. 经过测试,在Windows系统下可以运行(尽管mean
为None
),而在MacOS下会报错:请问是应该自己手动添加参数,设置
mean
为第一部分预测出的结果吗?