-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
42 lines (28 loc) · 996 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import pandas as pd
from transformers import pipeline, set_seed
import pickle
# Replace 'file_path.pkl' with the path to your pickle file
with open('modelForPredictionDisease.pkl', 'rb') as file:
model_rf = pickle.load(file)
def predictDisease(symp_in):
if(len(symp_in) == 0):
return "No symptoms!"
header = pd.read_csv("symptoms.csv")
symptoms = []
for a in header:
symptoms.append(a)
dat = {}
for i in range(132):
dat[symptoms[i]] = [0]
for sym in symp_in:
dat[sym] = [1]
frame = pd.DataFrame(dat)
Q=model_rf.predict(frame)
disease = Q[0]
str = f"Ayurvedic herbs for {disease}"
generator = pipeline('text-generation', model='gpt2-medium')
set_seed(42)
result = generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)
print(result[0]['generated_text'])
return 0
predictDisease(["chills","nausea"])