コード例 #1
0
ファイル: OpenApi.py プロジェクト: tj0822/Python
                            docList.append(wordList)
                            classList.append(0)
            except:
                continue

        else:
            pass

    vocaList = NaiveBayes.createVocabList(docList)

    trainMat = []
    for postinDoc in docList:
        trainMat.append(NaiveBayes.setOfWords2Vec(vocaList, postinDoc))

    print('vocaList : ', vocaList)
    print('trainMat : ', trainMat)
    print('testEntry : ', testEntry)
    p0V, p1V, pAb = NaiveBayes.trainNB0(array(trainMat), array(classList))

    # testEntry = ['카카오', '인공지능', '알파고']
    thisDoc = array(NaiveBayes.setOfWords2Vec(vocaList, testEntry))
    print(testIssueDate, ' 일자의 ', testTitle, '기사 이후 주가는 ?\n', NaiveBayes.classifyNB(thisDoc, p0V, p1V, pAb))
else:
    print("Error Code:" + rescode)