Spaces:
Runtime error
Runtime error
tentativo efficientamento pro HF
Browse files- CD/app.py +0 -6
- CI/test_ci.py +7 -0
- app.py +7 -19
CD/app.py
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
print("MACOSACOMDAI")
|
| 2 |
-
# Utilities
|
| 3 |
-
from src.modello import Modello
|
| 4 |
-
from src.dataset import LoadDataset
|
| 5 |
-
|
| 6 |
-
print("Hello world!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CI/test_ci.py
CHANGED
|
@@ -14,3 +14,10 @@ class TestClass :
|
|
| 14 |
def test_trivial_output(self) :
|
| 15 |
# Controllo del funzionamento del modello con frasi banali
|
| 16 |
assert model.predict("neutral")[0]=="neutral" and model.predict("awesome")[0]=="positive" and model.predict("terrible")[0]=="negative"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def test_trivial_output(self) :
|
| 15 |
# Controllo del funzionamento del modello con frasi banali
|
| 16 |
assert model.predict("neutral")[0]=="neutral" and model.predict("awesome")[0]=="positive" and model.predict("terrible")[0]=="negative"
|
| 17 |
+
|
| 18 |
+
def test_accuracy(self) :
|
| 19 |
+
# Controllo che l'accuracy sia almeno 0.5
|
| 20 |
+
X = ld.dataset.X
|
| 21 |
+
y = ld.dataset.y
|
| 22 |
+
y_pred = model.predict(X)
|
| 23 |
+
assert accuracy_score(y, y_pred)>=0.5
|
app.py
CHANGED
|
@@ -9,20 +9,18 @@ dataset = LoadDataset()
|
|
| 9 |
|
| 10 |
X = dataset.X
|
| 11 |
y = dataset.y
|
| 12 |
-
y_pred =
|
| 13 |
-
|
| 14 |
-
acc = f"{accuracy_score(y, y_pred)}"
|
| 15 |
|
| 16 |
valori = ['negative', 'neutral', 'positive']
|
| 17 |
|
| 18 |
def predict_tweet(tweet,esito_atteso) :
|
| 19 |
-
global
|
| 20 |
X.append(tweet)
|
| 21 |
y.append(esito_atteso)
|
| 22 |
y_new = model.predict(tweet)[0]
|
| 23 |
y_pred.append(y_new)
|
| 24 |
-
|
| 25 |
-
return y_new,
|
| 26 |
|
| 27 |
demo = gr.Interface(
|
| 28 |
fn=predict_tweet,
|
|
@@ -31,16 +29,6 @@ demo = gr.Interface(
|
|
| 31 |
flagging_mode = 'never'
|
| 32 |
)
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
#check_loop = True
|
| 39 |
-
|
| 40 |
-
#while check_loop :
|
| 41 |
-
# tweet = input("Inserire tweet:")
|
| 42 |
-
# if tweet=="" :
|
| 43 |
-
# print("EXIT")
|
| 44 |
-
# check_loop = False
|
| 45 |
-
# else :
|
| 46 |
-
# print(f"Sentiment: {model.predict(tweet)[0]}")
|
|
|
|
| 9 |
|
| 10 |
X = dataset.X
|
| 11 |
y = dataset.y
|
| 12 |
+
y_pred = []
|
|
|
|
|
|
|
| 13 |
|
| 14 |
valori = ['negative', 'neutral', 'positive']
|
| 15 |
|
| 16 |
def predict_tweet(tweet,esito_atteso) :
|
| 17 |
+
global X, y, y_pred
|
| 18 |
X.append(tweet)
|
| 19 |
y.append(esito_atteso)
|
| 20 |
y_new = model.predict(tweet)[0]
|
| 21 |
y_pred.append(y_new)
|
| 22 |
+
acc_new = f"{accuracy_score(y, y_pred)}"
|
| 23 |
+
return y_new,acc_new
|
| 24 |
|
| 25 |
demo = gr.Interface(
|
| 26 |
fn=predict_tweet,
|
|
|
|
| 29 |
flagging_mode = 'never'
|
| 30 |
)
|
| 31 |
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
y_pred = model.predict(X)
|
| 34 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|