""" 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)