|
|
|
import pickle |
|
import gradio as gr |
|
import sklearn |
|
import pandas as pd |
|
from sklearn.model_selection import train_test_split |
|
from sklearn.ensemble import ExtraTreesRegressor |
|
|
|
|
|
|
|
|
|
|
|
filename = 'Dataset_RCS_3.csv' |
|
names0 = ['JET', "Suelo",'SPT', 'WtoC', 'Presion', 'Velocidad','RCS'] |
|
dataset=pd.read_csv(filename, names=names0) |
|
|
|
y = dataset['RCS'] |
|
X = dataset.drop('RCS', axis=1) |
|
|
|
categorical_cols = ['JET', "Suelo"] |
|
df = pd.get_dummies(X, columns = categorical_cols) |
|
|
|
|
|
validation_size = 0.20 |
|
seed = 10 |
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=validation_size, random_state=seed) |
|
|
|
|
|
modelodef=ExtraTreesRegressor( |
|
n_estimators=1000, |
|
max_depth=9, |
|
min_samples_leaf=1, |
|
random_state=seed) |
|
modelodef.fit(X_train, y_train) |
|
|
|
pickle.dump(modelodef, open("modelodef.pkl", "wb")) |
|
|
|
|
|
def RCS(JET, Suelo,SPT, WtoC, Presion, Velocidad): |
|
modelodef = pickle.load(open("modelodef.pkl", "rb")) |
|
prediction = modelodef.predict([[JET, Suelo,SPT, WtoC, Presion, Velocidad]]) |
|
return prediction |
|
|
|
|
|
app = gr.Interface( |
|
RCS, |
|
inputs=[ |
|
gr.inputs.Textbox( |
|
lines=2, |
|
label="Pregúntame sobre BioMedicina o temas relacionados. Puedes simplemente preguntarme aquí y darle al botón verde de abajo que pone Enviar.", |
|
placeholder="Escribe aquí tu pregunta", |
|
optional=True,), |
|
gr.inputs.Radio(['1', '2', '3'], label="Jet system: 1=Single. 2=Double. 3=Triple"), |
|
gr.inputs.Radio(['1', '2', '3', '4'], label="Soil type: 1=Coarse without fines. 2=Coarse with fines. 3=Fine. 4=Organic"), |
|
gr.Number(value=1, label="Nspt"), |
|
gr.Number(value=1, label="W/C"), |
|
gr.Number(value=1, label="Grout pressure (MPa)"), |
|
gr.Number(value=1, label="Rotation speed (rpm)"), |
|
], |
|
outputs=[gr.Text(label="UCS (MPa)")], |
|
) |
|
|
|
app.launch() |