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

本站现有博文332篇,共被浏览875421

本站已经建立2583天!

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