diff --git a/internbootcamp/bootcamp/ChemStructure2Property/InChI2logPBootCamp.py b/internbootcamp/bootcamp/ChemStructure2Property/InChI2logPBootCamp.py index d6ddc90..bcca08f 100755 --- a/internbootcamp/bootcamp/ChemStructure2Property/InChI2logPBootCamp.py +++ b/internbootcamp/bootcamp/ChemStructure2Property/InChI2logPBootCamp.py @@ -20,11 +20,10 @@ class InChI2logPbootcamp(Basebootcamp): 生成一组数字和目标值。 """ self.InChIGenerator = InChIGenerator(max_atoms=self.max_atoms, min_atoms=self.min_atoms, elements=None, seed=None) - inchis = self.InChIGenerator.generate_n_valid_inchi(10) + inchis = self.InChIGenerator.generate_n_valid_inchi(1) # print(inchis) - n = random.randint(0, 9) # print(n) - return inchis[n] + return inchis[0] def prompt_func(self, InChI) -> str: diff --git a/internbootcamp/bootcamp/ChemStructure2Property/SMILES2logPBootCamp.py b/internbootcamp/bootcamp/ChemStructure2Property/SMILES2logPBootCamp.py index f8a2eca..6426cc3 100755 --- a/internbootcamp/bootcamp/ChemStructure2Property/SMILES2logPBootCamp.py +++ b/internbootcamp/bootcamp/ChemStructure2Property/SMILES2logPBootCamp.py @@ -21,7 +21,7 @@ class SMILES2logPbootcamp(InChI2logPbootcamp): 生成一组数字和目标值。 """ self.SMILESGenerator = SMILESGenerator(min_len=self.min_len, max_len=self.max_len, seed=None) - return self.SMILESGenerator.generate_n_valid_smiles(10)[random.randint(0, 9)] + return self.SMILESGenerator.generate_n_valid_smiles(1)[0] def prompt_func(self, SMILES) -> str: @@ -63,5 +63,5 @@ class SMILES2logPbootcamp(InChI2logPbootcamp): return 0.0 # Error is too large, score is 0 else: # Linear interpolation: score decreases linearly from 1 to 0 as error goes from 0 to max_relative_error - return 1.0 + # return 1.0 return 1 - (relative_error / max_relative_error) * 0.5 ## For RL diff --git a/internbootcamp/bootcamp/symbolic_regression/symbolic_regression.py b/internbootcamp/bootcamp/symbolic_regression/symbolic_regression.py index 9dfd0a9..33c1cd1 100644 --- a/internbootcamp/bootcamp/symbolic_regression/symbolic_regression.py +++ b/internbootcamp/bootcamp/symbolic_regression/symbolic_regression.py @@ -138,9 +138,9 @@ Based on the above data, please infer the possible formula. Ensure that your inf x, y_true = data[:, :var_num], data[:, -1] except Exception as e: # import traceback - print("Exception while parsing symbolic formulas:", e) - print("Infer formula:", infer_formula) - print("Ground truth formula:", gt_formula) + # print("Exception while parsing symbolic formulas:", e) + # print("Infer formula:", infer_formula) + # print("Ground truth formula:", gt_formula) # traceback.print_exc() return 0.0 if func_pred is not None: @@ -157,7 +157,7 @@ Based on the above data, please infer the possible formula. Ensure that your inf metrics['R2'] = r2_score(y_true, y_pred) metrics['NMSE'] = np.mean((y_true - y_pred) ** 2) / np.var(y_true) except Exception as e: - print(f"Exception: {e}") + # print(f"Exception: {e}") try: x0_vals, x1_vals = generate_samples() gt_vals = func_gt(x0_vals, x1_vals) @@ -174,7 +174,8 @@ Based on the above data, please infer the possible formula. Ensure that your inf metrics['R2'] = 1 - np.sum((gt_valid - pred_valid) ** 2) / np.var(gt_valid) metrics['NMSE'] = np.mean((gt_valid - pred_valid) ** 2) / np.var(gt_valid) except Exception as e: - print(e) + # print(e) + pass # 判断方程等价性 metrics['SymbolicMatch'] = is_symbolically_equivalent(infer_formula, gt_formula, var_num) @@ -215,7 +216,7 @@ def _send_request(messages, mllm='gpt-4o'): content = response.json()['choices'][0]['message']['content'] break except Exception as e: - print(f"Error: {e}, {response.json()}") + # print(f"Error: {e}, {response.json()}") pass return content @@ -299,7 +300,7 @@ def parse_formula(formula_str: str): expr_str = formula_str.strip() if not expr_str: - print(f"[Parse Error] 公式字符串为空或剥离后为空: '{formula_str}'") + # print(f"[Parse Error] 公式字符串为空或剥离后为空: '{formula_str}'") return None local_dict = {"sin": sp.sin, "cos": sp.cos, "exp": sp.exp, "sqrt": sp.sqrt, "log": sp.log, @@ -316,12 +317,12 @@ def parse_formula(formula_str: str): func = sp.lambdify(symbols, expr, modules=numpy_modules) return func, variable_names except (SyntaxError, TypeError, AttributeError, sp.SympifyError) as e: - print(f'[Parse Error] 无法解析公式 "{formula_str}": {e}') + # print(f'[Parse Error] 无法解析公式 "{formula_str}": {e}') # import traceback # traceback.print_exc() return None except Exception as e: - print(f'[Parse Error] 解析公式 "{formula_str}" 时发生意外错误: {e}') + # print(f'[Parse Error] 解析公式 "{formula_str}" 时发生意外错误: {e}') return None diff --git a/internbootcamp/libs/chemStructure2Property/ChemStructureGenerator.py b/internbootcamp/libs/chemStructure2Property/ChemStructureGenerator.py index bfe23cb..de91444 100755 --- a/internbootcamp/libs/chemStructure2Property/ChemStructureGenerator.py +++ b/internbootcamp/libs/chemStructure2Property/ChemStructureGenerator.py @@ -244,7 +244,7 @@ class SMILESGenerator: valid_smiles_set = set() total_attempts_overall = 0 - print(f"Attempting to generate {n} valid SMILES (min_len={self.min_len}, max_len={self.max_len})...") + # print(f"Attempting to generate {n} valid SMILES (min_len={self.min_len}, max_len={self.max_len})...") while len(valid_smiles_set) < n: attempts_for_current_smiles = 0 generated_this_round = False diff --git a/setup.py b/setup.py index 497d81e..a37d3cd 100755 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setuptools.setup( "langdetect", "pympler", "shortuuid", - "rdkit" + "rdkit==2024.3.2" ], package_data={