# Fix "Parameters: { use_label_encoder } are not used" Warning in XGBoost

Yes. An agent traces use_label_encoder from the release that needed it to the one that ignores it, removes it from your classifier, pins XGBoost and adds a fit test.

[Run this on Rush](https://cloud.getrush.ai/run/fix-parameters-use-label-encoder-are-not-used-warning/xgboost/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

`use_label_encoder=False` was the recommended way to silence a warning in XGBoost 1.3 to 1.5, and it has outlived the warning. On a fresh install today, which resolves xgboost 3.2.0, fitting an `XGBClassifier` built with that argument prints `UserWarning: WARNING: src/learner.cc:782: Parameters: { "use_label_encoder" } are not used.` from `xgboost/training.py`, because the scikit-learn wrapper no longer knows the name and passes it to the booster, which ignores it. The model trains and predicts; the line appears on every fit and in every log, and a test suite that turns warnings into errors fails on it.

In a Flask service like Fahed1401/Fraud-Detection-UPI-ChatBot, `requirements.txt` lists `flask`, `pandas`, `numpy`, `scikit-learn` and `xgboost` with no versions. `app.py` generates 20,000 synthetic transactions with `generate_transactions`, derives `Amount (INR)` and `Hour` as features, fits an `IsolationForest` and a `OneClassSVM`, labels amounts over 8,000 as fraud, selects features with `SelectKBest`, and on lines 50 to 59 builds `XGBClassifier(use_label_encoder=False, eval_metric='logloss', n_estimators=100, max_depth=3, learning_rate=0.05, scale_pos_weight=20, min_child_weight=5, random_state=42)` before fitting it. The `/api/check_fraud` route then votes across the three models for each request. The labels are already integers 0 and 1 from `astype(int)`, so the encoder the argument refers to was never involved.

The agent reproduces the warning on the fresh install, then walks the argument's history in a second environment with NumPy 1 and setuptools pinned so older wheels import: on 1.5.2 a classifier built without the argument prints `The use of label encoder in XGBClassifier is deprecated and will be removed in a future release` and tells you to pass `use_label_encoder=False` and encode labels from 0, which is the advice the code followed; on 1.6.2 the argument is accepted silently either way; on 1.7.6 it prints `use_label_encoder is deprecated in 1.7.0`; on 2.0.3 it is silent again; and on 3.2.0 it is the unknown-parameter line above. That table is what the pull request leads with, so a reviewer sees the argument has done nothing since 1.6.

The change is to delete the argument and keep the rest: `eval_metric='logloss'` stays, since the wrapper still takes it, and the labels stay integers. `requirements.txt` pins `xgboost>=1.6` as the lower bound below which the argument would be needed again, with the other packages left as they are. A test builds a small frame the way `train_models` does, fits the classifier inside `warnings.catch_warnings(record=True)` and asserts that no recorded warning mentions `use_label_encoder`, so the next deprecation of a constructor argument surfaces as a failure rather than a log line. The service is started once with `flask run` and the fraud route is called with one transaction to show the vote still answers.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "This service prints Parameters: { use_label_encoder } are not used every time the XGBoost classifier is fitted. In a clean virtual environment, install requirements.txt, report the resolved xgboost, scikit-learn, numpy and pandas versions, and reproduce the warning by fitting the classifier as the code builds it on a small frame. In a second environment with numpy below 2 and setuptools pinned below 81, install xgboost 1.5, 1.6, 1.7 and 2.0 in turn and record what each prints when the classifier is built with and without use_label_encoder, so the pull request shows when the argument stopped doing anything. Remove the argument from every XGBClassifier and XGBRegressor call, keep eval_metric and the other parameters, and check that the labels are integers starting at 0. Pin xgboost in requirements.txt to the lowest release where the argument is unnecessary. Add a test that fits the classifier on a small frame under warnings.catch_warnings and asserts no warning mentions use_label_encoder. Start the app once and call the fraud-check route with a sample transaction to show it still answers. Open a pull request with the version table, the test run and the route's response.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that changes the training code, `requirements.txt` and a new test file. The description opens with the version table: five XGBoost releases, what each prints with and without the argument, and the resolved versions of the fresh install. A reviewer sees in one glance that the argument was needed on 1.5, inert on 1.6, deprecated on 1.7 and unknown on 3.x.

Below it is the list of constructor calls that lost the argument, with file and line, the test output, and the JSON the fraud route returned for the sample transaction. The session's record keeps every install and fit with its warnings, so the table can be checked against the raw output.

Before merging, a reviewer checks that the pinned lower bound agrees with the deployment image, that no notebook or script outside the service still passes the argument, and that the test's small frame exercises the same feature selection the real training path uses.

## Run it on every Dependabot pull request for xgboost

The warning changes its wording with the release, so the useful moment is each XGBoost bump. A bot sender never fires an automation's `github` trigger, so give the automation a `webhook` trigger and add a workflow step on the bump that runs when its title names xgboost and posts the pull request number to the trigger's URL with `Authorization: Bearer` and the trigger's secret; the event lands after the prompt, and the run fits the classifier on the release in that pull request's lockfile, reports any constructor argument the new release no longer knows, and pushes the fix onto the same branch or opens its own.

From your own server the same request goes to `POST /o/{org}/sessions` with the repository in `resources`. Give it a `request_id` that is a UUID v5 of the pull request number, so a retried delivery returns the run that already started instead of opening a second pull request.

## Why run it on Rush?

Deleting one keyword is trivial; knowing it is safe on every release your team might install is not. The proof here is five XGBoost versions in two environments, one of them with NumPy 1 and an old setuptools because the older wheels do not import otherwise, each fitted twice and its warnings recorded. In a Rush sandbox the agent builds those environments on its own disk and keeps the output, and the machine is gone when the run ends.

What comes back is a table with the raw warnings behind it, not a sentence that says the argument is deprecated. A team with several models on the same template starts one run per repository with the same request, up to the key's `max_concurrent` limit at once, and the rest queue.

## Frequently asked questions

### Is the warning harmful, or just noise?

The model trains and predicts the same with or without the argument on 3.2.0; the booster ignores a parameter it does not know. The cost is a line on every fit and a failing suite anywhere warnings are errors, and the risk is that the same habit hides a parameter that does matter. Removing it is the whole fix.

### Why was use_label_encoder=False added in the first place?

Because XGBoost 1.3 to 1.5 warned on every fit that the built-in label encoder was going away and told users to pass exactly that argument and encode labels from 0. The example's labels were already integers, so the argument only silenced the notice. From 1.6 the encoder was gone and the argument stopped doing anything.

### Should I keep eval_metric='logloss'?

Yes. The scikit-learn wrapper still takes `eval_metric` on 3.2.0, and the agent keeps it along with every other parameter on the call. The pull request removes one keyword and changes nothing about how the model is trained or scored.

### What does the lower bound in requirements.txt do?

It stops an install from landing on a release that would warn without the argument. The agent pins `xgboost>=1.6`, the first line where the argument is unnecessary, and leaves the upper end open so the next bump is still a bump and not a pin to argue about.

### Will the agent retrain on my data?

It fits on a small frame built the way the training function builds its own, and in the example on the synthetic transactions the service generates itself. It does not touch production data or a trained model artifact; the one route call at the end uses a sample transaction and is there to show the vote still answers.

## More jobs like this: Fix a bug from an alert

- [Fix "Passing null to parameter of type string is deprecated" on PHP 8.1 and later](https://getrush.ai/run/fix-passing-null-to-parameter-deprecated/php/)
- [Fix "Error: pg_config executable not found" When Installing psycopg2](https://getrush.ai/run/fix-pg-config-executable-not-found/psycopg2/)
- [Fix "module 'PIL.Image' has no attribute 'ANTIALIAS'" After a Pillow Upgrade](https://getrush.ai/run/fix-pil-image-antialias-error/pillow/)
- [Fix 'The option "--no-dev" does not exist' After pip install poetry Picks Up Poetry 2](https://getrush.ai/run/fix-poetry-no-dev-option-does-not-exist/poetry/)
- [Fix Angular Exceptions From PostHog Error Tracking](https://getrush.ai/run/fix-posthog-exceptions/angular/)
- [Fix Django Exceptions From PostHog Error Tracking](https://getrush.ai/run/fix-posthog-exceptions/django/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
