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

Replace pandas append with concat #231

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions ms2query/create_new_library/train_ms2query_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def get_matches_info_and_tanimoto(self,
validation_query_spectra:
List of Spectrum objects
"""
all_tanimoto_scores = pd.DataFrame()
info_of_matches_with_tanimoto = pd.DataFrame()
all_tanimoto_scores_list = []
info_of_matches_with_tanimoto_list = []
for query_spectrum in tqdm(query_spectra,
desc="Get scores and tanimoto scores"):
results_table = self.ms2library.calculate_features_single_spectrum(query_spectrum,
Expand All @@ -67,18 +67,17 @@ def get_matches_info_and_tanimoto(self,
tanimoto_scores = calculate_tanimoto_scores_with_library(self.ms2library.sqlite_library, query_spectrum,
library_spectrum_ids)
# Add tanimoto scores for training data
all_tanimoto_scores = \
all_tanimoto_scores.append(tanimoto_scores,
ignore_index=True)
all_tanimoto_scores_list.append(tanimoto_scores)
# Select the features (remove inchikey, since this should not be
# used for training
features_dataframe = results_table.get_training_data()
# Add matches for which a tanimoto score could be calculated
matches_with_tanimoto = features_dataframe.loc[
tanimoto_scores.index]
info_of_matches_with_tanimoto = \
info_of_matches_with_tanimoto.append(matches_with_tanimoto,
ignore_index=True)
info_of_matches_with_tanimoto_list.append(matches_with_tanimoto)

all_tanimoto_scores = pd.concat(all_tanimoto_scores_list, ignore_index = True)
info_of_matches_with_tanimoto = pd.concat(info_of_matches_with_tanimoto_list, ignore_index = True)
return info_of_matches_with_tanimoto, all_tanimoto_scores


Expand Down
Loading