Instructions to use Carlito-25/sentiment-model-logistic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Carlito-25/sentiment-model-logistic with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Carlito-25/sentiment-model-logistic", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Download load_model.py from Carlito-25/sentiment-model-logistic: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/Carlito-25/sentiment-model-logistic/resolve/main/load_model.py
- Command line
-
hf download hf://Carlito-25/sentiment-model-logistic/load_model.py
-
curl -L -o load_model.py https://huggingface.co/Carlito-25/sentiment-model-logistic/resolve/main/load_model.py
1.16 kB
| """ | |
| Script de chargement pour le modèle logistic regression | |
| """ | |
| import pickle | |
| import numpy as np | |
| from huggingface_hub import hf_hub_download | |
| def load_logistic_model(repo_id="Carlito-25/sentiment-model-logistic"): | |
| """Charge le modèle logistic regression depuis Hugging Face""" | |
| model_path = hf_hub_download( | |
| repo_id=repo_id, | |
| filename="model.pkl" | |
| ) | |
| with open(model_path, 'rb') as f: | |
| model = pickle.load(f) | |
| return model | |
| def predict_sentiment(model, text_features): | |
| """Prédiction avec le modèle logistic regression""" | |
| if isinstance(text_features, list): | |
| text_features = np.array(text_features).reshape(1, -1) | |
| prediction = model.predict(text_features) | |
| probabilities = model.predict_proba(text_features) | |
| return { | |
| 'prediction': prediction[0], | |
| 'probabilities': probabilities[0].tolist() | |
| } | |
| # Exemple d'usage | |
| if __name__ == "__main__": | |
| model = load_logistic_model() | |
| # Remplace par tes features réelles | |
| dummy_features = np.random.rand(1, 100) # Adapte selon tes features | |
| result = predict_sentiment(model, dummy_features) | |
| print(result) | |