cpsplines


Namecpsplines JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/ManuelNavarroGarcia/cpsplines/
SummaryConstrained P-splines
upload_time2024-01-24 09:20:55
maintainer
docs_urlNone
authorManuel Navarro García
requires_python>=3.9
licenseMIT
keywords p-splines mosek python 3.9 constraints optimization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cpsplines

`cpsplines` is a Python module to perform constrained regression under shape
constraints on the component functions of the dependent variable. It is assumed
that the smooth hypersurface to be estimated is defined through a reduced-rank
basis (B−splines) and fitted via a penalized splines approach (P−splines). To
embed requirements about the sign of any order partial derivative (including the
function itself), the constraints are included into the fitting procedure as
hard constraints, yielding a semidefinite optimization model. In particular, the
problem of estimating the component function using this approach is stated as a
convex conic optimization problem with a quadratic objective function.

Sign related constraints are imposed using a well-known result carried out by
Bertsimas and Popescu, 2002. This enables to enforce non-negativity of a
univariate polynomial over a finite interval, which can be straightforwardly
extended to the sign of any higher order derivative. When only one covariate is
related to the response variable, these constraints are successfully fulfilled
over the whole domain of the regressor sample. However, when dealing with
multiple regression, this equivalence does not hold, so alternative approaches
must be developed. The proposed framework in this repository uses the
equivalence relation for univariate polynomials by imposing the constraints over
a finite set of curves which belong to the hypersurface.

At present, `cpsplines` can handle constrained regression problems for an
arbitrary number of variables, where all the interaction term are considered. In
this setting, the smooth hypersurface is constructed from the tensor products of
B-splines basis along each axis. When data is arranged in a grid, efficient
algorithms accelerating the computations are used (Currie, Durban and  Eilers,
2006). On this repository, the fitting procedure is performed using the method
`CPsplines`, whose main features are the following:

* Arbitrary number of variables.
* Arbitrary knot sequence length to construct the B-spline basis.
* Arbitrary B-spline basis degrees.
* Arbitrary difference orders on the penalty term.
* Out-of-range prediction (backwards and forward) along every dimension (Currie
  and Durban, 2004), and the constraints are enforced both on the fitting and
  the prediction region.
* The smoothing parameters are selected as the minimizer of the Generalized
  Cross Validation criteria, but this routine can be done either by choosing the
  best parameters out of a set of candidates or by finding them using numerical
  methods.
* Enforcing sign related constraints over the fitting and prediction range (if
  prediction is required). Arbitrary number of sign constraints can be imposed
  along each regressor.
* Enforcing the hypersurface (or any partial derivative) attains a certain value
  at a certain point.
* Enforcing the hypersurface is a probability density function, i.e., it is
  non-negative and it integrates to one.  
* Choose among several distributions from the exponential family, currently
  implemented for Gaussian, Poisson and Binomial. For the last two distribution,
  only sign and monotonocity constraints can be enforced.
* Internally decides whether the input data can be rearranged into a grid or
  not, and exploits the array structure of the data when this is the case.

