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

本站现有博文333篇,共被浏览922196

本站已经建立2628天!

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