Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alenrajsp/niaaml-api
Api for remote work with NiaAML
https://github.com/alenrajsp/niaaml-api
Last synced: 9 days ago
JSON representation
Api for remote work with NiaAML
- Host: GitHub
- URL: https://github.com/alenrajsp/niaaml-api
- Owner: alenrajsp
- License: mit
- Created: 2021-09-12T21:07:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T10:32:08.000Z (3 months ago)
- Last Synced: 2024-08-06T12:24:45.831Z (3 months ago)
- Language: Python
- Size: 919 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NiaAML API
![GitHub license](https://img.shields.io/github/license/alenrajsp/NiaAML-API)
NiaAML API is a Python library for using [NiaAML](https://github.com/lukapecnik/NiaAML) as an FastAPI based web API.
The currently used version of **NiaAML** is **2.1.0**.## Installation
1. Download project
2. Install dependencies with Poetry
```bash
poetry install
```
3. Navigate to project folder and run server in terminal.
* ```bash uvicorn main:app --reload```
or
* run the ```main.py``` script of the project## How to use (locally)
1. Run server
2. Navigate to [Swagger docs](localhost:8000/docs) to see how to use.## How to use (Docker)
1. Use the official image from DockerHub repository
(alenrajsp/niaamlapi:0.2)[https://hub.docker.com/r/alenrajsp/niaamlapi]2. Run from terminal with
`docker run -p :80 alenrajsp/niaamlapi:main`.
The **\** variable is the port from which you want to access the container.
3. If data is to be preserved the **/src/data** folder needs to be made into a volume.
The **data** folder contains the following subfolders and files:| Folder / file | Description |
| ----------- | ----------- |
| /csvfiles | Folder where all uploaded csv files are saved. |
| /pipelineResults | Folder where **.ppln** and **.txt** files of results are saved |
| jobs.db | SQLite3 database where all executed and current jobs are saved. |
| jobs.db | SQLite3 database where all job queues are saved. |### Workflow
#### CSV upload
Only CSV type pipelines from NiaAML are currently supported. To create a remote job call the [/pipeline/uploadCsv](http://localhost:8000/docs) method.
Upload a csv file (with last column of the CSV file as a class). The method returns a **uuid** which is needed in the next step.
### Running the pipeline
To run the pipeline you need to call the [/pipeline/run](http://localhost:8000/docs) method.
The **data_id** parameter represents the **uuid** returned from the CSV upload method.To execute the [example](https://github.com/lukapecnik/NiaAML#example-of-usage) shown in NiaAML documentation the following request is needed.
```
POST http://localhost:8000/pipeline/run?data_id=50e7e53e-f85c-4361-b52a-a31422719743
REQUEST BODY: {
"web_pipeline_optimizer": {
"classifiers": [
"AdaBoost"
],
"feature_selection_algorithms": [
"SelectKBest"
],
"feature_transform_algorithms": [
"Normalizer"
],
"categorical_features_encoder": "OneHotEncoder",
"imputer": "SimpleImputer",
"log": false,
"log_verbose": false,
"log_output_file": ""
},
"web_pipeline_optimizer_run": {
"fitness_name": "Accuracy",
"pipeline_population_size": 5,
"inner_population_size": 5,
"number_of_pipeline_evaluations": 5,
"number_of_inner_evaluations": 5,
"optimization_algorithm": "ParticleSwarmAlgorithm",
"inner_optimization_algorithm": "ParticleSwarmAlgorithm"
}
}
```The returned response should look something like:
``` JSON
{
"file_id": "2e4b64b1-e192-4f24-b5c7-045bb51aee67",
"result": "Added to queue!",
"export": "85486cf6-f760-4556-9f73-460c1aa0b80d"
}
```
Where the **export** attribute is the input parameter for the *data_id* of */pipeline/export* methods, since more than one pipeline can be created from a CSV file.### Retrieving the results
Once jobs are completed the **.ppln** and **.txt** files can be retrieved using the following two requests:
**.txt result files** - *note data_id = **export** value of **/pipeline/run** method.
```
POST http://localhost:8000/pipeline/export/text?data_id=50e7e53e-f85c-4361-b52a-a31422719743
```**.ppln result files**
```
POST http://localhost:8000/pipeline/export/ppln?data_id=50e7e53e-f85c-4361-b52a-a31422719743
```## Tests
All of the endpoints have functional tests available for them in the **tests** directory. You can also check the tests to better understand how to make requests with the client.## License
[MIT](https://choosealicense.com/licenses/mit/)