Spaces:
Runtime error
Runtime error
Mustafa Al Hamad commited on
Commit ·
49fb311
1
Parent(s): 991fa51
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,36 @@ from sklearn.metrics import confusion_matrix
|
|
| 28 |
from sklearn.feature_selection import SequentialFeatureSelector
|
| 29 |
from sklearn.model_selection import GridSearchCV, StratifiedKFold
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
from sklearn.metrics import accuracy_score, confusion_matrix, roc_auc_score, roc_curve, cohen_kappa_score, f1_score, recall_score, precision_score
|
| 32 |
def measures(predicted, y_test):
|
| 33 |
accuracy = accuracy_score(y_test, predicted)
|
|
@@ -179,6 +209,8 @@ def greet(operation,filer):
|
|
| 179 |
filename = str(number)+"="+type(model).__name__+'='+str(acc)+'.sav'
|
| 180 |
document.add_paragraph(type(model).__name__+' has been chosen as the prediction model for achieving an accuracy of '+str(acc)+'%')
|
| 181 |
pickle.dump(model, open(filename, 'wb'))
|
|
|
|
|
|
|
| 182 |
document.save('retraining_report.docx')
|
| 183 |
return 'retraining_report.docx',str(type(model).__name__+' has been chosen as the prediction model for achieving an accuracy of '+str(acc)+'%')
|
| 184 |
majors = ['CIS', 'CS', 'CYS', 'AI']
|
|
|
|
| 28 |
from sklearn.feature_selection import SequentialFeatureSelector
|
| 29 |
from sklearn.model_selection import GridSearchCV, StratifiedKFold
|
| 30 |
|
| 31 |
+
from docx.enum.dml import MSO_THEME_COLOR_INDEX
|
| 32 |
+
def add_hyperlink(paragraph, text, url):
|
| 33 |
+
# This gets access to the document.xml.rels file and gets a new relation id value
|
| 34 |
+
part = paragraph.part
|
| 35 |
+
r_id = part.relate_to(url, docx.opc.constants.RELATIONSHIP_TYPE.HYPERLINK, is_external=True)
|
| 36 |
+
|
| 37 |
+
# Create the w:hyperlink tag and add needed values
|
| 38 |
+
hyperlink = docx.oxml.shared.OxmlElement('w:hyperlink')
|
| 39 |
+
hyperlink.set(docx.oxml.shared.qn('r:id'), r_id, )
|
| 40 |
+
|
| 41 |
+
# Create a w:r element and a new w:rPr element
|
| 42 |
+
new_run = docx.oxml.shared.OxmlElement('w:r')
|
| 43 |
+
rPr = docx.oxml.shared.OxmlElement('w:rPr')
|
| 44 |
+
|
| 45 |
+
# Join all the xml elements together add add the required text to the w:r element
|
| 46 |
+
new_run.append(rPr)
|
| 47 |
+
new_run.text = text
|
| 48 |
+
hyperlink.append(new_run)
|
| 49 |
+
|
| 50 |
+
# Create a new Run object and add the hyperlink into it
|
| 51 |
+
r = paragraph.add_run ()
|
| 52 |
+
r._r.append (hyperlink)
|
| 53 |
+
|
| 54 |
+
# A workaround for the lack of a hyperlink style (doesn't go purple after using the link)
|
| 55 |
+
# Delete this if using a template that has the hyperlink style in it
|
| 56 |
+
r.font.color.theme_color = MSO_THEME_COLOR_INDEX.HYPERLINK
|
| 57 |
+
r.font.underline = True
|
| 58 |
+
|
| 59 |
+
return hyperlink
|
| 60 |
+
|
| 61 |
from sklearn.metrics import accuracy_score, confusion_matrix, roc_auc_score, roc_curve, cohen_kappa_score, f1_score, recall_score, precision_score
|
| 62 |
def measures(predicted, y_test):
|
| 63 |
accuracy = accuracy_score(y_test, predicted)
|
|
|
|
| 209 |
filename = str(number)+"="+type(model).__name__+'='+str(acc)+'.sav'
|
| 210 |
document.add_paragraph(type(model).__name__+' has been chosen as the prediction model for achieving an accuracy of '+str(acc)+'%')
|
| 211 |
pickle.dump(model, open(filename, 'wb'))
|
| 212 |
+
p = document.add_paragraph('For more like this contact me at contact@mustafasa.com ')
|
| 213 |
+
add_hyperlink(p, 'contact@mustafasa.com', "contact@mustafasa.com")
|
| 214 |
document.save('retraining_report.docx')
|
| 215 |
return 'retraining_report.docx',str(type(model).__name__+' has been chosen as the prediction model for achieving an accuracy of '+str(acc)+'%')
|
| 216 |
majors = ['CIS', 'CS', 'CYS', 'AI']
|