EstebanDC commited on
Commit
ef468f4
1 Parent(s): 9409cfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,42 +1,37 @@
1
- # Cargamos librerías
2
  import pickle
3
  import numpy as np
4
  import gradio as gr
5
- #import sklearn
6
  import pandas as pd
7
  from sklearn.model_selection import train_test_split
8
  from sklearn.ensemble import ExtraTreesRegressor
9
 
10
- # You can use this block to train and save a model.
11
-
12
-
13
- # Load the data
14
  filename = 'Dataset_RCS_3.csv'
15
  names0 = ['JET', "Suelo",'SPT', 'WtoC', 'Presion', 'Velocidad','RCS']
16
  dataset=pd.read_csv(filename, names=names0)
17
- # Dividimos el dataset en entrenamiento y test
18
  y = dataset['RCS']
19
  X = dataset.drop('RCS', axis=1)
20
- # Categorical data
21
  categorical_cols = ['JET', "Suelo"]
22
  df = pd.get_dummies(X, columns = categorical_cols)
23
 
24
- # Split the data into training and testing sets
25
  validation_size = 0.20
26
  seed = 10
27
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=validation_size, random_state=seed)
28
 
29
- # Train the model
30
  modelodef=ExtraTreesRegressor(
31
  n_estimators=1000,
32
  max_depth=9,
33
  min_samples_leaf=1,
34
  random_state=seed)
35
  modelodef.fit(X_train, y_train)
36
- # Save the model
37
  pickle.dump(modelodef, open("modelodef.pkl", "wb"))
38
 
39
- #create a function for gradio
40
  def RCS(JET, Suelo,SPT, WtoC, Presion, Velocidad):
41
  modelodef = pickle.load(open("modelodef.pkl", "rb"))
42
  prediction0 = modelodef.predict([[JET, Suelo,SPT, WtoC, Presion, Velocidad]])
 
 
1
  import pickle
2
  import numpy as np
3
  import gradio as gr
4
+ import sklearn
5
  import pandas as pd
6
  from sklearn.model_selection import train_test_split
7
  from sklearn.ensemble import ExtraTreesRegressor
8
 
 
 
 
 
9
  filename = 'Dataset_RCS_3.csv'
10
  names0 = ['JET', "Suelo",'SPT', 'WtoC', 'Presion', 'Velocidad','RCS']
11
  dataset=pd.read_csv(filename, names=names0)
12
+
13
  y = dataset['RCS']
14
  X = dataset.drop('RCS', axis=1)
15
+
16
  categorical_cols = ['JET', "Suelo"]
17
  df = pd.get_dummies(X, columns = categorical_cols)
18
 
19
+
20
  validation_size = 0.20
21
  seed = 10
22
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=validation_size, random_state=seed)
23
 
24
+
25
  modelodef=ExtraTreesRegressor(
26
  n_estimators=1000,
27
  max_depth=9,
28
  min_samples_leaf=1,
29
  random_state=seed)
30
  modelodef.fit(X_train, y_train)
31
+
32
  pickle.dump(modelodef, open("modelodef.pkl", "wb"))
33
 
34
+
35
  def RCS(JET, Suelo,SPT, WtoC, Presion, Velocidad):
36
  modelodef = pickle.load(open("modelodef.pkl", "rb"))
37
  prediction0 = modelodef.predict([[JET, Suelo,SPT, WtoC, Presion, Velocidad]])