giseldo commited on
Commit
a599e86
·
1 Parent(s): bb30fac

ultima versao

Browse files
Files changed (1) hide show
  1. app.py +46 -50
app.py CHANGED
@@ -1,11 +1,9 @@
1
  import gradio as gr
2
- from sklearn.feature_extraction.text import TfidfVectorizer
3
- from sklearn.feature_selection import SelectKBest
4
  import pandas as pd
5
  from textblob import TextBlob
6
  import textstat
7
  from huggingface_hub import hf_hub_download
8
- import joblib
9
 
10
  titulo1 = """CLONE - Studio Dashboard: "default" and "Default Project" does not give clear information about Alloy and Project unless description is read."""
11
  descricao1 = """Steps To Reproduce: 1. On dashboard on studio 3.0, navigate to Develop tab. 2. Notice "default" and "Default Project" & "two-tabbed" and "Tabbed Application" names. Actual: User does not get clear information from names that one is alloy project and another one is Titanium project unless he reads the description below. Expected: Naming convention or icon corresponding must suggest type"""
@@ -22,32 +20,24 @@ descricao4 = """During the compile process Alloy will attempt to remove files fr
22
  titulo5 = """Resolve suboptimal compression from uglify-js v2 update"""
23
  descricao5 = """The v2 update of uglify-js in Alloy, specifically version 2.2.5, has some suboptimal compressions, which are causing the optimizer.js test spec to fail in certain cases. Specifically the issues are around booleans and cascading of variables in assignments. These issues have been logged with the Uglifyjs2 project in the following links: * https://github.com/mishoo/UglifyJS2/issues/137 * https://github.com/mishoo/UglifyJS2/issues/138 When these issues are resolved and distributed in an npm release, we need to revisit these compressions and testing to ensure that the fixes are in place, and that new uglify-js version has no regressions that impact alloy."""
24
 
25
-
26
- from huggingface_hub import hf_hub_download
27
- import joblib
28
-
29
  def calcula_MbR(titulo, descricao):
30
  context = titulo + descricao
31
  d = {"context": [context]}
32
  df = pd.DataFrame(data=d, columns=["context"])
33
-
34
- model = joblib.load(
35
- hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_mbr.joblib")
36
- )
37
-
38
- #model = load("model/model_tawos_aloy_mbr.pkl")
39
-
40
  story_points_MbR = model.predict(df["context"])
41
  return story_points_MbR
42
 
43
- def calcula_neosp(titulo, descricao):
44
-
45
- model = joblib.load(
46
- hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_neosp.joblib")
47
- )
48
-
49
- # model = load("model/model_tawos_aloy_neosp.pkl")
50
 
 
 
51
  context = titulo + descricao
52
  d = {"context": [context]}
53
  df = pd.DataFrame(data=d, columns=["context"])
@@ -73,59 +63,65 @@ def calcula_neosp(titulo, descricao):
73
 
74
  story_points = model.predict(X)
75
  return story_points
76
-
77
- def calculaTFIDFSVM(titulo, descricao):
78
-
79
- model = joblib.load(
80
- hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_tfidfsvm.joblib")
81
- )
82
-
83
- # model = load("model/model_tawos_aloy_tfidfsvm.pkl")
84
 
 
 
85
  context = titulo + descricao
86
  d = {"context": [context]}
87
  df = pd.DataFrame(data=d, columns=["context"])
88
 
89
- vectorizer = joblib.load(
90
- hf_hub_download("giseldo/model_effort_tawos", "vectorizer_tfidfsvm.joblib")
91
- )
 
 
 
 
 
 
 
92
 
93
- # vectorizer = load("model/vectorizer_tfidfsvm.pkl")
 
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  X = vectorizer.transform(df["context"])
96
  story_points = model.predict(X)
97
  return story_points
98
 
99
- def calculaTFIDFLinear(titulo, descricao):
100
-
101
- model = joblib.load(
102
- hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_tfidflinear.joblib")
103
- )
104
-
105
- # model = load("model/model_tawos_aloy_tfidflinear.pkl")
106
-
107
  context = titulo + descricao
