|
import streamlit as st |
|
import pandas as pd |
|
import pickle |
|
|
|
import numpy as np |
|
import pandas as pd |
|
import seaborn as sns |
|
from sklearn.pipeline import Pipeline |
|
from sklearn.pipeline import make_pipeline |
|
|
|
from sklearn.model_selection import GridSearchCV |
|
from sklearn.model_selection import train_test_split |
|
from sklearn.model_selection import GridSearchCV |
|
from sklearn.model_selection import StratifiedKFold |
|
from sklearn.model_selection import cross_val_score |
|
from sklearn.metrics import classification_report |
|
from sklearn.metrics import accuracy_score |
|
from sklearn.base import BaseEstimator, TransformerMixin |
|
from sklearn.preprocessing import StandardScaler |
|
from sklearn.preprocessing import MinMaxScaler |
|
from sklearn.neighbors import KNeighborsClassifier |
|
from sklearn.linear_model import LogisticRegression |
|
from sklearn.ensemble import RandomForestClassifier |
|
from sklearn.ensemble import IsolationForest |
|
from sklearn.tree import DecisionTreeClassifier |
|
|
|
from fs import FeatureSelection |
|
|
|
from xgboost import XGBClassifier |
|
|
|
import warnings |
|
warnings.filterwarnings('ignore') |
|
from sklearn import set_config |
|
set_config(display="diagram") |
|
|
|
|
|
|
|
|
|
with open('mejor_modelo_tp4.pkl', 'rb') as f: |
|
modelo = pickle.load(f) |
|
|
|
|
|
|
|
def predecir(features): |
|
|
|
predicciones = modelo.predict(features) |
|
return predicciones |
|
|
|
|
|
|
|
|
|
|
|
|
|
def app(): |
|
|
|
st.title('Ingrese los valores de las features') |
|
|
|
col1, col2, col3 = st.columns(3) |
|
|
|
with col1: |
|
feature1 = st.text_input('Unnamed: 0', value = 61) |
|
|
|
with col2: |
|
feature2 = st.text_input('acc_max', value = 26.310655) |
|
|
|
with col3: |
|
feature3 = st.text_input('gyro_max', value = 5.192876) |
|
|
|
col4, col5, col6 = st.columns(3) |
|
|
|
with col4: |
|
feature4 = st.text_input('acc_kurtosis', value = 17.569042) |
|
|
|
with col5: |
|
feature5 = st.text_input('gyro_kurtosis', value = 9.776727) |
|
|
|
with col6: |
|
feature6 = st.text_input('label', value = 'FOL') |
|
|
|
col7, col8, col9 = st.columns(3) |
|
|
|
with col7: |
|
feature7 = st.text_input('lin_max', value = 11.584056) |
|
|
|
with col8: |
|
feature8 = st.text_input('acc_skewness', value = 3.587634) |
|
|
|
with col9: |
|
feature9 = st.text_input('gyro_skewness', value = 2.848477) |
|
|
|
col10, col11, col12 = st.columns(3) |
|
|
|
with col10: |
|
feature10 = st.text_input('post_gyro_max', value = 4.691588) |
|
|
|
with col11: |
|
feature11 = st.text_input('post_lin_max', value = 10.684285) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if st.button('Predecir'): |
|
|
|
features = pd.DataFrame({ |
|
'Unnamed: 0': [feature1], |
|
'acc_max': [feature2], |
|
'gyro_max': [feature3], |
|
'acc_kurtosis': [feature4], |
|
'gyro_kurtosis': [feature5], |
|
'label': [feature6], |
|
'lin_max': [feature7], |
|
'acc_skewness': [feature8], |
|
'gyro_skewness': [feature9], |
|
'post_gyro_max': [feature10], |
|
'post_lin_max': [feature11], |
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if predecir(features) == [0]: |
|
respuesta = ' NO ' |
|
else: |
|
respuesta = ' SI ' |
|
st.write(f'Estos datos {respuesta}son compatibles con una ca铆da') |
|
|
|
if st.button('Modelo'): |
|
|
|
st.write(modelo.named_steps) |
|
|
|
|
|
if __name__ == '__main__': |
|
app() |
|
|