Datasets:
Tasks:
Tabular Regression
Sub-tasks:
tabular-single-column-regression
Languages:
English
Size:
100K<n<1M
ArXiv:
License:
| #!/usr/bin/env python3 | |
| """ | |
| Prepare dataset_CO2: copies _init.cif files, writes id_prop.csv without .cif extension. | |
| Filters by |adsorption_energy| <= 2. | |
| """ | |
| import shutil | |
| import csv | |
| from pathlib import Path | |
| def main(): | |
| base_dir = Path("/media/herman/New Volume/Aixelo/DatasetAix/ODAC") | |
| pristine_co2_dir = base_dir / "pristine_CO2" / "pristine_CO2" | |
| adsorption_energy_file = base_dir / "adsorption_energy.txt" | |
| output_dir = base_dir / "dataset_CO2" | |
| raw_dir = output_dir / "raw" | |
| raw_dir.mkdir(parents=True, exist_ok=True) | |
| print("Reading adsorption_energy.txt...") | |
| energy_data = {} | |
| with open(adsorption_energy_file, 'r') as f: | |
| for line in f: | |
| line = line.strip() | |
| if not line: | |
| continue | |
| parts = line.split() | |
| if len(parts) >= 2: | |
| try: | |
| energy_data[parts[0]] = float(parts[1]) | |
| except ValueError: | |
| continue | |
| print(f"Loaded {len(energy_data)} entries") | |
| print("Finding _init.cif files...") | |
| init_files = list(pristine_co2_dir.rglob("*_init.cif")) | |
| print(f"Found {len(init_files)} _init.cif files") | |
| matched_files = [] | |
| for cif_path in init_files: | |
| filename = cif_path.name # e.g. ABEFUL_w_CO2_1_init.cif | |
| if not filename.endswith("_init.cif"): | |
| continue | |
| base_name = filename[:-9] # remove "_init.cif" (9 chars) → ABEFUL_w_CO2_1 | |
| if base_name in energy_data: | |
| energy = energy_data[base_name] | |
| if abs(energy) <= 2: | |
| matched_files.append((cif_path, base_name, energy)) | |
| print(f"Matched {len(matched_files)} files with |energy| <= 2") | |
| csv_data = [] | |
| for cif_path, base_name, energy in matched_files: | |
| dest_path = raw_dir / f"{base_name}.cif" # rename: убираем _init суффикс тоже (опционально) | |
| shutil.copy2(cif_path, dest_path) | |
| csv_data.append((base_name, energy)) # БЕЗ .cif расширения | |
| csv_path = output_dir / "id_prop.csv" | |
| print(f"Writing {csv_path}...") | |
| with open(csv_path, 'w', newline='') as f: | |
| writer = csv.writer(f) | |
| writer.writerow(['odac_id', 'adsorption_energy']) | |
| for odac_id, energy in csv_data: | |
| writer.writerow([odac_id, energy]) | |
| print(f"Done! {len(csv_data)} entries written.") | |
| print(f" raw/ → {raw_dir}") | |
| print(f" csv → {csv_path}") | |
| if __name__ == "__main__": | |
| main() | |