Solving the optimization problems is done using [MOSEK](https://www.mosek.com)
optimization software.

## Project structure

The current version of the project is structured as follows:

* **cpsplines**: the main directory of the project, which consist of:
  * **fittings**: contains the smoothing algorithms.
  * **graphics**: constituted by graphic methods to visualize the results.
  * **mosek_functions**: contains the functions used to define the optimization
    problems.
  * **psplines**: composed by several methods that build the main objects of
    P-splines.
  * **utils**: integrated by a miscellanea of files used for a variety of
    purposes (numerical computations, data processing, ...).
* **data**: a folder containing CSV files used in the real data numerical
  experiments.
* **examples**: a directory containing multiple numerical experiments, using
  both synthetic and real data sets.
* **img**: contains some images used in this `README.md` file.
* **tests**: a folder including tests for the main methods of the project.

## Package dependencies

`cpsplines` mainly depends on the following packages:

* [Joblib](https://joblib.readthedocs.io/).
* [Matplotlib](https://matplotlib.org/).
* [MOSEK](https://www.mosek.com). **License Required**
* [Numpy](https://numpy.org/).
* [Pandas](https://pandas.pydata.org/).
* [Scipy](https://www.scipy.org/).
* [Tensorly](http://tensorly.org/).
* [Statsmodels](https://www.statsmodels.org/).

MOSEK requires a license to be used. For research or educational purposes, a
free yearly and renewable [academic
license](https://www.mosek.com/products/academic-licenses/) is offered by the
company. For other cases, a 30-day [trial license](https://www.mosek.com/try/)
is available. According to MOSEK indications, the license file (`mosek.lic`)
must be located at

```{bash}
$HOME/mosek/mosek.lic                (Linux/OSX)
%USERPROFILE%\mosek\mosek.lic        (Windows)
```

## Installation

1. To clone the repository on your own device, use

```{bash}
git clone https://github.com/ManuelNavarroGarcia/cpsplines.git
cd cpsplines
```

2. To install the dependencies, there are two options according to your
   installation preferences:

* Create and activate a virtual environment with `conda` (recommended)

```{bash}
conda env create -f env.yml
conda activate cpsplines
```

* Install the setuptools dependencies via `pip`

```{bash}
pip install -r requirements.txt
pip install -e .[dev]
```

3. If neccessary, add version requirements to existing dependencies or add new
   ones on `setup.py`. Then, update `requirements.txt` file using

```{bash}
pip-compile --extra dev > requirements.txt
```

and update the environment with `pip-sync`. Afterwards, the command

```{bash}
pip install -e .[dev]
```

needs to be executed.

## Usage

To illustrate the usage of the repository, let's see how `CPsplines` works with
two examples, the first with only one regressor and the  second two covariates.

For the univariate case, consider the function

$$f(x) = (2x-1)^3,$$

which is a non-decreasing function. We simulated noisy data following the scheme

$$y_l= f(x_l)+\varepsilon_l, \quad \varepsilon_l\sim \text{N}(0,0.25), \quad x_l=0, 0.02, 0.04,\ldots, 1.$$

We fit an unconstrained and a constrained model imposing non-decreasing
constraints over the interval $[-0.15, 1.12]$ (forward and backwards prediction).
For the basis, cubic B-splines with $10$ interior knots are taken with a
second-order difference penalty. The smoothing parameter is selected using
`scipy.optimize.minimize` with the `"SLSQP"` method.

```python
# Generate the data 
np.random.seed(6)
x = np.linspace(0, 1, 51)
y = (2 * x - 1) ** 3 + np.random.normal(0, 0.25, 51)
data = pd.DataFrame({"x": x, "y": y})
# Build and fit the two models: unconstrained and non-decreasing 
# The constraints follows the syntax 
# {variable index : {derivative order: {constraint sign: upper or lower bound}}}
example1D_1 = CPsplines(
    deg=(3,),
    ord_d=(2,),
    n_int=(10,),
    x_range={"x": (-0.15, 1.12)}, # variable index : range
    sp_method="optimizer",
    sp_args={"options": {"ftol": 1e-12}},
)
example1D_1.fit(data=data, y_col="y")

example1D_2 = CPsplines(
    deg=(3,),
    ord_d=(2,),
    n_int=(10,),
    x_range={"x": (-0.15, 1.12)},
    sp_method="optimizer",
    sp_args={"options": {"ftol": 1e-12}},
    int_constraints={"x": {1: {"+": 0}}} 
)
example1D_2.fit(data=data, y_col="y")
# Plot the results
# Dashed vertical lines are the limits of the fitting region and grey vertical lines corresponds to the position of the knots
ax = plt.gca()
for estimator, c in zip((example1D_1, example1D_2), ("g", "k")):
    _ = CurvesDisplay.from_estimator(estimator,
                                     X=data["x"],
                                     y=data["y"],
                                     knot_positions=True, 
                                     constant_constraints=True,
                                     col_pt="b",
                                     ax=ax,
                                     **{"c": c}
                                     )

legend = ax.legend(('Unconstrained model','Non-decreasing model'), loc=8, prop={'size': 20})
legend.legendHandles[0].set_color('g')
legend.legendHandles[1].set_color('k')
```

![alt text](./img/example1D.jpg)

For the bivariate case, consider the function
$$f(x, y) = \sin(x)\sin(y).$$

We simulated noisy data following the scheme
$$z_{lm} = f(x_l, y_m) + \varepsilon_{lm}, \quad \varepsilon_{lm} \sim \text{N}(0, 1),$$
with $300$ equidistant points in $[0, 3\pi]$ in the x-axis and $200$ in $[0, 2\pi]$ in
the y-axis. We fit an unconstrained and a constrained model imposing non-negativity
constraints over the interval $[0, 3\pi] \times [0, 2\pi]$ (i.e. no prediction). For the
bases, cubic B-splines with $30$ and $20$ interior knots are taken, respectively, with a
second-order difference penalty. The smoothing parameter is selected as the best
candidates out of the sets $\{10, 100\}$ (for the first smoothing parameter) and $\{10,
50, 100\}$ (for the second smoothing parameter).

```python
# Generate the data 
np.random.seed(5)
x = np.linspace(0, 3 * np.pi, 301)
y = np.linspace(0, 2 * np.pi, 201)
z = np.outer(np.sin(x), np.sin(y)) + np.random.normal(0, 1, (301, 201))
data = grid_to_scatter(x=[x, y], y=z, y_col="z")
# Build and fit the non-negativity constrained model
example2D = CPsplines(
    deg=(3, 3),
    ord_d=(2, 2),
    n_int=(30, 20),
    sp_method="grid_search",
    sp_args={"grid": [(10, 100), (10, 50, 100)]},
    int_constraints={"x0": {0: {"+": 0}}, "x1": {0: {"+": 0}}}
)
example2D.fit(data=data, y_col="z")
#Plot the results
_ = SurfacesDisplay.from_estimator(example2D, 
                                   orientation=(45,45), 
                                   figsize=(10, 6), 
                                   **{"cmap": "gist_earth"}
                                   )
```

![alt text](./img/example2D.jpg)

## Testing

The repository contains a folder with unit tests to guarantee the main methods
meets their design and behave as intended. To launch the test suite, it is
enough to enter `pytest`. If only one test file wants to be run, the syntax is
given by

```{bash}
pytest tests/test_<file_name>.py
```

Moreover, a GitHub Action runs automatically all the tests but
`tests/test_solution.py` (which requires MOSEK license) when any commit is
pushed on any Pull Request.

## Contributing

Contributions to the repository are welcomed! Regardless of whether it is a
small fix on the documentation or a notable feature to be included, I encourage
you to develop your ideas and make this project greater. Even suggestions about
the code structure are highly appreciated. Furthermore, users participating on
these submissions will figure as contributors on this main page of the
repository.

There are many ways you can contribute on this repository:

* [Discussions](https://github.com/ManuelNavarroGarcia/cpsplines/discussions).
  To ask questions you are wondering about or share ideas, you can enter an
  existing discussion or open a new one.

* [Issues](https://github.com/ManuelNavarroGarcia/cpsplines/issues). If you
  detect a bug or you want to propose an enhancement of the current version of
  the code, a issue with reproducible code and/or a detailed description is
  highly appreciated.

* [Pull Requests](https://github.com/ManuelNavarroGarcia/cpsplines/pulls). If
  you feel I am missing an important feature, either in the code or in the
  documentation, I encourage you to start a pull request developing this idea.
  Nevertheless, before starting any major new feature work, I suggest you to
  open an issue or start a discussion describing what you are planning to do.
  Recall that, before starting a pull request, all unit test must pass on your
  local repository.

## Contact Information and Citation

If you have encountered any problem or doubt while using `cpsplines`, please
feel free to let me know by sending me an email:

* Name: Manuel Navarro García (he/his)
* Email: <manuelnavarrogithub@gmail.com>

The formal background of the models used in this project are either published in
research papers or under current research. If these techniques are helpful to
your own research, consider citing the related papers of the project and/or this
repository:

```{bash}
@article{NAVARROGARCIA2023,
title = {On constrained smoothing and out-of-range prediction using P-splines: A conic optimization approach},
journal = {Applied Mathematics and Computation},
volume = {441},
pages = {127679},
year = {2023},
issn = {0096-3003},
doi = {https://doi.org/10.1016/j.amc.2022.127679},
url = {https://www.sciencedirect.com/science/article/pii/S0096300322007470},
author = {Manuel Navarro-García and Vanesa Guerrero and María Durban},
keywords = {Data science, Penalized splines, Conic optimization, Smoothing, Prediction},
}
```

```{bash}
@article{NAVARROGARCIA2023_2,
title = {On mathematical optimization for shape-constrained non-parametric multiple regression using P−splines},
year = {2023},
url = {https://www.researchgate.net/publication/370492139},
author = {Navarro-García, Manuel and Guerrero, Vanesa and Durbán, María},
keywords = {Shape-constrained regression, Penalized splines, Conic optimization},
}
```

## Acknowledgements

Throughout the developing of this project I have received strong support from
various individuals.  

I would first like to thank my PhD supervisors, Professor [Vanesa
Guerrero](https://github.com/vanesaguerrero) and Professor [María
Durbán](https://github.com/MariaDurban), whose insightful comments and
invaluable expertise has given way to many of the current functionalities of the
repository.

I would also like to acknowledge the [Komorebi AI](https://komorebi.ai/) team
for their assistance and guidance on the technical part of the project.
Specially, I would like to thank [Alberto Torres](https://github.com/albertotb),
[David Gordo](https://github.com/davidggphy) and [Victor
Gallego](https://github.com/vicgalle) for their constructive code structure suggestions
that have helped notably to improve the computational efficiency and the usage
of the algorithms.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ManuelNavarroGarcia/cpsplines/",
    "name": "cpsplines",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "P-splines,MOSEK,Python 3.9,Constraints,Optimization",
    "author": "Manuel Navarro Garc\u00eda",
    "author_email": "manuelnavarrogithub@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/92/25/0145f369311df4f2df4cebe1f7dcd400f8112568ae87b11f043d4c5b6b1a/cpsplines-0.2.3.tar.gz",
    "platform": null,
    "description": "# cpsplines\n\n`cpsplines` is a Python module to perform constrained regression under shape\nconstraints on the component functions of the dependent variable. It is assumed\nthat the smooth hypersurface to be estimated is defined through a reduced-rank\nbasis (B\u2212splines) and fitted via a penalized splines approach (P\u2212splines). To\nembed requirements about the sign of any order partial derivative (including the\nfunction itself), the constraints are included into the fitting procedure as\nhard constraints, yielding a semidefinite optimization model. In particular, the\nproblem of estimating the component function using this approach is stated as a\nconvex conic optimization problem with a quadratic objective function.\n\nSign related constraints are imposed using a well-known result carried out by\nBertsimas and Popescu, 2002. This enables to enforce non-negativity of a\nunivariate polynomial over a finite interval, which can be straightforwardly\nextended to the sign of any higher order derivative. When only one covariate is\nrelated to the response variable, these constraints are successfully fulfilled\nover the whole domain of the regressor sample. However, when dealing with\nmultiple regression, this equivalence does not hold, so alternative approaches\nmust be developed. The proposed framework in this repository uses the\nequivalence relation for univariate polynomials by imposing the constraints over\na finite set of curves which belong to the hypersurface.\n\nAt present, `cpsplines` can handle constrained regression problems for an\narbitrary number of variables, where all the interaction term are considered. In\nthis setting, the smooth hypersurface is constructed from the tensor products of\nB-splines basis along each axis. When data is arranged in a grid, efficient\nalgorithms accelerating the computations are used (Currie, Durban and  Eilers,\n2006). On this repository, the fitting procedure is performed using the method\n`CPsplines`, whose main features are the following:\n\n* Arbitrary number of variables.\n* Arbitrary knot sequence length to construct the B-spline basis.\n* Arbitrary B-spline basis degrees.\n* Arbitrary difference orders on the penalty term.\n* Out-of-range prediction (backwards and forward) along every dimension (Currie\n  and Durban, 2004), and the constraints are enforced both on the fitting and\n  the prediction region.\n* The smoothing parameters are selected as the minimizer of the Generalized\n  Cross Validation criteria, but this routine can be done either by choosing the\n  best parameters out of a set of candidates or by finding them using numerical\n  methods.\n* Enforcing sign related constraints over the fitting and prediction range (if\n  prediction is required). Arbitrary number of sign constraints can be imposed\n  along each regressor.\n* Enforcing the hypersurface (or any partial derivative) attains a certain value\n  at a certain point.\n* Enforcing the hypersurface is a probability density function, i.e., it is\n  non-negative and it integrates to one.  \n* Choose among several distributions from the exponential family, currently\n  implemented for Gaussian, Poisson and Binomial. For the last two distribution,\n  only sign and monotonocity constraints can be enforced.\n* Internally decides whether the input data can be rearranged into a grid or\n  not, and exploits the array structure of the data when this is the case.\n\nSolving the optimization problems is done using [MOSEK](https://www.mosek.com)\noptimization software.\n\n## Project structure\n\nThe current version of the project is structured as follows:\n\n* **cpsplines**: the main directory of the project, which consist of:\n  * **fittings**: contains the smoothing algorithms.\n  * **graphics**: constituted by graphic methods to visualize the results.\n  * **mosek_functions**: contains the functions used to define the optimization\n    problems.\n  * **psplines**: composed by several methods that build the main objects of\n    P-splines.\n  * **utils**: integrated by a miscellanea of files used for a variety of\n    purposes (numerical computations, data processing, ...).\n* **data**: a folder containing CSV files used in the real data numerical\n  experiments.\n* **examples**: a directory containing multiple numerical experiments, using\n  both synthetic and real data sets.\n* **img**: contains some images used in this `README.md` file.\n* **tests**: a folder including tests for the main methods of the project.\n\n## Package dependencies\n\n`cpsplines` mainly depends on the following packages:\n\n* [Joblib](https://joblib.readthedocs.io/).\n* [Matplotlib](https://matplotlib.org/).\n* [MOSEK](https://www.mosek.com). **License Required**\n* [Numpy](https://numpy.org/).\n* [Pandas](https://pandas.pydata.org/).\n* [Scipy](https://www.scipy.org/).\n* [Tensorly](http://tensorly.org/).\n* [Statsmodels](https://www.statsmodels.org/).\n\nMOSEK requires a license to be used. For research or educational purposes, a\nfree yearly and renewable [academic\nlicense](https://www.mosek.com/products/academic-licenses/) is offered by the\ncompany. For other cases, a 30-day [trial license](https://www.mosek.com/try/)\nis available. According to MOSEK indications, the license file (`mosek.lic`)\nmust be located at\n\n```{bash}\n$HOME/mosek/mosek.lic                (Linux/OSX)\n%USERPROFILE%\\mosek\\mosek.lic        (Windows)\n```\n\n## Installation\n\n1. To clone the repository on your own device, use\n\n```{bash}\ngit clone https://github.com/ManuelNavarroGarcia/cpsplines.git\ncd cpsplines\n```\n\n2. To install the dependencies, there are two options according to your\n   installation preferences:\n\n* Create and activate a virtual environment with `conda` (recommended)\n\n```{bash}\nconda env create -f env.yml\nconda activate cpsplines\n```\n\n* Install the setuptools dependencies via `pip`\n\n```{bash}\npip install -r requirements.txt\npip install -e .[dev]\n```\n\n3. If neccessary, add version requirements to existing dependencies or add new\n   ones on `setup.py`. Then, update `requirements.txt` file using\n\n```{bash}\npip-compile --extra dev > requirements.txt\n```\n\nand update the environment with `pip-sync`. Afterwards, the command\n\n```{bash}\npip install -e .[dev]\n```\n\nneeds to be executed.\n\n## Usage\n\nTo illustrate the usage of the repository, let's see how `CPsplines` works with\ntwo examples, the first with only one regressor and the  second two covariates.\n\nFor the univariate case, consider the function\n\n$$f(x) = (2x-1)^3,$$\n\nwhich is a non-decreasing function. We simulated noisy data following the scheme\n\n$$y_l= f(x_l)+\\varepsilon_l, \\quad \\varepsilon_l\\sim \\text{N}(0,0.25), \\quad x_l=0, 0.02, 0.04,\\ldots, 1.$$\n\nWe fit an unconstrained and a constrained model imposing non-decreasing\nconstraints over the interval $[-0.15, 1.12]$ (forward and backwards prediction).\nFor the basis, cubic B-splines with $10$ interior knots are taken with a\nsecond-order difference penalty. The smoothing parameter is selected using\n`scipy.optimize.minimize` with the `\"SLSQP\"` method.\n\n```python\n# Generate the data \nnp.random.seed(6)\nx = np.linspace(0, 1, 51)\ny = (2 * x - 1) ** 3 + np.random.normal(0, 0.25, 51)\ndata = pd.DataFrame({\"x\": x, \"y\": y})\n# Build and fit the two models: unconstrained and non-decreasing \n# The constraints follows the syntax \n# {variable index : {derivative order: {constraint sign: upper or lower bound}}}\nexample1D_1 = CPsplines(\n    deg=(3,),\n    ord_d=(2,),\n    n_int=(10,),\n    x_range={\"x\": (-0.15, 1.12)}, # variable index : range\n    sp_method=\"optimizer\",\n    sp_args={\"options\": {\"ftol\": 1e-12}},\n)\nexample1D_1.fit(data=data, y_col=\"y\")\n\nexample1D_2 = CPsplines(\n    deg=(3,),\n    ord_d=(2,),\n    n_int=(10,),\n    x_range={\"x\": (-0.15, 1.12)},\n    sp_method=\"optimizer\",\n    sp_args={\"options\": {\"ftol\": 1e-12}},\n    int_constraints={\"x\": {1: {\"+\": 0}}} \n)\nexample1D_2.fit(data=data, y_col=\"y\")\n# Plot the results\n# Dashed vertical lines are the limits of the fitting region and grey vertical lines corresponds to the position of the knots\nax = plt.gca()\nfor estimator, c in zip((example1D_1, example1D_2), (\"g\", \"k\")):\n    _ = CurvesDisplay.from_estimator(estimator,\n                                     X=data[\"x\"],\n                                     y=data[\"y\"],\n                                     knot_positions=True, \n                                     constant_constraints=True,\n                                     col_pt=\"b\",\n                                     ax=ax,\n                                     **{\"c\": c}\n                                     )\n\nlegend = ax.legend(('Unconstrained model','Non-decreasing model'), loc=8, prop={'size': 20})\nlegend.legendHandles[0].set_color('g')\nlegend.legendHandles[1].set_color('k')\n```\n\n![alt text](./img/example1D.jpg)\n\nFor the bivariate case, consider the function\n$$f(x, y) = \\sin(x)\\sin(y).$$\n\nWe simulated noisy data following the scheme\n$$z_{lm} = f(x_l, y_m) + \\varepsilon_{lm}, \\quad \\varepsilon_{lm} \\sim \\text{N}(0, 1),$$\nwith $300$ equidistant points in $[0, 3\\pi]$ in the x-axis and $200$ in $[0, 2\\pi]$ in\nthe y-axis. We fit an unconstrained and a constrained model imposing non-negativity\nconstraints over the interval $[0, 3\\pi] \\times [0, 2\\pi]$ (i.e. no prediction). For the\nbases, cubic B-splines with $30$ and $20$ interior knots are taken, respectively, with a\nsecond-order difference penalty. The smoothing parameter is selected as the best\ncandidates out of the sets $\\{10, 100\\}$ (for the first smoothing parameter) and $\\{10,\n50, 100\\}$ (for the second smoothing parameter).\n\n```python\n# Generate the data \nnp.random.seed(5)\nx = np.linspace(0, 3 * np.pi, 301)\ny = np.linspace(0, 2 * np.pi, 201)\nz = np.outer(np.sin(x), np.sin(y)) + np.random.normal(0, 1, (301, 201))\ndata = grid_to_scatter(x=[x, y], y=z, y_col=\"z\")\n# Build and fit the non-negativity constrained model\nexample2D = CPsplines(\n    deg=(3, 3),\n    ord_d=(2, 2),\n    n_int=(30, 20),\n    sp_method=\"grid_search\",\n    sp_args={\"grid\": [(10, 100), (10, 50, 100)]},\n    int_constraints={\"x0\": {0: {\"+\": 0}}, \"x1\": {0: {\"+\": 0}}}\n)\nexample2D.fit(data=data, y_col=\"z\")\n#Plot the results\n_ = SurfacesDisplay.from_estimator(example2D, \n                                   orientation=(45,45), \n                                   figsize=(10, 6), \n                                   **{\"cmap\": \"gist_earth\"}\n                                   )\n```\n\n![alt text](./img/example2D.jpg)\n\n## Testing\n\nThe repository contains a folder with unit tests to guarantee the main methods\nmeets their design and behave as intended. To launch the test suite, it is\nenough to enter `pytest`. If only one test file wants to be run, the syntax is\ngiven by\n\n```{bash}\npytest tests/test_<file_name>.py\n```\n\nMoreover, a GitHub Action runs automatically all the tests but\n`tests/test_solution.py` (which requires MOSEK license) when any commit is\npushed on any Pull Request.\n\n## Contributing\n\nContributions to the repository are welcomed! Regardless of whether it is a\nsmall fix on the documentation or a notable feature to be included, I encourage\nyou to develop your ideas and make this project greater. Even suggestions about\nthe code structure are highly appreciated. Furthermore, users participating on\nthese submissions will figure as contributors on this main page of the\nrepository.\n\nThere are many ways you can contribute on this repository:\n\n* [Discussions](https://github.com/ManuelNavarroGarcia/cpsplines/discussions).\n  To ask questions you are wondering about or share ideas, you can enter an\n  existing discussion or open a new one.\n\n* [Issues](https://github.com/ManuelNavarroGarcia/cpsplines/issues). If you\n  detect a bug or you want to propose an enhancement of the current version of\n  the code, a issue with reproducible code and/or a detailed description is\n  highly appreciated.\n\n* [Pull Requests](https://github.com/ManuelNavarroGarcia/cpsplines/pulls). If\n  you feel I am missing an important feature, either in the code or in the\n  documentation, I encourage you to start a pull request developing this idea.\n  Nevertheless, before starting any major new feature work, I suggest you to\n  open an issue or start a discussion describing what you are planning to do.\n  Recall that, before starting a pull request, all unit test must pass on your\n  local repository.\n\n## Contact Information and Citation\n\nIf you have encountered any problem or doubt while using `cpsplines`, please\nfeel free to let me know by sending me an email:\n\n* Name: Manuel Navarro Garc\u00eda (he/his)\n* Email: <manuelnavarrogithub@gmail.com>\n\nThe formal background of the models used in this project are either published in\nresearch papers or under current research. If these techniques are helpful to\nyour own research, consider citing the related papers of the project and/or this\nrepository:\n\n```{bash}\n@article{NAVARROGARCIA2023,\ntitle = {On constrained smoothing and out-of-range prediction using P-splines: A conic optimization approach},\njournal = {Applied Mathematics and Computation},\nvolume = {441},\npages = {127679},\nyear = {2023},\nissn = {0096-3003},\ndoi = {https://doi.org/10.1016/j.amc.2022.127679},\nurl = {https://www.sciencedirect.com/science/article/pii/S0096300322007470},\nauthor = {Manuel Navarro-Garc\u00eda and Vanesa Guerrero and Mar\u00eda Durban},\nkeywords = {Data science, Penalized splines, Conic optimization, Smoothing, Prediction},\n}\n```\n\n```{bash}\n@article{NAVARROGARCIA2023_2,\ntitle = {On mathematical optimization for shape-constrained non-parametric multiple regression using P\u2212splines},\nyear = {2023},\nurl = {https://www.researchgate.net/publication/370492139},\nauthor = {Navarro-Garc\u00eda, Manuel and Guerrero, Vanesa and Durb\u00e1n, Mar\u00eda},\nkeywords = {Shape-constrained regression, Penalized splines, Conic optimization},\n}\n```\n\n## Acknowledgements\n\nThroughout the developing of this project I have received strong support from\nvarious individuals.  \n\nI would first like to thank my PhD supervisors, Professor [Vanesa\nGuerrero](https://github.com/vanesaguerrero) and Professor [Mar\u00eda\nDurb\u00e1n](https://github.com/MariaDurban), whose insightful comments and\ninvaluable expertise has given way to many of the current functionalities of the\nrepository.\n\nI would also like to acknowledge the [Komorebi AI](https://komorebi.ai/) team\nfor their assistance and guidance on the technical part of the project.\nSpecially, I would like to thank [Alberto Torres](https://github.com/albertotb),\n[David Gordo](https://github.com/davidggphy) and [Victor\nGallego](https://github.com/vicgalle) for their constructive code structure suggestions\nthat have helped notably to improve the computational efficiency and the usage\nof the algorithms.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Constrained P-splines",
    "version": "0.2.3",
    "project_urls": {
        "Download": "https://github.com/ManuelNavarroGarcia/cpsplines/archive/refs/tags/0.2.3.tar.gz",
        "Homepage": "https://github.com/ManuelNavarroGarcia/cpsplines/"
    },
    "split_keywords": [
        "p-splines",
        "mosek",
        "python 3.9",
        "constraints",
        "optimization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "edc4427b36c28fbc180e195d894619d351051bf428612048e17509e99c8c8059",
                "md5": "9e0e7d7cdc73a2fb2ece6cdce4327bf9",
                "sha256": "c01fe1f9857876f9ffaa40879daca68323830c0d9a8eeaf038fba74b0423dddc"
            },
            "downloads": -1,
            "filename": "cpsplines-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e0e7d7cdc73a2fb2ece6cdce4327bf9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 52122,
            "upload_time": "2024-01-24T09:20:48",
            "upload_time_iso_8601": "2024-01-24T09:20:48.907801Z",
            "url": "https://files.pythonhosted.org/packages/ed/c4/427b36c28fbc180e195d894619d351051bf428612048e17509e99c8c8059/cpsplines-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92250145f369311df4f2df4cebe1f7dcd400f8112568ae87b11f043d4c5b6b1a",
                "md5": "90b2199b90ced4cc50edab3434b47e89",
                "sha256": "9c21614a842828616544de77ff8408eec46b38c25cb40813b5606c262f1541df"
            },
            "downloads": -1,
            "filename": "cpsplines-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "90b2199b90ced4cc50edab3434b47e89",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 4848142,
            "upload_time": "2024-01-24T09:20:55",
            "upload_time_iso_8601": "2024-01-24T09:20:55.066543Z",
            "url": "https://files.pythonhosted.org/packages/92/25/0145f369311df4f2df4cebe1f7dcd400f8112568ae87b11f043d4c5b6b1a/cpsplines-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-24 09:20:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ManuelNavarroGarcia",
    "github_project": "cpsplines",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "cpsplines"
}
        
Elapsed time: 0.24548s