<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
import xgboost as xgb
#Create a data frame
df = pd.DataFrame(
    [[1, 2, 0], [3, 4, 1], [5, 6, 0], [7, 8, 1]],
    columns=["num", "amount", "target"]
)

#Create xgboost data matrix from df
df_xgb = xgb.DMatrix(
    df[["num", "amount"]], label=df["target"]
)

#Train model with binary classification params
params = {"eval_metric": "logloss", "objective": "binary:hinge"}
bst = xgb.train(params, df_xgb)

#Predict target values from feature matrix
bst.predict(df_xgb)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16548042704626334, 'fraction_numerical': 0.021352313167259787, 'mean_word_length': 5.546511627906977, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '419059', 'license': 'Apache-2.0', 'n_tokens_mistral': 224, 'n_tokens_neox': 212, 'n_words': 61, 'path': 'XGBoost_simple_example.ipynb', 'repo_name': 'EnsiyehRaoufi/ML_Models_Linear_treebased_XGBoost__AutoGluon', 'size': '562'}