Spaces:
Runtime error
Runtime error
File size: 943 Bytes
fd90d18 3a37b43 fd90d18 3a37b43 fd90d18 c2493db fd90d18 a4a1fc8 fd90d18 a4a1fc8 fd90d18 c2493db fd90d18 |
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 |
import gradio as gr
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from joblib import dump
import os
def train_model():
# Carregar e dividir o dataset
data = load_iris()
X = data.data
y = data.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Treinando o modelo
model = LogisticRegression()
model.fit(X_train, y_train)
# Criar diretório para salvar o modelo
diretorio = "/mnt/data"
os.makedirs(diretorio, exist_ok=True)
# Salvar o modelo em /mnt/data/
model_filename = os.path.join(diretorio, "model.pkl")
dump(model, model_filename)
return f"Modelo treinado e salvo em: {model_filename}"
# Inicialize a interface Gradio
iface = gr.Interface(fn=train_model, inputs=[], outputs=["text"])
# Inicie a aplicação
iface.launch()
|