use crate::error::{NpcError, Result};

pub async fn fit_model(
    data_json: &str,
    model_type: &str,
    target: &str,
    output_path: &str,
) -> Result<String> {
    let _data: serde_json::Value = serde_json::from_str(data_json)
        .map_err(|e| NpcError::Other(format!("Invalid data JSON: {}", e)))?;

    Ok(serde_json::json!({
        "status": "ml_funcs.fit_model requires Python sklearn runtime",
        "model_type": model_type,
        "target": target,
        "output_path": output_path,
        "hint": "Use npcpy for full ML model training"
    })
    .to_string())
}

pub async fn predict_model(model_path: &str, data_json: &str) -> Result<String> {
    let _data: serde_json::Value = serde_json::from_str(data_json)
        .map_err(|e| NpcError::Other(format!("Invalid data JSON: {}", e)))?;

    Ok(serde_json::json!({
        "status": "ml_funcs.predict_model requires Python sklearn runtime",
        "model_path": model_path,
        "hint": "Use npcpy for ML prediction"
    })
    .to_string())
}

pub async fn score_model(model_path: &str, data_json: &str, target: &str) -> Result<f64> {
    let _data: serde_json::Value = serde_json::from_str(data_json)
        .map_err(|e| NpcError::Other(format!("Invalid data JSON: {}", e)))?;
    let _ = (model_path, target);
    Err(NpcError::Other(
        "ml_funcs.score_model requires Python sklearn runtime. Use npcpy.".into(),
    ))
}

pub fn list_models() -> Vec<String> {
    vec![
        "RandomForestClassifier".into(),
        "RandomForestRegressor".into(),
        "LogisticRegression".into(),
        "LinearRegression".into(),
        "GradientBoostingClassifier".into(),
        "GradientBoostingRegressor".into(),
    ]
}

pub async fn ensemble_predict(_data_json: &str, _model_paths: &[&str]) -> Result<String> {
    Err(NpcError::Other(
        "ensemble_predict requires Python sklearn runtime. Use npcpy.".into(),
    ))
}

pub async fn cross_validate(
    _data_json: &str,
    _model_type: &str,
    _target: &str,
    _folds: u32,
) -> Result<String> {
    Err(NpcError::Other(
        "cross_validate requires Python sklearn runtime. Use npcpy.".into(),
    ))
}
