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

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

本站已经建立2583天!

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