hanifekaptan commited on
Commit
a98a45f
1 Parent(s): 380ac1c

Yazım hataları düzeltildi

Browse files
Files changed (1) hide show
  1. app.py +70 -70
app.py CHANGED
@@ -1,71 +1,71 @@
1
- # Author: Hanife Kaptan
2
- # Versions: python==3.11.2, xgboost==2.1.1, streamlit==1.36.0, scikit-learn==1.4.2, pandas==2.0.2
3
-
4
- import pandas as pd
5
- from sklearn.compose import ColumnTransformer
6
- from sklearn.preprocessing import OneHotEncoder, StandardScaler
7
- from sklearn.pipeline import Pipeline
8
- from xgboost import XGBClassifier
9
- import streamlit as st
10
-
11
- df = pd.read_csv("akcigerKanseri.csv")
12
-
13
- X = df.drop("lung_cancer", axis=1)
14
- y = df["lung_cancer"]
15
-
16
- preprocess = ColumnTransformer(
17
- transformers = [("cat", OneHotEncoder(), ["gender"]), ("num", (StandardScaler()), ["age"])]
18
- )
19
-
20
- my_model = XGBClassifier()
21
-
22
- pipe = Pipeline(steps=[("preprocessor", preprocess), ("model", my_model)])
23
- pipe.fit(X, y)
24
-
25
- def lung_cancer(gender, age, smoking, yellow_fingers, anxiety, peer_pressure,
26
- chronic_disease, fatigue, allergy, wheezing, alcohol_consuming,
27
- coughing, shortness_of_breath, swallowing_difficulty, chest_pain):
28
- input_data = pd.DataFrame({"gender": [gender],
29
- "age": [age],
30
- "smoking": [smoking],
31
- "yellow_fingers": [yellow_fingers],
32
- "anxiety": [anxiety],
33
- "peer_pressure": [peer_pressure],
34
- "chronic_disease": [chronic_disease],
35
- "fatigue": [fatigue],
36
- "allergy": [allergy],
37
- "wheezing": [wheezing],
38
- "alcohol_consuming": [alcohol_consuming],
39
- "coughing": [coughing],
40
- "shortness_of_breath": [shortness_of_breath],
41
- "swallowing_difficulty": [swallowing_difficulty],
42
- "chest_pain": [chest_pain]})
43
- prediction = pipe.predict(input_data)[0]
44
- return prediction
45
-
46
- st.title("Akciğer Kanseri Tespiti :hospital:: @hanifekaptan")
47
- st.write("Kendinizle ilgili doğru seçenekleri seçiniz.")
48
- gender = st.radio("Gender", ["Male", "Female"]) # male ve female 1 ve 0 değerlerine dönüştürülecek
49
- age = st.number_input("Age", 0, 100)
50
- smoking = st.radio("Smoking", [True, False])
51
- yellow_fingers = st.radio("Yellow Fingers", [True, False])
52
- anxiety = st.radio("Anxiety", [True, False])
53
- peer_pressure = st.radio("peer_pressure", [True, False])
54
- chronic_disease = st.radio("chronic_disease", [True, False])
55
- fatigue = st.radio("fatigue", [True, False])
56
- allergy = st.radio("allergy", [True, False])
57
- wheezing = st.radio("wheezing", [True, False])
58
- alcohol_consuming = st.radio("alcohol_consuming", [True, False])
59
- coughing = st.radio("coughing", [True, False])
60
- shortness_of_breath = st.radio("shortness_of_breath", [True, False])
61
- swallowing_difficulty = st.radio("swallowing_difficulty", [True, False])
62
- chest_pain = st.radio("chest_pain", [True, False])
63
-
64
- if st.button("Predict"):
65
- pred = lung_cancer(gender, age, smoking, yellow_fingers, anxiety, peer_pressure,
66
- chronic_disease, fatigue, allergy, wheezing, alcohol_consuming,
67
- coughing, shortness_of_breath, swallowing_difficulty, chest_pain)
68
- if pred == 1:
69
- st.write("Result: Positive")
70
- elif pred == 0:
71
  st.write("Result: Negative")
 
