ErenKontas
commited on
Upload 4 files
Browse files- Abalone.pkl +3 -0
- app.py +63 -0
- requirements.txt +4 -0
- train.csv +0 -0
Abalone.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e8c3c068ccd32bfbd55550c013b4d1d0664fae8079f0c2d15379032b5701589b
|
3 |
+
size 1914064
|
app.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
+
import joblib
|
4 |
+
|
5 |
+
from sklearn.preprocessing import StandardScaler, OneHotEncoder
|
6 |
+
from sklearn.model_selection import train_test_split
|
7 |
+
from sklearn.compose import ColumnTransformer
|
8 |
+
|
9 |
+
# Veriyi yükleme ve sütun isimlerini güncelleme
|
10 |
+
df = pd.read_csv('train.csv')
|
11 |
+
df.columns = df.columns.str.replace(r'[\s\.]', '_', regex=True)
|
12 |
+
|
13 |
+
# Bağımlı ve bağımsız değişkenlerin seçimi
|
14 |
+
x = df.drop(['id', 'Rings'], axis=1)
|
15 |
+
y = df[['Rings']]
|
16 |
+
|
17 |
+
# Eğitim ve test verilerini ayırma
|
18 |
+
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.20, random_state=42)
|
19 |
+
|
20 |
+
# Ön işleme (StandardScaler ve OneHotEncoder)
|
21 |
+
preprocessor = ColumnTransformer(
|
22 |
+
transformers=[
|
23 |
+
('num', StandardScaler(), ['Length', 'Diameter', 'Height', 'Whole_weight', 'Whole_weight_1', 'Whole_weight_2', 'Shell_weight']),
|
24 |
+
('cat', OneHotEncoder(), ['Sex'])
|
25 |
+
]
|
26 |
+
)
|
27 |
+
|
28 |
+
# Streamlit uygulaması
|
29 |
+
def rings_pred(Sex, Length, Diameter, Height, Whole_weight, Whole_weight_1, Whole_weight_2, Shell_weight):
|
30 |
+
input_data = pd.DataFrame({
|
31 |
+
'Sex': [Sex],
|
32 |
+
'Length': [Length],
|
33 |
+
'Diameter': [Diameter],
|
34 |
+
'Height': [Height],
|
35 |
+
'Whole_weight': [Whole_weight],
|
36 |
+
'Whole_weight_1': [Whole_weight_1],
|
37 |
+
'Whole_weight_2': [Whole_weight_2],
|
38 |
+
'Shell_weight': [Shell_weight]
|
39 |
+
})
|
40 |
+
|
41 |
+
|
42 |
+
input_data_transformed = preprocessor.fit_transform(input_data)
|
43 |
+
|
44 |
+
model = joblib.load('Abalone.pkl')
|
45 |
+
|
46 |
+
prediction = model.predict(input_data_transformed)
|
47 |
+
return float(prediction[0])
|
48 |
+
|
49 |
+
st.title("Abalone Veri seti ile Yaş Tahmini Regresyon Modeli")
|
50 |
+
st.write("Veri Gir")
|
51 |
+
|
52 |
+
Sex = st.selectbox('Sex', df['Sex'].unique())
|
53 |
+
Length = st.selectbox('Length', df['Length'].unique())
|
54 |
+
Diameter = st.selectbox('Diameter', df['Diameter'].unique())
|
55 |
+
Height = st.selectbox('Height', df['Height'].unique())
|
56 |
+
Whole_weight = st.selectbox('Whole_weight', df['Whole_weight'].unique())
|
57 |
+
Whole_weight_1 = st.selectbox('Whole_weight_1', df['Whole_weight_1'].unique())
|
58 |
+
Whole_weight_2 = st.selectbox('Whole_weight_2', df['Whole_weight_2'].unique())
|
59 |
+
Shell_weight = st.selectbox('Shell_weight', df['Shell_weight'].unique())
|
60 |
+
|
61 |
+
if st.button('Predict'):
|
62 |
+
rings = rings_pred(Sex, Length, Diameter, Height, Whole_weight, Whole_weight_1, Whole_weight_2, Shell_weight)
|
63 |
+
st.write(f'The predicted rings is: {rings:.2f}')
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
scikit-learn
|
3 |
+
pandas
|
4 |
+
tensorflow
|
train.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|