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

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

本站已经建立2538天!

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