大家好,我是小k,好久没写博客了,从五月份开始接触机器学习,经过了一段时间沉淀,在11月份第一次参加了意义上的大数据比赛,下面想对这次比赛学习到的东西做个总结QAQ。
比赛地址传送门:
1:导入相应包与数据
import seaborn as sns
import lightgbm as lgb
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
from sklearn.model_selection import KFold
from catboost import CatBoostClassifier, Pool
from sklearn.metrics import mean_squared_error, f1_score, accuracy_score
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import train_test_split
train = pd.read_excel(r'C:\Users\wzk\Desktop\train.xlsx')
test = pd.read_excel(r'C:\Users\wzk\Desktop\predict.xlsx')
df_features = train.append(test)
2:观察数据集
#检查数据各列的缺失占比情况
df1 = (train.shape[0] - train.count())/train.shape[0]
df1[0:20]
唯一标识 0.000000
flag 0.000000
总评分 0.000000
住院号 0.000000
住院次数 0.000000
性别 0.000000
民族 0.000000
身高 0.000000
体重 0.004243
心率 0.000542
呼吸 0.002167
收缩压 0.001083
舒张压 0.001806
诊断 0.000000
3P试验 0.981943
C反应蛋白 0.939689
D-二聚体 0.213344
α-淀粉酶 0.972824
α-羟丁酸脱氢酶 0.740339
α羟丁酸脱氢酶 0.803720
dtype: float64
#检查数据类型 int/float/object
df_features.select_dtypes(include=['int']).columns
Index(['住院次数'], dtype='object')
df_features.select_dtypes(include=['float']).columns
Index(['flag', '总评分', '心率', '呼吸', '收缩压', '舒张压', 'D-二聚体', 'α-淀粉酶', 'α-羟丁酸脱氢酶',
'β2-微球蛋白', '不饱和铁结合力', '凝血酶原时间比率', '凝血酶原时间活动度', '国际标准化比率', '尿酸', '总胆红素',
'总蛋白', '总铁结合力', '果糖胺', '氯', '球蛋白', '白球比', '白蛋白', '直接胆红素'