File size: 4,566 Bytes
52dbbac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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)


# Define una funci贸n para hacer predicciones con el modelo
def predecir(features):
    # Procesa los valores de features y hace predicciones con el modelo
    predicciones = modelo.predict(features)
    return predicciones

# 'Unnamed: 0', 'acc_max', 'gyro_max', 'acc_kurtosis', 'gyro_kurtosis',
#        'label', 'lin_max', 'acc_skewness', 'gyro_skewness', 'post_gyro_max',
#        'post_lin_max', 'fall']

# Crea la aplicaci贸n Streamlit
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)

    # with col12:
    #         feature12 =  st.text_input('3')
    # # # Crea los campos de entrada de texto para las features
    # feature1 = st.text_input('Unnamed: 0')
    # feature2 = st.text_input('acc_max')
    # feature3 = st.text_input('gyro_max')
    # feature4 = st.text_input('acc_kurtosis')
    # feature5 = st.text_input('gyro_kurtosis')
    # feature6 = st.text_input('label')
    # feature7 = st.text_input('lin_max')
    # feature8 = st.text_input('acc_skewness')
    # feature9 = st.text_input('gyro_skewness')
    # feature10 = st.text_input('post_gyro_max')
    # feature11 = st.text_input('post_lin_max')

    # Crea un bot贸n para hacer predicciones con el modelo
    if st.button('Predecir'):
        # Convierte los valores de features en un DataFrame de Pandas
        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:
        #     predicciones = 'NO '
        # else:
        #     predicciones = ''
        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)

# Ejecuta la aplicaci贸n Streamlit
if __name__ == '__main__':
    app()