llepogam commited on
Commit
f2cf38f
·
1 Parent(s): e36af4b

updated /predict description

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -61,14 +61,23 @@ async def index():
61
  @app.post("/predict", tags=["Machine Learning"])
62
  async def predict(predictionFeatures: PredictionFeatures):
63
  """
64
- Predicts whether the provided text contains hate speech.
65
- The input is a string with the sentence to be predicted
66
 
67
- The return is a dictionnary with :
68
- * the prediction : "offensive" or "not offensive"
69
- * the probability : A number between 0 and 1. The higher the bigger the probability for hate speech. The threshold for the prediction is at 0.5
70
 
71
- Use the following request to use it :
 
 
 
 
 
 
 
 
 
 
72
 
73
  url = "https://llepogam-hate-speech-detection-api.hf.space/predict"
74
  headers = {
@@ -76,11 +85,13 @@ async def predict(predictionFeatures: PredictionFeatures):
76
  "Content-Type": "application/json"
77
  }
78
 
79
- Text_to_predict = {
80
- "Text": text
81
  }
82
 
83
-
 
 
84
  """
85
 
86
  # Convert input into a DataFrame
 
61
  @app.post("/predict", tags=["Machine Learning"])
62
  async def predict(predictionFeatures: PredictionFeatures):
63
  """
64
+ Predict whether the provided text contains hate speech.
 
65
 
66
+ ### Input
67
+ - `predictionFeatures` (PredictionFeatures): An object containing the text to be analyzed.
68
+ - The input text is provided as a string.
69
 
70
+ ### Output
71
+ Returns a dictionary with the following keys:
72
+ - `prediction` (str): Indicates whether the text is "offensive" or "not offensive".
73
+ - `probability` (float): A value between 0 and 1, representing the likelihood of hate speech.
74
+ - Texts with a probability >= 0.5 are classified as "offensive".
75
+
76
+ ### Example Usage
77
+ To use this endpoint, send a POST request as follows:
78
+
79
+ ```python
80
+ import requests
81
 
82
  url = "https://llepogam-hate-speech-detection-api.hf.space/predict"
83
  headers = {
 
85
  "Content-Type": "application/json"
86
  }
87
 
88
+ data = {
89
+ "Text": "your text here"
90
  }
91
 
92
+ response = requests.post(url, headers=headers, json=data)
93
+ print(response.json())
94
+ ```
95
  """
96
 
97
  # Convert input into a DataFrame