coan commited on
Commit
a8a1a0d
1 Parent(s): a4a1fc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -23
app.py CHANGED
@@ -1,28 +1,23 @@
1
  import gradio as gr
2
- from joblib import load
3
- from huggingface_hub import hf_hub_download
4
- import pandas as pd
 
 
5
 
6
- # Baixe o modelo do Hugging Face Hub
7
- model_path = hf_hub_download(
8
- repo_id="coan/botClaiton",
9
- filename="model.pkl",
10
- use_auth_token=True # Caso o repositório seja privado
11
- )
12
 
13
- # Carregue o modelo
14
- model = joblib.load(model_path)
15
 
16
- # Carregar o modelo diretamente do Hugging Face
17
- model_path = hf_hub_download(repo_id="coan/botClaiton", filename="model.joblib")
18
- model = load(model_path)
 
19
 
20
- # Função de previsão
21
- def predict_price(open_price, high_price, low_price, volume):
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()