コード例 #1
0
def testLoadLinksClassifier():
    medMiningObj = MedGraphMining()
    layerObj = NeuralLayerClassifier()
    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    trainLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    testLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_test_links1201-1500.txt'

    storeFilePath = ROOT_PATH.auto_config_root(
    ) + u'model/keras/links(sc2bz)_classifier_cnnlstmT'

    layerModel = layerObj.loadStoredModel(storeFilePath, recompile=True)
    #     print(layerModel.to_json())
    #===========================================================================
    # classes, proba = medMiningObj.testLinksClasses_file(layerModel, gensimModelPath, testLinksDataPath)
    #
    # return classes, proba
    #===========================================================================

    score = medMiningObj.evaluateLinksClassifier_file(layerModel,
                                                      gensimModelPath,
                                                      testLinksDataPath)
    print(score)
コード例 #2
0
def testFindRelatBzFromPatient():
    medMiningObj = MedGraphMining()

    print('load w2v-model from path: ' + medMiningObj.medW2VModelPath)

    ask = '胸闷,气喘,头昏四肢酸,嘴巴没味道,胸口胀气有时还一直打嗝,比以前瞌睡多,肺部没问题,只有点纵膈淋巴结肥大,心率64,去三甲医院看专家科医生说是哮喘,拿了哮喘药也没治到胸口气胀打嗝,还是头昏脚酸的,请问到底是肺部问题还是肠胃,还是心脏的问题?'
    seg_ask = WordSeg('e').singlePosSegEngine(ask)

    confBZRes = medMiningObj.findRelatBzFromPatient(seg_ask, 0.14)
    for bz in confBZRes.keys():
        print(bz + ' '),
        print(confBZRes[bz])

    return confBZRes
コード例 #3
0
def testLoadLinksReps():
    medMiningObj = MedGraphMining()

    trainLinksFilePath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1000.txt'
    textWordsList, maxTextLength, labelList = medMiningObj.loadLinksReps(
        trainLinksFilePath)

    for textWords in textWordsList:
        print(' '.join(textWords))

    print(len(textWordsList))
    print(maxTextLength)
    print(labelList)
コード例 #4
0
def testSaveLinksClassifier():
    medMiningObj = MedGraphMining()
    layerObj = NeuralLayerClassifier()
    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    trainLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    testLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_test_links1201-1500.txt'

    storeFilePath = ROOT_PATH.auto_config_root(
    ) + u'model/keras/links(sc2bz)_classifier_cnnlstmT'

    medMiningObj.trainLinksClassifier_file(gensimModelPath,
                                           trainLinksDataPath,
                                           v_ratio=0.15,
                                           storeFilePath=storeFilePath)
コード例 #5
0
def testEvaluateLinksClassify():
    medMiningObj = MedGraphMining()
    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    trainLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    testLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_test_links1201-1500.txt'

    layerModel = medMiningObj.trainLinksClassifier_file(gensimModelPath,
                                                        trainLinksDataPath,
                                                        v_ratio=0.15)
    score = medMiningObj.evaluateLinksClassifier_file(layerModel,
                                                      gensimModelPath,
                                                      testLinksDataPath)

    print(score)
コード例 #6
0
def testPredictNewLinks():
    medMiningObj = MedGraphMining()
    layerObj = NeuralLayerClassifier()
    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    trainLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    predictLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_predict_links1501-2834.txt'

    storeFilePath = ROOT_PATH.auto_config_root(
    ) + u'model/keras/links(sc2bz)_classifier_cnnlstm'

    layerModel = layerObj.loadStoredModel(storeFilePath, recompile=False)
    classes, proba = medMiningObj.testLinksClasses_file(
        layerModel, gensimModelPath, predictLinksDataPath)

    return classes, proba
コード例 #7
0
def testClassifyLinks():
    medMiningObj = MedGraphMining()
    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    trainLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    testLinksDataPath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_test_links1201-1500.txt'

    layerModel = medMiningObj.trainLinksClassifier_file(
        gensimModelPath, trainLinksDataPath)
    classes, proba = medMiningObj.testLinksClasses_file(
        layerModel, gensimModelPath, testLinksDataPath)

    #     for i in range(len(classes)):
    #         print(str(classes[i]) + ': ' + str(proba[i]))

    return classes, proba
コード例 #8
0
def testLinksRepsToEmbeddingData():
    medMiningObj = MedGraphMining()
    layerObj = NeuralLayerClassifier()

    load_start = time.clock()

    trainLinksFilePath = ROOT_PATH.auto_config_root(
    ) + u'model_cache/relation_learning/shicai2bingzheng_train_links1-1200.txt'
    textWordsList, maxTextLength, labelList = medMiningObj.loadLinksReps(
        trainLinksFilePath)

    gensimModelPath = ROOT_PATH.auto_config_root(
    ) + u'model/word2vec/zongheword2vecModel.vector'
    x_data, y_data = layerObj.preTextEmbeddingProcess(gensimModelPath,
                                                      textWordsList,
                                                      maxTextLength, labelList)

    load_end = time.clock()

    print('load data run time: %f s' % (load_end - load_start))
    print('x_data shape: ', x_data.shape)
    print(x_data)
    print('y_data shape: ', y_data.shape)
    print(y_data)