##Nuevo! pueden instalar la API como una libreria directamente con "pip install spam-api" desde la terminal
Spam Detection API
Esta es una API simple creada con FastAPI que permite detectar si un mensaje es spam o no spam usando un modelo de machine learning entrenado con Naive Bayes. La API permite cargar nuevos datos de entrenamiento, asà como realizar predicciones sobre mensajes.
Requisitos
- Python 3.7+
- Las siguientes dependencias:
fastapi
uvicorn
pydantic
joblib
scikit-learn
python-multipart
pandas
Instalacion Clona este repositorio o descarga el código fuente.
Crea un entorno virtual (opcional pero recomendado):
python -m venv venv
source venv/bin/activate # En Linux/MacOS
venv\Scripts\activate # En Windows
Instala las dependecias
pip install -r requirements.txt
Ejecutar la API Para correr la API, usa Uvicorn:
uvicorn anti_spam:app --reload
Esto iniciará la API en http://127.0.0.1:8000.
Endpoints
/detect_spam/ (POST) Este endpoint recibe un mensaje de texto y devuelve si es spam o no.
Ejemplo de request:
{
"text": "Congratulations! You have won a free gift card."
}
Ejemplo de respuesta:
{
"is_spam": true
}
/train_model/ (POST) Este endpoint permite agregar nuevos datos de entrenamiento (texto y etiqueta) al modelo.
Ejemplo de request: (hay que asegurarse de que cada dato de entrenamiento tenga el texto y la etiqueta correspondiendte. 1 = SPAM, 0 = NO SPAM)
[{
"text": "spam message!",
"label": 1
},
{
"text": "normal message.",
"label": 0
}]
Ejemplo de respuesta:
{
"message": "Datos cargados correctamente, el modelo se ha entrenado."
}
Cargar un archivo CSV Puedes cargar un archivo CSV con datos de entrenamiento usando el siguiente endpoint: /upload_data/ (POST)
Nota Este proyecto utiliza un modelo de Naive Bayes para clasificación de texto, que ha sido entrenado previamente con algunos datos de ejemplo. Puedes agregar más datos de entrenamiento y reentrenar el modelo en cualquier momento.
Metadata
Release files for spam-api 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spam_api-0.3.tar.gz | 4.8 kB | Without provenance | Details for spam_api-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spam_api-0.3-py3-none-any.whl | Python 3 | none | any | Details for spam_api-0.3-py3-none-any.whl |
Total release size: 10.2 kB
Release files / spam_api-0.3.tar.gz
| Download URL | spam_api-0.3.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92a568bb6f078bc4813b3a1d2f6547de9e45cd4c62a44f7ddcda18418df5f134
|
|
BLAKE2b-256 checksum How to use checksums |
ef86de47e8aa8d0bacf43ed018eaee8161aa84b63eaad04f2e02671c0ca3201e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.0
|
Release files / spam_api-0.3-py3-none-any.whl
| Download URL | spam_api-0.3-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82ab5681a2d242a91c9d1c2a363d59f89df48c4e45e524749cd46729b1c1bfc4
|
|
BLAKE2b-256 checksum How to use checksums |
29eff41cd0d503ac16258047af0dd3404d5ab2e0935eebaf29e064fbc5b43d4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.0
|
Security for spam-api 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.