Smadx / USTC-ML24-Fall

18 stars 12 forks source link

[lab1]关于分类任务的均值 #10

Closed tracer524 closed 1 month ago

tracer524 commented 1 month ago

使用python trainC.py --results_path"..\results\train\" 运行trainC.py时,meanNone. 检查发现原因是trainC.py--mean参数的默认值为None

Screenshot 2024-09-27 at 17 20 55

,也就是说传入submission.pydata_preprocessing_classification()方法的meanNone. 经过测试,在Windows系统下可以运行(尽管meanNone),而在MacOS下会报错:

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'

请问是应该自己手动添加参数,设置mean为第一部分预测出的结果吗?

Smadx commented 1 month ago

是的,你需要在运行分类任务时在命令中把第一部分预测的均值指定为mean参数作为分类基准