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

Python 3.13.0 support for spare scores package #29

Closed
wants to merge 12 commits into from
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macos tests python=3.8
name: macos tests python=3.9

# workflow dispatch has been added for testing purposes
on: [push, pull_request, workflow_dispatch]
Expand All @@ -11,12 +11,12 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- name: Set-up miniconda for macos and ubuntu
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.8
python-version: 3.9
miniconda-version: "latest"
- name: Create conda env
run: conda create -n spare python=3.8
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: pre-commit
on:
pull_request:
push:
branches: [main, fixing_issues]
branches: [main, spiros-dev]

jobs:
pre-commit:
Expand All @@ -13,5 +13,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip3 install pre-commit
- run: pre-commit run --files spare_scores/*
- name: install pre commit
run: pip install pre-commit && pre-commit install
- name: pre-commit
uses: pre-commit/[email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ubuntu build python=3.8
name: ubuntu build python=3.9

# workflow dispatch has been added for testing purposes
on: [push, pull_request, workflow_dispatch]
Expand All @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- name: Install spare scores
run: |
python -m pip cache purge
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![codecov](https://codecov.io/gh/CBICA/spare_score/graph/badge.svg?token=7yk7pkydHE)](https://codecov.io/gh/CBICA/spare_score)
![macos tests](https://github.com/CBICA/spare_score/actions/workflows/macos-tests-3.12.yml/badge.svg)
![ubuntu tests](https://github.com/CBICA/spare_score/actions/workflows/ubuntu-tests-3.12.yml/badge.svg)
![PyPI Stable](https://img.shields.io/pypi/v/spare_scores)

# Compute SPARE Scores for Your Case

Expand Down
97 changes: 0 additions & 97 deletions merge_ROI_demo_and_test.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"pandas",
"setuptools",
"scikit-learn",
"torch<=2.3.1",
"torch<=2.5.1",
"matplotlib",
"optuna",
],
Expand Down
12 changes: 6 additions & 6 deletions spare_scores/data_prep.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import random
from typing import Any, Tuple, Union
from typing import Any, Optional, Tuple, Union

import numpy as np
import pandas as pd
Expand All @@ -16,7 +16,7 @@ def check_train(
to_predict: str,
verbose: int = 1, # this needs to be removed(non used)
pos_group: str = "",
) -> Union[str, Tuple[pd.DataFrame, list, str]]:
) -> Union[Tuple[pd.DataFrame, list, str], str]:
"""
Checks training dataframe for errors.

Expand Down Expand Up @@ -71,7 +71,7 @@ def check_train(
logging.error("At least one of the groups to classify is too small (n<10).")
return "At least one of the groups to classify is too small (n<10)."
elif np.min(df[to_predict].value_counts()) < 100:
logging.warn(
logging.warning(
"At least one of the groups to classify may be too small (n<100)."
)
mdl_task = "Classification"
Expand All @@ -84,7 +84,7 @@ def check_train(
logging.error("Sample size is too small (n<10).")
return "Sample size is too small (n<10)."
elif len(df.index) < 100:
logging.warn("Sample size may be too small (n<100).")
logging.warning("Sample size may be too small (n<100).")
if pos_group != "":
logging.info(
'SPARE regression does not need a "pos_group". This will be ignored.'
Expand Down Expand Up @@ -126,7 +126,7 @@ def check_test(
# logging.warn('Some participants fall outside the age range of the SPARE model.')

if np.sum(np.sum(pd.isna(df[meta_data["predictors"]]))) > 0:
logging.warn(
logging.warning(
"Some participants have invalid (missing or NaN values) predictor variables."
)

Expand Down Expand Up @@ -221,7 +221,7 @@ def smart_unique(
def age_sex_match(
df1: pd.DataFrame,
df2: Union[pd.DataFrame, None] = None,
to_match: str = "",
to_match: Optional[str] = "",
p_threshold: float = 0.15,
verbose: int = 1,
age_out_percentage: float = 20,
Expand Down
4 changes: 1 addition & 3 deletions spare_scores/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ def get_stats(self, y: np.ndarray, y_hat: np.ndarray) -> None:
self.stats["F1"].append(2 * precision * recall / (precision + recall))
else:
self.stats["MAE"].append(metrics.mean_absolute_error(y, y_hat))
self.stats["RMSE"].append(
metrics.mean_squared_error(y, y_hat, squared=False)
)
self.stats["RMSE"].append(metrics.root_mean_squared_error(y, y_hat))
self.stats["R2"].append(metrics.r2_score(y, y_hat))

def output_stats(self) -> None:
Expand Down
4 changes: 1 addition & 3 deletions spare_scores/svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,7 @@ def get_stats(self, y_test: np.ndarray, y_score: np.ndarray) -> None:
self.stats["F1"].append(2 * precision * recall / (precision + recall))
else:
self.stats["MAE"].append(metrics.mean_absolute_error(y_test, y_score))
self.stats["RMSE"].append(
metrics.mean_squared_error(y_test, y_score, squared=False)
)
self.stats["RMSE"].append(metrics.root_mean_squared_error(y_test, y_score))
self.stats["R2"].append(metrics.r2_score(y_test, y_score))
logging.debug(
" > "
Expand Down
4 changes: 2 additions & 2 deletions spare_scores/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
import pickle
from typing import Any, Union
from typing import Any, Optional, Union

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -43,7 +43,7 @@ def add_file_extension(filename: str, extension: str) -> str:
return filename


def check_file_exists(filename: str, logger: Any) -> Any:
def check_file_exists(filename: Optional[str], logger: Any) -> Any:
"""
Checks if file exists

Expand Down
25 changes: 0 additions & 25 deletions tests/conftest.py

This file was deleted.

Loading
Loading