Exemple #1
0
@author: Winham

# CPSC_hybrid.py: 使用xgboost混合深度学习网络和人工特征,得到最后结果

"""

import os
import numpy as np
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from CPSC_config import Config
import CPSC_utils as utils

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
config = Config()
config.MODEL_PATH = 'E:/CPSC_Scheme/Net_models/'
config.MAN_FEATURE_PATH = 'E:/CPSC_Scheme/Man_features/'

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, _, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from CPSC_config import Config
import CPSC_utils as utils
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
from evaluate_12ECG_score import evaluate_score
os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
config = Config()
config.MODEL_PATH = '/home/zyhk/桌面/CPSC_Scheme-master/model_t/'
config.MAN_FEATURE_PATH = '/home/zyhk/桌面/CPSC_Scheme-master/Man_features/'

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, _, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
Exemple #3
0
import numpy
from driver import dataread,get_classes,getdata_class,load_challenge_data,get_12ECG_features
from evaluate_12ECG_score import evaluate_score
import xgboost as xgb


os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))


os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
warnings.filterwarnings("ignore")
config = Config()
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())


# DATA_PATH= '/home/zyhk/桌面/datanpy/'
# REVISED_LABEL='/home/zyhk/桌面/CPSC_Scheme-master/recordlabel.npy'
# records_name = np.array(os.listdir(DATA_PATH))
# records_label = np.load(REVISED_LABEL) - 1
# class_num = len(np.unique(records_label))

# define 10-fold cross validation test harness
# seed = 7
# numpy.random.seed(seed)
# kfold = StratifiedKFold(n_splits=10, shuffle=True, random_state=seed)
# 取出训练集和测试集病人对应导联信号,并进行切片和z-score标准化 --------------------------------------------------------
Exemple #4
0
import CPSC_utils as utils
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
import tensorflow as tf
from keras import backend as bk

os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
# gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
warnings.filterwarnings("ignore")
config = Config()

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

# 划分训练,验证与测试集 -----------------------------------------------------------------------------------------------
train_val_records, test_records, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)
del test_records, test_labels

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
Exemple #5
0
import os
import warnings
import numpy as np
import tensorflow as tf
from keras import backend as bk
from keras.models import load_model
from keras.utils import to_categorical
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
from CPSC_config import Config
import CPSC_utils as utils

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
warnings.filterwarnings("ignore")
config = Config()
config.MODEL_PATH = 'E:/CPSC_Scheme/Net_models/'

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, test_records, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
    train_val_labels,
from sklearn.model_selection import train_test_split
import numpy as np
from sklearn.metrics import roc_auc_score
from CPSC_config import Config
import CPSC_utils as utils
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
from evaluate_12ECG_score import evaluate_score
os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
config = Config()
config.MODEL_PATH = 'E:/challenge2020/CPSC_Scheme-master/model_t/'
config.MAN_FEATURE_PATH = 'E:/challenge2020/CPSC_Scheme-master/Man_features/'

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, _, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
from keras.utils import to_categorical
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
from CPSC_config import Config
import CPSC_utils as utils

from keras.backend.tensorflow_backend import set_session
os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
warnings.filterwarnings("ignore")
config = Config()
config.MODEL_PATH = '/home/zyhk/桌面/CPSC_Scheme-master/model_t/'

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, test_records, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
    train_val_labels,
Exemple #8
0
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
from CPSC_model import Net1
from CPSC_config import Config
import CPSC_utils as utils

from keras.backend.tensorflow_backend import set_session
os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # 指定GPU

config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # 按需
set_session(tf.Session(config=config))

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
warnings.filterwarnings("ignore")
config = Config()

records_name = np.array(os.listdir(config.DATA_PATH))
records_label = np.load(config.REVISED_LABEL) - 1
class_num = len(np.unique(records_label))

train_val_records, test_records, train_val_labels, test_labels = train_test_split(
    records_name,
    records_label,
    test_size=0.2,
    random_state=config.RANDOM_STATE)
del test_records, test_labels

train_records, val_records, train_labels, val_labels = train_test_split(
    train_val_records,
    train_val_labels,