# -*- coding: utf-8 -*-
"""
Created on Sat May 2 15:45:36 2020
@author: ILQMN
"""
import pandas as pd
from sklearn.model_selection import train_test_split
import numpy as np
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from sklearn.neighbors import KNeighborsClassifier #导入KNN
from sklearn.svm import SVC #导入SVC
from sklearn.tree import DecisionTreeClassifier #导入DT
from vecstack import stacking
#种类,特征向量
names = ['class','chb03_biaozhuncha','chb03_biaozhuncha_d1','chb03_biaozhuncha_d2','chb03_biaozhuncha_d3','chb03_biaozhuncha_d4','chb03_biaozhuncha_d5']
data = pd.read_csv(r'E:\大学\大四学年(2019-2020)\下学期\毕设\数据\CHB-MIT数据集\stacking\标准差\chb03_biaozhuncha.csv',header=None,names=names)
label = data[['class']]
sub_data = data.iloc[:,1:]
sub_data_train,sub_data_test,label_train,label_test = train_test_split(sub_data,label,test_size = 0.2,random_state = 0)
models = [
SVC(C=2.8284,kernel='rbf',degree=3,gamma=22.6274,coef0=0.0,shrinking=True,probability=False,tol=0.001),
KNeighborsClassifier(n_neighbors=9,weights='uniform',algorithm='auto',p=2,metric='minkowski',metric_params=None,radius=None)]
S_train,S_test = stacking(models,
sub_data_train,label_train,sub_data_test,
regression=False,
mode='oof_pred_bag',
needs_proba=False,
save_dir=None,
metric=accuracy_score,
n_folds=5,
stratified=True,
shuffle=True,
random_state=0,
verbose=2
)
#cart算法采用的是 GINI 指数
model = DecisionTreeClassifier(criterion="gini",splitter="best",max_depth=None)
model = model.fit(S_train,label_train)
y_pred = model.predict(S_test)
#计算混淆矩阵的值
senpe = confusion_matrix(label_test,y_pred)
#打印准确度
print('预测结果:[%.8f]' % accuracy_score(label_test,y_pred))
#打印混淆矩阵
print(senpe)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
CHB-MIT数据集.rar (145个子文件)
sampen_chb03_epil_d5.m 8KB
sampen_chb01_epil_d3.m 8KB
sampen_chb01_epil_d4.m 8KB
sampen_chb03_epil_d1.m 8KB
sampen_chb01_epil_d1.m 8KB
sampen_chb03_epil_d4.m 8KB
sampen_chb03_epil_d3.m 8KB
sampen_chb01_epil_d5.m 8KB
sampen_chb03_epil_d2.m 8KB
sampen_chb01_epil_d2.m 8KB
sampen_chb03_nor_d4.m 8KB
sampen_chb01_nor_d4.m 8KB
sampen_chb01_nor_d5.m 8KB
sampen_chb03_nor_d5.m 8KB
sampen_chb03_nor_d1.m 8KB
sampen_chb01_nor_d1.m 8KB
sampen_chb01_nor_d3.m 8KB
sampen_chb03_nor_d3.m 8KB
sampen_chb01_nor_d2.m 8KB
sampen_chb03_nor_d2.m 8KB
std_chb03_epil_d1.m 7KB
std_chb01_epil_d4.m 7KB
std_chb03_epil_d5.m 7KB
std_chb03_epil_d4.m 7KB
std_chb01_epil_d5.m 7KB
std_chb01_epil_d3.m 7KB
std_chb01_epil_d1.m 7KB
std_chb03_epil_d2.m 7KB
std_chb01_epil_d2.m 7KB
std_chb03_epil_d3.m 7KB
std_chb01_nor_d1.m 7KB
std_chb03_nor_d1.m 7KB
std_chb01_nor_d4.m 7KB
std_chb03_nor_d2.m 7KB
std_chb03_nor_d3.m 7KB
std_chb01_nor_d2.m 7KB
std_chb03_nor_d4.m 7KB
std_chb03_nor_d5.m 7KB
std_chb01_nor_d5.m 7KB
std_chb01_nor_d3.m 7KB
chb03_biaozhuncha_multi_attri.m 3KB
chb01_biaozhuncha_multi_attri.m 3KB
sampen_chb01_epil.m 3KB
sampen_chb03_epil.m 3KB
sampen_chb03_nor.m 3KB
sampen_chb01_nor.m 3KB
chb03_biaozhuncha_multi_attri.m 3KB
chb01_biaozhuncha_multi_attri.m 3KB
chb01_biaozhuncha_multi_attri.m 3KB
chb03_biaozhuncha_multi_attri.m 3KB
SVMcg.m 3KB
SVMcg.m 3KB
chb01_sampen_multi_attri.m 2KB
chb01_sampen_multi_attri.m 2KB
chb03_sampen_multi_attri.m 2KB
chb01_sampen_multi_attri.m 2KB
std_chb03_epil.m 2KB
std_chb01_epil.m 2KB
std_chb03_nor.m 2KB
std_chb01_nor.m 2KB
chb01_std_read.m 2KB
chb03_std_read.m 2KB
chb03_sampen_multi_attri.m 2KB
chb03_sampen_read.m 2KB
chb01_sampen_read.m 2KB
chb03_sampen_multi_attri.m 2KB
search_chb01_bestcg.m 2KB
search_chb03_bestcg.m 2KB
chb01_biaozhuncha.m 2KB
chb01_biaozhuncha.m 2KB
chb01_sampen.m 2KB
chb01_sampen.m 2KB
chb03_biaozhuncha.m 2KB
chb01_sampen_d2.m 2KB
chb01_sampen_d3.m 2KB
chb01_sampen_d5.m 2KB
chb03_biaozhuncha.m 2KB
chb01_sampen_d4.m 2KB
chb01_sampen_d4.m 2KB
chb01_sampen_d2.m 2KB
chb01_sampen_d3.m 2KB
chb01_sampen_d5.m 2KB
chb01_biaozhuncha_d2.m 2KB
chb03_biaozhuncha_d5.m 2KB
chb01_biaozhuncha_d5.m 2KB
chb03_biaozhuncha_d2.m 2KB
chb01_biaozhuncha_d1.m 2KB
chb01_biaozhuncha_d3.m 2KB
chb03_biaozhuncha_d1.m 2KB
chb03_biaozhuncha_d4.m 2KB
chb03_sampen.m 2KB
chb01_biaozhuncha_d4.m 2KB
chb03_biaozhuncha_d3.m 2KB
chb01_biaozhuncha_d2.m 2KB
chb03_biaozhuncha_d2.m 2KB
chb03_biaozhuncha_d5.m 2KB
chb01_biaozhuncha_d1.m 2KB
chb01_biaozhuncha_d4.m 2KB
chb01_biaozhuncha_d5.m 2KB
chb03_biaozhuncha_d1.m 2KB
共 145 条
- 1
- 2
资源评论
算法工程师y
- 粉丝: 351
- 资源: 686
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功