Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
)
|
12 |
|
13 |
-
|
14 |
-
model
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
# Criar um dataframe com os dados de entrada
|
23 |
-
data = pd.DataFrame({
|
24 |
-
"Open": [open_price],
|
25 |
-
"High": [high_price],
|
26 |
-
"Low": [low_price],
|
27 |
-
"Volume": [volume],
|
28 |
-
})
|
|
|
1 |
import gradio as gr
|
2 |
+
from sklearn.datasets import load_iris
|
3 |
+
from sklearn.model_selection import train_test_split
|
4 |
+
from sklearn.linear_model import LogisticRegression
|
5 |
+
from joblib import dump
|
6 |
+
import os
|
7 |
|
8 |
+
def train_model():
|
9 |
+
data = load_iris()
|
10 |
+
X = data.data
|
11 |
+
y = data.target
|
12 |
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
|
13 |
|
14 |
+
model = LogisticRegression()
|
15 |
+
model.fit(X_train, y_train)
|
16 |
|
17 |
+
model_filename = "/mnt/data/model.pkl"
|
18 |
+
dump(model, model_filename)
|
19 |
+
|
20 |
+
return f"Modelo treinado e salvo em: {model_filename}"
|
21 |
|
22 |
+
iface = gr.Interface(fn=train_model, inputs=[], outputs=["text"])
|
23 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|