當前位置: 首頁>>代碼示例>>Python>>正文


Python Classifier.reduce方法代碼示例

本文整理匯總了Python中Classifier.Classifier.reduce方法的典型用法代碼示例。如果您正苦於以下問題:Python Classifier.reduce方法的具體用法?Python Classifier.reduce怎麽用?Python Classifier.reduce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Classifier.Classifier的用法示例。


在下文中一共展示了Classifier.reduce方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from Classifier import Classifier [as 別名]
# 或者: from Classifier.Classifier import reduce [as 別名]

#.........這裏部分代碼省略.........
                lo = 0
            else:
                lo = charEnds[i-1]

            rowColBinList = em.getAveragedEpochs(hi,lo,isiList,maxSets)
            finalDataArray = rowColBinList
            classMarks = self.prepairTargetArray(self.getCharIndexes(self.targetLetters[i]))

            if self.firsttrain == 1:
                self.cl.learn(finalDataArray,classMarks,0)
                self.firsttrain = 0
            else:
                self.cl.learn(finalDataArray,classMarks)

    # Metoda hada cielove znaky a updatuje pouzivatelske rozhranie
    def guessChars(self,subset,files,targetLetter,testProgress,progTestLabel,guessView,guessLab,maxSets):
        aktCharNum = 0
        totalChars = len(sum(targetLetter,[]))

        if self.chanNum != 64:
            files.sort()
            files = self.createTriplets(files)


        for m in range(len(files)):
            # nacitanie a predspracovanie signalu
            signalLoader = SignalLoader(self.chanNum,files[m])
            prpr = Preprocessor(self.chanNum,subset)
            signal, stimCode, phaseInSequence = signalLoader.loadSignal()
            self.signal = prpr.preprocess(240,1E-1,30E0,self.sf,signal,stimCode,phaseInSequence,1)
            self.stimulusCode = prpr.stimulusCode
            self.phaseInSequence = prpr.phaseInSequence
            if (len(targetLetter) > m):
                self.targetLetters = targetLetter[m]
            else:
                self.targetLetters = []
            print "Processing file:",m,"\n"

            # najdenie prechodov medzi znakmi
            charEnds = self.findCharEnds()

            # rozdelenie dat do epoch
            em = EpochManager(self.signal,self.stimulusCode,self.phaseInSequence)
            isiList = em.createEpochs()

            hit = 0
            # hadanie jednotlivych znakov
            for i in range(len(charEnds)):
                testProgress["value"] = aktCharNum
                progTestLabel["text"] = ("Hádam znak: {}/{}").format(aktCharNum+1, totalChars)
                aktCharNum +=1

                hi = charEnds[i]
                if i == 0:
                    lo = 0
                else:
                    lo = charEnds[i-1]

                rowColBinList = em.getAveragedEpochs(hi,lo,isiList,maxSets)
                finalDataArray = self.prepairSignalArray(self.sf.grandAveragingFilter(rowColBinList,subset,1))

                #pomocou klasifikatora
                char = self.cl.predictTarget(finalDataArray,self.cl.reduce(self.sf,self,subset))

                if len(self.targetLetters) > i:
                    if char == self.targetLetters[i]:
                        hit+=1
                        print "Succesfully guessed char:",char,"\n"
                    else:
                        print "Guessed char:",char,"\n"


                if i == 0:
                    text = "(" + char + ","
                elif i == len(charEnds) - 1:
                    text = char + ")"
                else:
                    text = char + ","

                guessView.configure(state='normal')
                guessView.insert(INSERT, text)
                guessView.configure(state='disabled')

            self.rate += (hit)*100/float(totalChars)
            print "\n Success rate= ",self.rate, "\n"
            guessLab["text"]=("Presnosť: {}").format(self.rate)

        return self.rate

    # Pomocna funkcia pre spracovanie csv suborov epoc dat
    def createTriplets(self, epocFiles):
        triplets = []
        for i in range(len(epocFiles)/3):
            triplet = []
            triplet.append(epocFiles[i])
            triplet.append(epocFiles[i+len(epocFiles)/3])
            triplet.append(epocFiles[i+2*len(epocFiles)/3])
            triplets.append(triplet)

        return triplets
開發者ID:BergiSK,項目名稱:Bakalarka,代碼行數:104,代碼來源:Processor.py


注:本文中的Classifier.Classifier.reduce方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。