BayesWitnesses / m2cgen

Transform ML models into a native code (Java, C, Python, Go, JavaScript, Visual Basic, C#, R, PowerShell, PHP, Dart, Haskell, Ruby, F#, Rust) with zero dependencies
MIT License
2.8k stars 241 forks source link

XGBoost exported to C generates wrong indices for input array #584

Open vladBaciu opened 1 year ago

vladBaciu commented 1 year ago

As the title says, seems that there is an issue when generating a XGBoost to C:

For instance f100 should have been just 100, otherwise the compilation fails.

void predict(double * input, double * output) {
    double var0;
    if ((input[f100]) >= (0.9064144)) {
        if ((input[f116]) >= (1.9821854)) {
            if ((input[f17]) >= (0.3522055)) {
                if ((input[f1]) >= (0.96535176)) {
                    var0 = 0.04736842;
                } else {
                    var0 = -0.17782988;
                }
            } else {
                var0 = 0.5538461;
            }
        } else {