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

本站现有博文320篇,共被浏览757198

本站已经建立2422天!

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