File size: 2,627 Bytes
e9f3adc f6c1fae e9f3adc |
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 |
'''
author : Rupesh Garsondiya
github : @Rupeshgarsondiya
Organization : L.J University
'''
import pandas as pd
import streamlit as st
import numpy as np
from src.features.build_features import *
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
class Model_Train:
def __init__(self) -> None:
pass
'''load_data() fuction use for to get the clean data or feature transformed data '''
def load_data(self):
pass
def train_model(self):
st.markdown(
"""
<style>
body {
background-color: lightblue;
}
</style>
""",
unsafe_allow_html=True
)
fe = FeatureEngineering()
x_train,x_test,y_train,y_test,pipeline = fe.get_clean_data()
# Define the options for the dropdown menu
options = ['Logistic Regreesion', 'Random Forest Classifier', 'Decision Tree', 'SVM','KNeighborsClassifier']
# Create the dropdown menu
with st.container():
st.markdown('<div class="dropdown-left">', unsafe_allow_html=True)
selected_option = st.sidebar.selectbox('Select Algoritham :', options)
st.markdown('</div>', unsafe_allow_html=True)
S_algo = object
if selected_option== 'Logistic Regreesion':
S_algo = LogisticRegression()
S_algo.fit(x_train,y_train)
ypred = S_algo.predict(x_test)
elif selected_option=='Random Forest Classifier':
S_algo = RandomForestClassifier(n_estimators=200,n_jobs=-1,verbose=True,max_depth=2)
S_algo.fit(x_train,y_train)
ypred1 = S_algo.predict(x_test)
elif selected_option=='Decision Tree':
S_algo = DecisionTreeClassifier(max_depth=4,max_leaf_nodes=5,min_samples_split=50)
S_algo.fit(x_train,y_train)
ypred2 = S_algo.predict(x_test)
elif selected_option =='SVM':
S_algo = SVC()
S_algo.fit(x_train,y_train)
ypred3 = S_algo.predict(x_test)
elif selected_option=='KNeighborsClassifier':
S_algo = KNeighborsClassifier()
S_algo.fit(x_train,y_train)
ypred4 = S_algo.predict(x_test)
else:
pass
return S_algo,pipeline
|