[4d90c1]: / predictive system.py

Download this file

33 lines (26 with data), 823 Bytes

 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
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import pandas as pd
import pickle
import numpy as np
loaded_model = pickle.load(open('/Users/pratyushkumargulzari/Downloads/depoly_lung_cancer_pred/trained_model.sav', 'rb'))
new_data = pd.DataFrame({
'Age': [30],
'Gender': [2],
'Alcohol use': [6],
'Genetic Risk': [4],
'chronic Lung Disease': [3],
'Wheezing': [2]
})
predictions = loaded_model.predict(new_data)
new_data['Predicted Level'] = predictions
predicted_messages = {
"Low": "The person has a low chance of lung cancer.",
"Medium": "The person has a moderate chance of lung cancer.",
"High": "The person has a high chance of lung cancer."
}
new_data['Prediction Message'] = new_data['Predicted Level'].map(predicted_messages)
print(new_data)