我制作了一个可以诊断疾病的python flask应用程序 该应用程序在本地运行良好,但通过Heroku部署时,我得到了500个内部错误。我知道该错误的含义,但我无法在我的应用程序中找到错误,因此,我相信通过StackOverflow可以找到它
从sk学习输入svm 从sk学习导入预处理 从sklearn.model\u选择导入列车\u测试\u拆分 从烧瓶进口烧瓶 进口泡菜 将numpy作为np导入 作为pd进口熊猫 导入操作系统
app = Flask(__name__)
@app.route('/hello')
def home():
return 'hello'
@app.route('/rf/<sym1>/<sym2>/<sym3>/<sym4>/<sym5>')
def predict(sym1, sym2, sym3, sym4, sym5):
l1=['back pain','constipation','abdominal pain','diarrhoea','mild fever','yellow urine',
'yellowing of eyes','acute liver failure','fluid overload','swelling of stomach',
'swelled lymph nodes','malaise','blurred and distorted vision','phlegm','throat irritation',
'redness of eyes','sinus pressure','runny nose','congestion','chest pain','weakness in limbs',
'fast heart rate','pain during bowel movements','pain in anal region','bloody stool',
'irritation in anus','neck pain','dizziness','cramps','bruising','obesity','swollen legs',
'swollen blood vessels','puffy face and eyes','enlarged thyroid','brittle nails',
'swollen extremeties','excessive hunger','extra marital contacts','drying and tingling lips',
'slurred speech','knee pain','hip joint pain','muscle weakness','stiff neck','swelling joints',
'movement stiffness','spinning movements','loss of balance','unsteadiness',
'weakness of one body side','loss of smell','bladder discomfort','foul smell of urine',
'continuous feel of urine','passage of gases','internal itching','toxic look (typhos)',
'depression','irritability','muscle pain','altered sensorium','red spots over body','belly pain',
'abnormal menstruation','dischromic patches','watering from eyes','increased
appetite','polyuria','family history','mucoid sputum',
'rusty sputum','lack of concentration','visual disturbances','receiving blood transfusion',
'receiving unsterile injections','coma','stomach bleeding','distention of abdomen',
'history of alcohol consumption','fluid overload','blood in sputum','prominent veins on calf',
'palpitations','painful walking','pus filled pimples','blackheads','scurring','skin peeling',
'silver like dusting','small dents in nails','inflammatory nails','blister','red sore around nose',
'yellow crust ooze']
disease=['Fungal infection','Allergy','GERD','Chronic cholestasis','Drug Reaction',
'Peptic ulcer diseae','AIDS','Diabetes','Gastroenteritis','Bronchial Asthma','Hypertension',
'Migraine','Cervical spondylosis',
'Paralysis (brain hemorrhage)','Jaundice','Malaria','Chicken pox','Dengue','Typhoid','hepatitis A',
'Hepatitis B','Hepatitis C','Hepatitis D','Hepatitis E','Alcoholic hepatitis','Tuberculosis',
'Common Cold','Pneumonia','Dimorphic hemmorhoids(piles)',
'Heartattack','Varicoseveins','Hypothyroidism','Hyperthyroidism','Hypoglycemia','Osteoarthristis',
'Arthritis','(vertigo) Paroymsal Positional Vertigo','Acne','Urinary tract infection','Psoriasis',
'Impetigo']
l2=[]
for x in range(0,len(l1)):
l2.append(0)
from sklearn.ensemble import RandomForestClassifier
clf3 = RandomForestClassifier()
clf3 = clf3.fit(X,np.ravel(y))
#filename = 'model.sav'
#pickle.dump(clf3, open(filename, 'wb'))
model =
pickle.load(open(os.path.abspath(os.path.dirname(__file__).replace("",""))+"/asset/model.sav", "rb"))
print("model loaded")
# calculating accuracy-------------------------------------------------------------------
#from sklearn.metrics import accuracy_score
#y_pred=clf3.predict(X_test)
#print(accuracy_score(y_test, y_pred))
#print(accuracy_score(y_test, y_pred,normalize=False))
# -----------------------------------------------------
Symptom1 = '%s' % sym1
Symptom2 = '%s' % sym2
Symptom3 = '%s' % sym3
Symptom4 = '%s' % sym4
Symptom5 = '%s' % sym5
psymptoms = [Symptom1,Symptom2,Symptom3,Symptom4,Symptom5]
for k in range(0,len(l1)):
# print (k,)
for z in psymptoms:
if(z==l1[k]):
l2[k]=1
inputtest = [l2]
predict = model.predict(inputtest)
predicted=predict[0]
#print(predicted)
#assigning a string value to "a"
for a in range(0,len(disease)):
if(predicted == a):
break
return disease[a]#returning the disease
if __name__ == '__main__':
app.run(debug=True)
如果你看到一些缩进错误,那不是问题所在,因为当我复制粘贴到网站上时,它可能错误地缩进了
此外,URL directing“/hello”工作正常,这表明我的predict函数有错误
如果你能回答,那就太好了
问候,, 罗山
目前没有回答
相关问题 更多 >
编程相关推荐