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

本站现有博文327篇,共被浏览828362

本站已经建立2534天!

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