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

Debugging ML #143

Merged
merged 13 commits into from
Jun 14, 2024
Prev Previous commit
Next Next commit
Fixed #131
ntalluri committed Dec 26, 2023
commit 51e5a7633dd751820fc47b774c477bae40a87c06
6 changes: 4 additions & 2 deletions spras/analysis/ml.py
Original file line number Diff line number Diff line change
@@ -82,9 +82,11 @@ def summarize_networks(file_paths: Iterable[Union[str, PathLike]]) -> pd.DataFra
concated_df = concated_df.fillna(0)
concated_df = concated_df.astype('int64')

# don't do ml post processing if there is an empty dataframe
# don't do ml post processing if there is an empty dataframe or the number of samples is <= 1
if concated_df.empty:
raise ValueError("The summarize network dataFrame is empty.\nEnsure that the output files and configuration parameters are correct and non-empty to produce a non-empty dataframe for ml post processing.")
raise ValueError("ML post-processing cannot proceed because the summarize network dataFrame is empty.\nCheck that the output files and configuration parameters are correct and non-empty to produce a non-empty dataframe for ml post processing.")
ntalluri marked this conversation as resolved.
Show resolved Hide resolved
if min(concated_df.shape) <= 1:
raise ValueError (f"ML post-processing cannot proceed as the available number of samples is insufficient. The process requires more than one sample, but currently, there are only {min(concated_df.shape)} samples.")
ntalluri marked this conversation as resolved.
Show resolved Hide resolved

return concated_df

1 change: 1 addition & 0 deletions test/ml/input/test-data-single/single.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
L M 1 U
agitter marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions test/ml/test_ml.py
Original file line number Diff line number Diff line change
@@ -30,6 +30,10 @@ def test_summarize_networks_empty(self):
with pytest.raises(ValueError): #raises error if empty dataframe is used for post processing
ml.summarize_networks([INPUT_DIR + 'test-data-empty/empty.txt'])
ntalluri marked this conversation as resolved.
Show resolved Hide resolved

def test_summarize_networks_empty(self):
with pytest.raises(ValueError): #raises error if empty dataframe is used for post processing
ml.summarize_networks([INPUT_DIR + 'test-data-single/single.txt'])

def test_pca(self):
dataframe = ml.summarize_networks([INPUT_DIR + 'test-data-s1/s1.txt', INPUT_DIR + 'test-data-s2/s2.txt', INPUT_DIR + 'test-data-s3/s3.txt'])
ml.pca(dataframe, OUT_DIR + 'pca.png', OUT_DIR + 'pca-variance.txt',