Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompositionError: ( is an invalid formula! #1

Open
DrAshish88 opened this issue Jun 14, 2023 · 4 comments
Open

CompositionError: ( is an invalid formula! #1

DrAshish88 opened this issue Jun 14, 2023 · 4 comments

Comments

@DrAshish88
Copy link

Processing Input Data: 92%|█████████▏| 1263/1377 [00:00<00:00, 6946.72it/s]

CompositionError Traceback (most recent call last)
in <cell line: 1>()
1 for f in ['jarvis', 'magpie', 'mat2vec', 'oliynyk', 'onehot','random_200']:
----> 2 X_train_unscaled, y_train, formulae_train, skipped_train = generate_features(df, elem_prop=f, drop_duplicates=False, extend_features=False, sum_feat=True)
3
4 SEED = 42
5 X_train_unscaled, X_test_unscaled, y_train, y_test = train_test_split(X_train_unscaled, y_train, test_size=0.20, random_state=SEED)

4 frames
/usr/local/lib/python3.10/dist-packages/CBFV/composition.py in generate_features(df, elem_prop, drop_duplicates, extend_features, sum_feat, mini)
281 if 'x' in formula:
282 continue
--> 283 l1, l2 = _element_composition_L(formula)
284 formula_mat.append(l1)
285 count_mat.append(l2)

/usr/local/lib/python3.10/dist-packages/CBFV/composition.py in _element_composition_L(formula)
97
98 def _element_composition_L(formula):
---> 99 comp_frac = _element_composition(formula)
100 atoms = list(comp_frac.keys())
101 counts = list(comp_frac.values())

/usr/local/lib/python3.10/dist-packages/CBFV/composition.py in _element_composition(formula)
86
87 def _element_composition(formula):
---> 88 elmap = parse_formula(formula)
89 elamt = {}
90 natoms = 0

/usr/local/lib/python3.10/dist-packages/CBFV/composition.py in parse_formula(formula)
62 expanded_formula = formula.replace(m.group(), expanded_sym)
63 return parse_formula(expanded_formula)
---> 64 sym_dict = get_sym_dict(formula, 1)
65 return sym_dict
66

/usr/local/lib/python3.10/dist-packages/CBFV/composition.py in get_sym_dict(f, factor)
26 f = f.replace(m.group(), "", 1)
27 if f.strip():
---> 28 raise CompositionError(f'{f} is an invalid formula!')
29 return sym_dict
30

CompositionError: ( is an invalid formula!

@DrAshish88
Copy link
Author

Dear Athul, The area is new for me, please help. I have watched your youtube video as well and followed the exact code. The error I am facing is Composition error as shown above. How to rectify the same?

@athulkrishna2015
Copy link
Owner

Dear Athul, The area is new for me, please help. I have watched your youtube video as well and followed the exact code. The error I am facing is Composition error as shown above. How to rectify the same?

Hi I am not the author of Kaaiian /
CBFV. you can ask there for more help

  • By reading the error provided, I think there is something wrong with the chemical formula in the df(data frame) you have provided.
  • I suggest you check the formula column in the df. Check whether bad data is present there?

May I ask which University are you working?

@DrAshish88
Copy link
Author

DrAshish88 commented Jun 14, 2023 via email

@DrAshish88
Copy link
Author

Thanks for help, the error got rectified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants