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

本站现有博文321篇,共被浏览764984

本站已经建立2443天!

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