-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
112 lines (71 loc) · 2.91 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import streamlit as st
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
st.write("""
# Program Prediksi Peluang Penerimaan Program S2
""")
st.image('./image.jpg')
st.write( """
## Keterangan Data Yang Digunakan
1. GRE Score: Merupakan Score Test Untuk Masuk Program S2 (0 - 340) Bersifat Continous
2. TOEFL Score: Score Kemampuan TOEFL (0 - 120) Bersifat Continous
3. University Rating: Rating Universitas (0 - 5) Bersifat Ordinal
4. Kekuatan Surat Rekomendasi (0 - 5) Bersifat Ordinal
5. GPA Sewaktu Undergraduate (0 - 10) Bersifat Continous
6. Pengalaman Riset (0 : tidak ada, 1 : ada) Bersifat Nominal
7. Peluang Diterima (0 - 1) Merupakan Dependent Variable
""")
st.write("""
## Overview Data
""")
myData = pd.read_csv('data.csv')
st.dataframe(myData)
st.write("""
## Deskripsi Data
""")
st.dataframe(myData.describe())
# Preproccessing Data
st.write("""
## Dilakukan Preprocessing Data dimana Fitur dan Labelnya akan Dipisah
""")
# Memisahkan Label Dan Fitur
X = myData.iloc[:, 1:-1].values
y = myData.iloc[:, -1].values
st.write("## Input Data X",X)
st.write("## Label Data y",y)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=69)
from sklearn.preprocessing import StandardScaler
ss_train_test = StandardScaler()
X_train_ss_scaled = ss_train_test.fit_transform(X_train)
X_test_ss_scaled = ss_train_test.transform(X_test)
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
l_regressor_ss = LinearRegression()
l_regressor_ss.fit(X_train_ss_scaled, y_train)
y_pred_l_reg_ss = l_regressor_ss.predict(X_test_ss_scaled)
st.write("Dengan Menggunakan Multiple Linear Regression Diperoleh Skor Untuk Data Test")
st.write(r2_score(y_test, y_pred_l_reg_ss))
st.write("# Sekarang Silahkan Masukan Skor Test Kamu Untuk Mengetahui Prediksi Peluang Kelulusan S2 Kamu")
form = st.form(key='my-form')
inputGRE = form.number_input("Masukan GRE Score: ", 0)
inputTOEFL = form.number_input("Masukan TOEFL Score: ", 0)
inputUnivRating = form.number_input("Masukan Rating Univ: ", 0)
inputSOP = form.number_input("Masukan Kekuatan SOP: ", 0)
inputLOR = form.number_input("Masukan Kekuatan LOR: ", 0)
inputCGPA = form.number_input("Masukan CGPA: ", 0)
inputResearch = form.number_input("Pengalaman Researc, 1 Jika Pernah Riset, 0 Jika Tidak", 0)
submit = form.form_submit_button('Submit')
completeData = np.array([inputGRE, inputTOEFL, inputUnivRating,
inputSOP, inputLOR, inputCGPA, inputResearch]).reshape(1, -1)
scaledData = ss_train_test.transform(completeData)
st.write('Tekan Submit Untuk Melihat Prediksi Peluang S2 Anda')
if submit:
prediction = l_regressor_ss.predict(scaledData)
if prediction > 1 :
result = 1
elif prediction < 0 :
result = 0
else :
result = prediction[0]
st.write(result*100, "Percent")