|
1 | | -# Vetiver |
| 1 | +# vetiver <a href='https://rstudio.github.io/vetiver-python/'><img src='figures/logo.png' align="right" height="139" /></a> |
2 | 2 |
|
3 | | -The goal of vetiver is to provide fluent tooling to version, share, deploy, and monitor a trained model. Functions handle both recording and checking the model’s input data prototype, and predicting from a remote API endpoint. You can use vetiver with: |
| 3 | +<!-- badges: start --> |
4 | 4 |
|
5 | | -- [scikit-learn](https://scikit-learn.org/stable/) |
6 | | -- [pytorch](https://pytorch.org/) |
7 | | -- [statsmodels](https://www.statsmodels.org/) |
8 | | -- [xgboost](https://xgboost.readthedocs.io/) |
| 5 | +[](https://lifecycle.r-lib.org/articles/stages.html#experimental) [](https://codecov.io/gh/isabelizimm/vetiver-python) |
| 7 | + |
| 8 | +<!-- badges: end --> |
| 9 | + |
| 10 | +_Vetiver, the oil of tranquility, is used as a stabilizing ingredient in perfumery to preserve more volatile fragrances._ |
| 11 | + |
| 12 | +The goal of vetiver is to provide fluent tooling to version, share, deploy, and monitor a trained model. Functions handle both recording and checking the model's input data prototype, and predicting from a remote API endpoint. The vetiver package is extensible, with generics that can support many kinds of models, and available for both Python and R. To learn more about vetiver, see: |
| 13 | + |
| 14 | +- the documentation at <https://vetiver.rstudio.com/> |
| 15 | +- the R package at <https://rstudio.github.io/vetiver-r/> |
| 16 | + |
| 17 | +You can use vetiver with: |
| 18 | + |
| 19 | +- [scikit-learn](https://scikit-learn.org/) |
| 20 | +- [torch](https://pytorch.org/) |
| 21 | +- [statsmodels](https://www.statsmodels.org/stable/index.html) |
| 22 | +- [xgboost](https://xgboost.readthedocs.io/en/stable/) |
| 23 | +- or utilize [custom handlers](https://rstudio.github.io/vetiver-python/stable/advancedusage/custom_handler.html) to support your own models! |
| 24 | + |
| 25 | +## Installation |
| 26 | + |
| 27 | +You can install the released version of vetiver from [PyPI](https://pypi.org/project/vetiver/): |
| 28 | + |
| 29 | +```python |
| 30 | +python -m pip install vetiver |
| 31 | +``` |
| 32 | + |
| 33 | +And the development version from [GitHub](https://github.com/rstudio/vetiver-python) with: |
| 34 | + |
| 35 | +```python |
| 36 | +python -m pip install git+https://github.com/rstudio/vetiver-python |
| 37 | +``` |
| 38 | + |
| 39 | +## Example |
| 40 | + |
| 41 | +A `VetiverModel()` object collects the information needed to store, version, and deploy a trained model. |
| 42 | + |
| 43 | +```python |
| 44 | +from vetiver import mock, VetiverModel |
| 45 | + |
| 46 | +X, y = mock.get_mock_data() |
| 47 | +model = mock.get_mock_model().fit(X, y) |
| 48 | + |
| 49 | +v = VetiverModel(model, model_name='mock_model', prototype_data=X) |
| 50 | +``` |
| 51 | + |
| 52 | +You can **version** and **share** your `VetiverModel()` by choosing a [pins](https://rstudio.github.io/pins-python/) "board" for it, including a local folder, RStudio Connect, Amazon S3, and more. |
| 53 | + |
| 54 | +```python |
| 55 | +from pins import board_temp |
| 56 | +from vetiver import vetiver_pin_write |
| 57 | + |
| 58 | +model_board = board_temp(versioned = True, allow_pickle_read = True) |
| 59 | +vetiver_pin_write(model_board, v) |
| 60 | +``` |
| 61 | + |
| 62 | +You can **deploy** your pinned `VetiverModel()` using `VetiverAPI()`, an extension of [FastAPI](https://fastapi.tiangolo.com/). |
| 63 | + |
| 64 | +```python |
| 65 | +from vetiver import VetiverAPI |
| 66 | +app = VetiverAPI(v, check_prototype = True) |
| 67 | +``` |
| 68 | + |
| 69 | +To start a server using this object, use `app.run(port = 8080)` or your port of choice. |
| 70 | + |
| 71 | +## Contributing |
| 72 | + |
| 73 | +This project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. |
| 74 | + |
| 75 | +- For questions and discussions about deploying models, statistical modeling, and machine learning, please [post on RStudio Community](https://community.rstudio.com/new-topic?category_id=15&tags=vetiver,question). |
| 76 | + |
| 77 | +- If you think you have encountered a bug, please [submit an issue](https://github.com/rstudio/vetiver-python/issues). |
0 commit comments