108
  d = {"context": [context]}
109
  df = pd.DataFrame(data=d, columns=["context"])
110
-
111
- vectorizer = joblib.load(
112
- hf_hub_download("giseldo/model_effort_tawos", "vectorizer_tfidflinear.joblib")
113
- )
114
-
115
- # vectorizer = load("model/vectorizer_tfidflinear.pkl")
116
-
117
  X = vectorizer.transform(df["context"])
118
  story_points = model.predict(X)
119
  return story_points
120
 
121
  def calcula(titulo, descricao):
122
- return calcula_MbR(titulo, descricao), calcula_neosp(titulo, descricao), calculaTFIDFSVM(titulo, descricao), calculaTFIDFLinear(titulo, descricao)
123
 
124
  demo = gr.Interface(fn=calcula,
125
  inputs=[gr.Textbox(placeholder="Título", label="Título"),
126
  gr.Textbox(lines=10, placeholder="Descrição", label="Descrição")],
127
- outputs=[gr.Textbox(label="Story Points Estimado MbR"),
 
128
  gr.Textbox(label="Story Points Estimado NEOSP-SVR"),
 
129
  gr.Textbox(label="Story Points Estimado TFIDF-SVR"),
130
  gr.Textbox(label="Story Points Estimado TFIDF-Linear")],
131
  title="Agile Task Story Point Estimator",
 
1
  import gradio as gr
 
 
2
  import pandas as pd
3
  from textblob import TextBlob
4
  import textstat
5
  from huggingface_hub import hf_hub_download
6
+ from joblib import load
7
 
8
  titulo1 = """CLONE - Studio Dashboard: "default" and "Default Project" does not give clear information about Alloy and Project unless description is read."""
9
  descricao1 = """Steps To Reproduce: 1. On dashboard on studio 3.0, navigate to Develop tab. 2. Notice "default" and "Default Project" & "two-tabbed" and "Tabbed Application" names. Actual: User does not get clear information from names that one is alloy project and another one is Titanium project unless he reads the description below. Expected: Naming convention or icon corresponding must suggest type"""
 
20
  titulo5 = """Resolve suboptimal compression from uglify-js v2 update"""
21
  descricao5 = """The v2 update of uglify-js in Alloy, specifically version 2.2.5, has some suboptimal compressions, which are causing the optimizer.js test spec to fail in certain cases. Specifically the issues are around booleans and cascading of variables in assignments. These issues have been logged with the Uglifyjs2 project in the following links: * https://github.com/mishoo/UglifyJS2/issues/137 * https://github.com/mishoo/UglifyJS2/issues/138 When these issues are resolved and distributed in an npm release, we need to revisit these compressions and testing to ensure that the fixes are in place, and that new uglify-js version has no regressions that impact alloy."""
22
 
 
 
 
 
23
  def calcula_MbR(titulo, descricao):
24
  context = titulo + descricao
25
  d = {"context": [context]}
26
  df = pd.DataFrame(data=d, columns=["context"])
27
+ model = load(hf_hub_download("model_effort_tawos", "model_tawos_aloy_mbr.joblib"))
 
 
 
 
 
 
28
  story_points_MbR = model.predict(df["context"])
29
  return story_points_MbR
30
 
31
+ def calcula_Median(titulo, descricao):
32
+ context = titulo + descricao
33
+ d = {"context": [context]}
34
+ df = pd.DataFrame(data=d, columns=["context"])
35
+ model = load(hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_median.joblib"))
36
+ story_points_MbR = model.predict(df["context"])
37
+ return story_points_MbR
38
 
39
+ def calcula_NEOSP_SVR(titulo, descricao):
40
+ model = load(hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_neosp_svr.joblib"))
41
  context = titulo + descricao
42
  d = {"context": [context]}
43
  df = pd.DataFrame(data=d, columns=["context"])
 
63
 
64
  story_points = model.predict(X)
65
  return story_points
 
 
 
 
 
 
 
 
66
 
67
+ def calcula_NEOSP_Linear(titulo, descricao):
68
+ model = load(hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_neosp_linear.joblib"))
69
  context = titulo + descricao
70
  d = {"context": [context]}
71
  df = pd.DataFrame(data=d, columns=["context"])
72
 
73
+ # features de legibilidade
74
+ df["gunning_fog"] = df['context'].apply(textstat.gunning_fog)#
75
+ df["flesch_reading_ease"] = df['context'].apply(textstat.flesch_reading_ease)#
76
+ df["flesch_kincaid_grade"] = df['context'].apply(textstat.flesch_kincaid_grade)#
77
+ df["smog_index"] = df['context'].apply(textstat.smog_index)
78
+ df["coleman_liau_index"] = df['context'].apply(textstat.coleman_liau_index)#
79
+ df["automated_readability_index"] = df['context'].apply(textstat.automated_readability_index) #
80
+ df["dale_chall_readability_score"] = df['context'].apply(textstat.dale_chall_readability_score)#
81
+ df["difficult_words"] = df['context'].apply(textstat.difficult_words)
82
+ df["linsear_write_formula"] = df['context'].apply(textstat.linsear_write_formula)#
83
 
84
+ # feature de sentimento
85
+ df["polarity"] = df["context"].apply(lambda x: TextBlob(x).sentiment.polarity)
86
+ df["subjectivity"] = df["context"].apply(lambda x: TextBlob(x).sentiment.subjectivity)
87
 
88
+ X = df[["gunning_fog", "flesch_reading_ease", "flesch_kincaid_grade", "smog_index", "coleman_liau_index",
89
+ "automated_readability_index", "dale_chall_readability_score", "difficult_words", "linsear_write_formula",
90
+ "polarity", "subjectivity"]]
91
+
92
+ story_points = model.predict(X)
93
+ return story_points
94
+
95
+ def calcula_TFIDF_SVR(titulo, descricao):
96
+ model = load(hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_tfidf_svr.joblib"))
97
+ context = titulo + descricao
98
+ d = {"context": [context]}
99
+ df = pd.DataFrame(data=d, columns=["context"])
100
+ vectorizer = load(hf_hub_download("giseldo/model_effort_tawos", "vectorizer_tfidf.joblib"))
101
  X = vectorizer.transform(df["context"])
102
  story_points = model.predict(X)
103
  return story_points
104
 
105
+ def calcula_TFIDF_Linear(titulo, descricao):
106
+ model = load(hf_hub_download("giseldo/model_effort_tawos", "model_tawos_aloy_tfidf_linear.joblib"))
 
 
 
 
 
 
107
  context = titulo + descricao
108
  d = {"context": [context]}
109
  df = pd.DataFrame(data=d, columns=["context"])
110
+ vectorizer = load(hf_hub_download("giseldo/model_effort_tawos", "vectorizer_tfidf.joblib"))
 
 
 
 
 
 
111
  X = vectorizer.transform(df["context"])
112
  story_points = model.predict(X)
113
  return story_points
114
 
115
  def calcula(titulo, descricao):
116
+ return calcula_MbR(titulo, descricao), calcula_Median(titulo, descricao), calcula_NEOSP_SVR(titulo, descricao), calcula_NEOSP_Linear(titulo, descricao), calcula_TFIDF_SVR(titulo, descricao), calcula_TFIDF_Linear(titulo, descricao)
117
 
118
  demo = gr.Interface(fn=calcula,
119
  inputs=[gr.Textbox(placeholder="Título", label="Título"),
120
  gr.Textbox(lines=10, placeholder="Descrição", label="Descrição")],
121
+ outputs=[gr.Textbox(label="Story Points Estimado Média"),
122
+ gr.Textbox(label="Story Points Estimado Mediana"),
123
  gr.Textbox(label="Story Points Estimado NEOSP-SVR"),
124
+ gr.Textbox(label="Story Points Estimado NEOSP-Linear"),
125
  gr.Textbox(label="Story Points Estimado TFIDF-SVR"),
126
  gr.Textbox(label="Story Points Estimado TFIDF-Linear")],
127
  title="Agile Task Story Point Estimator",