

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Processore framework XGBoost
<a name="processing-job-frameworks-xgboost"></a>

XGBoost è un framework di machine learning open source. L'`XGBoostProcessor`SDK Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con script XGBoost. Quando utilizzi XGBoostProcessor, puoi sfruttare un contenitore Amazon-built Docker con un ambiente XGBoost gestito in modo da non dover portare il tuo contenitore.

Il seguente esempio di codice mostra come utilizzare il `XGBoostProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

```
from sagemaker.xgboost import XGBoostProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the XGBoostProcessor
xgb = XGBoostProcessor(
    framework_version='1.2-2',
    role=get_execution_role(),
    instance_type='ml.m5.xlarge',
    instance_count=1,
    base_job_name='frameworkprocessor-XGB',
)

#Run the processing job
xgb.run(
    code='{{processing-script.py}}',
    source_dir='{{scripts}}',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f'{{s3://{BUCKET}/{S3_INPUT_PATH}}}',
            destination='/opt/ml/processing/input/data'
        )
    ],
    outputs=[
        ProcessingOutput(
            output_name='processed_data',
            source='/opt/ml/processing/output/',
            destination=f'{{s3://{BUCKET}/{S3_OUTPUT_PATH}}}'
        )
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `XGBoostProcessor` classe, consulta [XGBoost Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/xgboost/xgboost.html) nell'SDK Amazon *Python SageMaker *.