Skip to content

Add support for the SVCBlock, the SVRBlock and the svm_solver tool - #109

Open
dmeoli wants to merge 11 commits into
SPSUnipi:mainfrom
dmeoli:SVM
Open

Add support for the SVCBlock, the SVRBlock and the svm_solver tool#109
dmeoli wants to merge 11 commits into
SPSUnipi:mainfrom
dmeoli:SVM

Conversation

@dmeoli

@dmeoli dmeoli commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Adds support for the SVCBlock and the SVRBlock of SMS++, i.e. the training problem of a Support Vector Machine, together with the svm_solver tool that trains it and performs the model selection around it.

What is in:

  • SVMSolver, the interface to the svm_solver tool, with the options for the hold-out, the k-fold cross-validation, the grid search over the hyper-parameters and the consensus structure of the problem in chunks. It parses the scores of the model selection and the trained model out of the log
  • the SVCBlock, SVRBlock and SVMBlockSolution component descriptions, so that a data set can be written and a trained model read back
  • the configuration templates in data/configs/SVMBlock, one per solver: the ad hoc SMOSolver, a :MILPSolver on either formulation, a LagrangianDualSolver on the chunks and LIBSVMSolver, which hands the problem over to LIBSVM
  • the Support Vector Machines example, which wraps SMS++ in a scikit-learn estimator and runs the two side by side on the same train/test split, the same folds and the same grid. Since scikit-learn trains its SVM with LIBSVM, and so does SMS++ through LIBSVMSolver, the example also compares them with libsvm-official: the same library called from Python and from C++, and it must give the same model
  • tests for all of the above, skipped when svm_solver is not in the PATH

The splits of the cross-validation are specified down to the bit rather than being left to the shuffle of the standard library, so that a seed gives the same folds in SMS++ and in Python and the two cross-validations are actually comparable.

LIBSVMSolver is in SMS++ only when it has been built with LIBSVM, which is an optional dependency: the run that needs it is skipped otherwise.

@davide-f davide-f left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thanks for the PR, comments added

Comment thread docs/release_notes.md Outdated
Comment on lines 7 to 11
* Add the `Support Vector Machines` example, which runs SMS++ and scikit-learn side by side on the same train/test split, k-fold cross-validation and grid of hyper-parameters

* Add support for the SVCBlock and the SVRBlock, i.e., the training problem of a Support Vector Machine, with the `SVMSolver` tool, the configuration templates of the `SVMBlock` folder and the model selection the tool performs (hold-out, k-fold cross-validation and grid search). The templates include `SVMSCfg-libsvm.txt`, which trains the model with LIBSVM: the example compares it with `libsvm-official` and with scikit-learn, i.e., the same library called from Python.

* Mirror the repository to its GitLab copy, `smspp/pysmspp`, at every push on `main`: SMS++ lives on GitLab and mirrors itself to GitHub, pySMSpp is the one going the other way round.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the link to the PRs, follow the examples shown below

Comment thread pysmspp/smspp_tools.py Outdated
[self._solver_path, self._help_option],
check=False,
shell=self._shell,
capture_output=True, # the help message is not what is asked for here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment

Comment thread test/test_optimize.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revise: it is impossible to compare the differences here

Comment thread pyproject.toml Outdated
Comment on lines +54 to +55
"scikit-learn", # the SVM example compares SMS++ with scikit-learn
"libsvm-official", # ... and with LIBSVM itself, which is what both use

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

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

Successfully merging this pull request may close these issues.

2 participants