import pandas as pd
from kpi_impact_sim.preprocessing import preprocess_dataframe
from kpi_impact_sim.ridge_model import fit_ridge_model
from kpi_impact_sim.simulate import apply_simulation
from kpi_impact_sim.utils import tipo_variable

# 🔹 1. Cargar data de ejemplo
df = pd.read_csv("demo_data.csv")
df.head()

# 🔹 2. Preprocesar
df_proc = preprocess_dataframe(df)
df_num = df_proc.select_dtypes(include="number")

target = "contacto_efectivo/contacto"
X = df_num.drop(columns=[target])
y = df_num[target]

# 🔹 3. Entrenar modelo
res = fit_ridge_model(X, y)
res["coefs"]

# 🔹 4. Simulación
sim = apply_simulation(
    res["coefs"],
    df_num,
    target,
    incremento_pts=2,
    tipo_variable_func=tipo_variable,
    save_path="simulacion_demo.csv"
)

sim["candidates"].head(10)




