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

Upgraded torch to v2, fixed FutureWarning for SVM training #13

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
packages=find_packages(),
package_data={'spare_scores':['mdl/*.pkl.gz','data/*.csv']},
include_package_data=True,
install_requires=['numpy', 'pandas', 'scikit-learn', 'torch==1.11', 'matplotlib', 'optuna'],
install_requires=['numpy',
'pandas',
'scikit-learn',
'torch<2.1',
'matplotlib',
'optuna'],
entry_points={
'console_scripts': ['spare_score=spare_scores.cli:main']
},
Expand Down
4 changes: 2 additions & 2 deletions spare_scores/svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def train_initialize(self, df, to_predict):
if self.task == 'Classification':
self.type, self.scoring, metrics = 'SVC', 'roc_auc', ['AUC', 'Accuracy', 'Sensitivity', 'Specificity', 'Precision', 'Recall', 'F1']
self.to_predict, self.classify = to_predict, list(df[to_predict].unique())
self.mdl = ([LinearSVC(max_iter=100000)] if self.kernel == 'linear' else [SVC(max_iter=100000, kernel=self.kernel)]) * len(self.folds)
self.mdl = ([LinearSVC(max_iter=100000, dual='auto')] if self.kernel == 'linear' else [SVC(max_iter=100000, kernel=self.kernel)]) * len(self.folds)
elif self.task == 'Regression':
self.type, self.scoring, metrics = 'SVR', 'neg_mean_absolute_error', ['MAE', 'RMSE', 'R2']
self.to_predict, self.classify = to_predict, None
self.mdl = [LinearSVR(max_iter=100000)] * len(self.folds)
self.mdl = [LinearSVR(max_iter=100000, dual='auto')] * len(self.folds)
self.bias_correct = {'slope':np.zeros((len(self.folds),)), 'int':np.zeros((len(self.folds),))}
self.stats = {metric: [] for metric in metrics}
logging.info(f'Training a SPARE model ({self.type}) with {len(df.index)} participants')
Expand Down
Loading