EADST

Train XGBoost Model with Pandas Input

Train XGBoost Model with Pandas Input

import warnings
warnings.filterwarnings("ignore")
import pandas as pd
import numpy as np
import xgboost as xgb
from sklearn.metrics import classification_report

train=pd.read_csv('./train.csv')
test=pd.read_csv('./test.csv')


info=pd.read_csv('info.csv')
print(info.head()) # column name
print(info.shape)
new_info = info.drop_duplicates(subset=['id']) # remove duplicate row with same id
train2=pd.merge(train, new_info[['id', 'number']], how='left', on='id').fillna(0) # merge table horizontally

train_y=train2['result']
train_x=train2.drop(columns=['uaid','result','others'])
test_id = test['id']
test_y=test['result']
test_x=test.drop(columns=['uaid','result','others'])


model = xgb.XGBClassifier()
model.fit(train_x, train_y)
train_predict_y = model.predict(train_x)
print(classification_report(train_y, train_predict_y))


result=model.predict_proba(test_x)
result=pd.concat([test_y,pd.DataFrame(result)],axis=1)
result.to_csv('./test_result.csv')
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
算法题 XGBoost torchinfo 关于博主 InvalidArgumentError Translation NameSilo Paper Food Attention FP8 DeepSeek tqdm Shortcut 报税 Disk News Input Website 腾讯云 C++ SVR Plate Quantization Knowledge printf ModelScope PyCharm Plotly Pytorch Firewall BF16 OCR Proxy FP16 EXCEL 搞笑 Claude CSV RL TensorRT JSON 飞书 tar AI ONNX Django Docker HuggingFace TensorFlow Paddle MD5 Heatmap Google Freesound icon NLP 继承 ChatGPT VGG-16 Pillow ResNet-50 Algorithm scipy hf Cloudreve Land CEIR PDB GIT v2ray LaTeX Random LoRA IndexTTS2 CC git Data Zip DeepStream Statistics SPIE CV Bert Bitcoin GPTQ Sklearn Conda API Interview Numpy CTC Mixtral FlashAttention Bin XML SQL 多进程 BTC Github TTS Logo CLAP CAM Search Tensor Pandas Ptyhon Vim Augmentation 阿里云 Hilton LLAMA Animate v0.dev VPN Web 签证 第一性原理 WebCrawler PIP Michelin QWEN 图标 COCO Clash llama.cpp logger TSV GoogLeNet Anaconda 域名 SQLite 证件照 PDF mmap Color Bipartite GPT4 LLM Agent Pickle Base64 Template Jetson HaggingFace Crawler NLTK Harness Llama Python OpenAI 云服务器 Qwen Qwen2.5 版权 Datetime BeautifulSoup GGML Qwen2 PyTorch FP64 YOLO Git FastAPI Gemma Tracking CUDA RAR Diagram 财报 Jev Quantize Transformers ms-swift Dataset Vmess Permission Markdown Baidu Ubuntu Image2Text 递归学习法 Breakpoint Windows Excel 多线程 论文速读 Password Jupyter 顶会 Rebuttal Tiktoken API网关 公式 Use git-lfs LeetCode Video Hotel RGB 论文 Safetensors VSCode 强化学习 uWSGI FP32 WAN Miniforge uwsgi Linux Review 音频 Card Hungarian Distillation 图形思考法 Nginx 净利润 SAM Domain transformers Streamlit diffusers UNIX Math UI OpenCV Magnet
站点统计

本站现有博文337篇,共被浏览961523次

本站已经建立2673天!

热门文章
文章归档
回到顶部