Datasets:

Modalities:
Tabular
ArXiv:
DOI:
License:
File size: 1,648 Bytes
877367d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4a6035
 
 
 
 
 
 
 
 
 
 
 
 
877367d
 
 
 
f4a6035
 
 
 
 
 
 
 
 
 
877367d
 
 
 
 
f4a6035
877367d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import pandas as pd

def replace_empty_performance(directories, performance_column="performance"):
    for directory in directories:
        if not os.path.exists(directory):
            print(f"Directory {directory} does not exist, skipping...")
            continue
        
        csv_files = [f for f in os.listdir(directory) if f.endswith('.csv')]
        
        for file in csv_files:
            file_path = os.path.join(directory, file)
            try:
                print(f"Processing {file_path}...")

                opt_step = {
                    8: 0,
                    12: 1,
                    14: 2,
                    15: 3,
                    21: 4,
                    24: 5,
                    25: 6,
                    29: 7,
                    31: 8,
                    35: 9,
                }
                
                # Read CSV file
                df = pd.read_csv(file_path)
                
                def get_opt_step(config_id):
                    remainder = config_id % 35
                    for key, value in opt_step.items():
                        if remainder < key:
                            return value + (config_id // 35) * 10
                    assert False

                df["optimization_step"] = df["config_id"].map(get_opt_step)
                df.to_csv(file_path, index=False)
                print(f"Saved processed file: {file_path}\n")
                
            except Exception as e:
                print(f"Error processing {file_path}: {e}")

if __name__ == "__main__":
    directories = ["smac_mf"]
    replace_empty_performance(directories)