1
+ # Author: Hanife Kaptan
2
+ # Versions: python==3.11.2, xgboost==2.1.1, streamlit==1.36.0, scikit-learn==1.4.2, pandas==2.0.2
3
+
4
+ import pandas as pd
5
+ from sklearn.compose import ColumnTransformer
6
+ from sklearn.preprocessing import OneHotEncoder, StandardScaler
7
+ from sklearn.pipeline import Pipeline
8
+ from xgboost import XGBClassifier
9
+ import streamlit as st
10
+
11
+ df = pd.read_csv("akcigerKanseri.csv")
12
+
13
+ X = df.drop("lung_cancer", axis=1)
14
+ y = df["lung_cancer"]
15
+
16
+ preprocess = ColumnTransformer(
17
+ transformers = [("cat", OneHotEncoder(), ["gender"]), ("num", (StandardScaler()), ["age"])]
18
+ )
19
+
20
+ my_model = XGBClassifier()
21
+
22
+ pipe = Pipeline(steps=[("preprocessor", preprocess), ("model", my_model)])
23
+ pipe.fit(X, y)
24
+
25
+ def lung_cancer(gender, age, smoking, yellow_fingers, anxiety, peer_pressure,
26
+ chronic_disease, fatigue, allergy, wheezing, alcohol_consuming,
27
+ coughing, shortness_of_breath, swallowing_difficulty, chest_pain):
28
+ input_data = pd.DataFrame({"gender": [gender],
29
+ "age": [age],
30
+ "smoking": [smoking],
31
+ "yellow_fingers": [yellow_fingers],
32
+ "anxiety": [anxiety],
33
+ "peer_pressure": [peer_pressure],
34
+ "chronic_disease": [chronic_disease],
35
+ "fatigue": [fatigue],
36
+ "allergy": [allergy],
37
+ "wheezing": [wheezing],
38
+ "alcohol_consuming": [alcohol_consuming],
39
+ "coughing": [coughing],
40
+ "shortness_of_breath": [shortness_of_breath],
41
+ "swallowing_difficulty": [swallowing_difficulty],
42
+ "chest_pain": [chest_pain]})
43
+ prediction = pipe.predict(input_data)[0]
44
+ return prediction
45
+
46
+ st.title("Akciğer Kanseri Tespiti :hospital:: @hanifekaptan")
47
+ st.write("Kendinizle ilgili doğru seçenekleri seçiniz.")
48
+ gender = st.radio("Gender", ["Male", "Female"]) # male ve female 1 ve 0 değerlerine dönüştürülecek
49
+ age = st.number_input("Age", 0, 100)
50
+ smoking = st.radio("Smoking", [True, False])
51
+ yellow_fingers = st.radio("Yellow Fingers", [True, False])
52
+ anxiety = st.radio("Anxiety", [True, False])
53
+ peer_pressure = st.radio("Peer Pressure", [True, False])
54
+ chronic_disease = st.radio("Chronic Disease", [True, False])
55
+ fatigue = st.radio("Fatigue", [True, False])
56
+ allergy = st.radio("Allergy", [True, False])
57
+ wheezing = st.radio("Wheezing", [True, False])
58
+ alcohol_consuming = st.radio("Alcohol Consuming", [True, False])
59
+ coughing = st.radio("Coughing", [True, False])
60
+ shortness_of_breath = st.radio("Shortness of Breath", [True, False])
61
+ swallowing_difficulty = st.radio("Swallowing Difficulty", [True, False])
62
+ chest_pain = st.radio("Chest Pain", [True, False])
63
+
64
+ if st.button("Predict"):
65
+ pred = lung_cancer(gender, age, smoking, yellow_fingers, anxiety, peer_pressure,
66
+ chronic_disease, fatigue, allergy, wheezing, alcohol_consuming,
67
+ coughing, shortness_of_breath, swallowing_difficulty, chest_pain)
68
+ if pred == 1:
69
+ st.write("Result: Positive")
70
+ elif pred == 0:
71
  st.write("Result: Negative")