Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,20 @@
|
|
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 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
return f"Modelo treinado e salvo em: {model_filename}"
|
21 |
|
22 |
-
|
23 |
-
iface.launch()
|
|
|
|
|
1 |
from sklearn.datasets import load_iris
|
2 |
from sklearn.model_selection import train_test_split
|
3 |
from sklearn.linear_model import LogisticRegression
|
4 |
from joblib import dump
|
|
|
5 |
|
6 |
+
# Carregar e dividir o dataset
|
7 |
+
data = load_iris()
|
8 |
+
X = data.data
|
9 |
+
y = data.target
|
10 |
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
11 |
|
12 |
+
# Treinando o modelo
|
13 |
+
model = LogisticRegression()
|
14 |
+
model.fit(X_train, y_train)
|
15 |
|
16 |
+
# Salvar o modelo em um arquivo
|
17 |
+
model_filename = "model.pkl"
|
18 |
+
dump(model, model_filename)
|
|
|
19 |
|
20 |
+
print("Modelo treinado e salvo!")
|
|