Initial upload of logistic regression sentiment model
Browse files- README.md +36 -0
- load_model.py +39 -0
- model.pkl +3 -0
README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- sentiment-analysis
|
| 5 |
+
- logistic-regression
|
| 6 |
+
- sklearn
|
| 7 |
+
- french
|
| 8 |
+
language:
|
| 9 |
+
- fr
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Carlito-25/sentiment-model-logistic
|
| 13 |
+
|
| 14 |
+
Modèle de régression logistique pour l'analyse de sentiment
|
| 15 |
+
|
| 16 |
+
## Usage
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from load_model import load_logistic_model, predict_sentiment
|
| 20 |
+
import numpy as np
|
| 21 |
+
|
| 22 |
+
# Charger le modèle
|
| 23 |
+
model = load_logistic_model()
|
| 24 |
+
|
| 25 |
+
# Prédiction (remplace par tes vraies features)
|
| 26 |
+
features = np.array([...]) # Tes features TF-IDF ou Word2Vec
|
| 27 |
+
result = predict_sentiment(model, features)
|
| 28 |
+
print(result)
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## Model Details
|
| 32 |
+
|
| 33 |
+
- **Algorithm**: Logistic Regression (scikit-learn)
|
| 34 |
+
- **Features**: TF-IDF/Word2Vec vectors
|
| 35 |
+
- **Task**: Sentiment Analysis
|
| 36 |
+
- **Training Data**: Custom French YouTube comments dataset
|
load_model.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Script de chargement pour le modèle logistic regression
|
| 3 |
+
"""
|
| 4 |
+
import pickle
|
| 5 |
+
import numpy as np
|
| 6 |
+
from huggingface_hub import hf_hub_download
|
| 7 |
+
|
| 8 |
+
def load_logistic_model(repo_id="Carlito-25/sentiment-model-logistic"):
|
| 9 |
+
"""Charge le modèle logistic regression depuis Hugging Face"""
|
| 10 |
+
model_path = hf_hub_download(
|
| 11 |
+
repo_id=repo_id,
|
| 12 |
+
filename="model.pkl"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
with open(model_path, 'rb') as f:
|
| 16 |
+
model = pickle.load(f)
|
| 17 |
+
|
| 18 |
+
return model
|
| 19 |
+
|
| 20 |
+
def predict_sentiment(model, text_features):
|
| 21 |
+
"""Prédiction avec le modèle logistic regression"""
|
| 22 |
+
if isinstance(text_features, list):
|
| 23 |
+
text_features = np.array(text_features).reshape(1, -1)
|
| 24 |
+
|
| 25 |
+
prediction = model.predict(text_features)
|
| 26 |
+
probabilities = model.predict_proba(text_features)
|
| 27 |
+
|
| 28 |
+
return {
|
| 29 |
+
'prediction': prediction[0],
|
| 30 |
+
'probabilities': probabilities[0].tolist()
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# Exemple d'usage
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
model = load_logistic_model()
|
| 36 |
+
# Remplace par tes features réelles
|
| 37 |
+
dummy_features = np.random.rand(1, 100) # Adapte selon tes features
|
| 38 |
+
result = predict_sentiment(model, dummy_features)
|
| 39 |
+
print(result)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8707543052dcf62a09be5b23f7d3f8e9934bd4b3f965bb1d9587d47f76fb9e22
|
| 3 |
+
size 63195069
|