python类ICON_INFORMATION的实例源码

pySIMsms.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def OnPopupDeleteAll(self, event):
        dlg = wxskinMessageDialog(self, self.delete_confirm_text,
                              'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION)
        ret = dlg.ShowModal()
        dlg.Destroy()
        if ret == wx.ID_YES:

            dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            try:
                self.SIM.gotoFile(SMS_FILE_PATH)
                i = 1
                for key in self.itemDataMap.keys()[:]:   # Make a copy of key table!!
                    if not dlg.Update(i):
                        break
                    self.writeSMSEntry(key)
                    del self.itemDataMap[key]
                    i += 1
            except:
                print_exc()
                pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error")

            dlg.Destroy()
            self.UpdateView()

    # Override the column sorting function. We need to compare 'a' and 'A' as equal
designer.py 文件源码 项目:tindieorderprintout 作者: limpkin 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def do_input(Class, parent, title, fields, data):
        dlg = Class(parent, -1, title, size=(350, 200),
                         style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX,
                        fields=fields, data=data
                         )
        dlg.CenterOnScreen()
        while 1:
            val = dlg.ShowModal()
            if val == wx.ID_OK:
                values = {}
                for field in fields:
                    try:
                        values[field] = eval(dlg.textctrls[field].GetValue())
                    except Exception, e:
                        msg = wx.MessageDialog(parent, unicode(e),
                               "Error in field %s" % field,
                               wx.OK | wx.ICON_INFORMATION
                               )
                        msg.ShowModal()
                        msg.Destroy()
                        break
                else:
                    return dict([(field, values[field]) for field in fields])
            else:
                return None
mentaltasks.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 56 收藏 0 点赞 0 评论 0
def afterTest(self, earlyStop):
        if not earlyStop:
            self.saveCap()
            ca = np.mean(np.diag(self.confusion))/self.nTestTrial
            confusion = np.round(100*self.confusion/self.nTestTrial)

            resultText = (('Test Selection CA: %f\n' % ca) +
                          ('Confusion Matrix:\n' + str(confusion) + '\n') +
                          ('Choices: ' + str(self.choices)))

            wx.MessageBox(message=resultText,
                          caption='Testing Complete',
                          style=wx.OK | wx.ICON_INFORMATION)

            self.saveResultText(resultText)
        else:
            self.pieMenu.zeroBars(refresh=False)
            self.pieMenu.clearAllHighlights()
config_camera.py 文件源码 项目:Pigrow 作者: Pragmatismo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def list_fs_ctrls_click(self, e):
        print("this is supposed to fswebcam -d v4l2:/dev/video0 --list-controls on the pi")
        target_ip = self.tb_ip.GetValue()
        target_user = self.tb_user.GetValue()
        target_pass = self.tb_pass.GetValue()
        try:
            ssh.connect(target_ip, username=target_user, password=target_pass, timeout=3)
            print "Connected to " + target_ip
            found_login = True
            cam_choice = self.cam_select_cb.GetValue()
            cam_cmd = "fswebcam -d v4l2:" + cam_choice + " --list-controls"
            print("---Doing: " + cam_cmd)
            stdin, stdout, stderr = ssh.exec_command(cam_cmd)
            cam_output = stderr.read().strip()
            print "Camera output; " + cam_output
            ssh.close()
        except Exception as e:
            print("Some form of problem; " + str(e))
            ssh.close()
        if not cam_output == None:
            msg_text = 'Camera located and interorgated; copy-paste a controll name from the following into the settings text box \n \n'
            msg_text += str(cam_output)
            wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
pigrow_remote.py 文件源码 项目:Pigrow 作者: Pragmatismo 项目源码 文件源码 阅读 74 收藏 0 点赞 0 评论 0
def cat_script(self, e):
        #opens an ssh pipe and runs a cat command to get the text of the script
        target_ip = pi_link_pnl.target_ip
        target_user = pi_link_pnl.target_user
        target_pass = pi_link_pnl.target_pass
        script_path = self.cron_path_combo.GetValue()
        script_name = self.cron_script_cb.GetValue()
        script_to_ask = script_path + script_name
        try:
        #    ssh.connect(target_ip, username=target_user, password=target_pass, timeout=3)
            print "Connected to " + target_ip
            print("running; cat " + str(script_to_ask))
            stdin, stdout, stderr = ssh.exec_command("cat " + str(script_to_ask))
            script_text = stdout.read().strip()
            error_text = stderr.read().strip()
            if not error_text == '':
                msg_text =  'Error reading script \n\n'
                msg_text += str(error_text)
            else:
                msg_text = script_to_ask + '\n\n'
                msg_text += str(script_text)
            wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
        except Exception as e:
            print("oh bother, this seems wrong... " + str(e))
supplicantdev.py 文件源码 项目:Supplicant 作者: mayuko2012 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run(self):
         self.timeToQuit.wait(10)
         while True:
            if self.timeToQuit.isSet():
                self.sock.close()
                break
            else:
                breathe = packet.generate_breathe(self.mac, self.ip, self.session, self.index)
                status = connect.breathe(self.sock, breathe, self.hosts)
                if status == 0:
                    self.sock.close()
                    wx.MessageBox(u"?????????????",u"??!!",wx.OK | wx.ICON_INFORMATION,self)
                    sys.exit()
                    break
                else:
                    self.index += 3
                    self.timeToQuit.wait(self.messageDelay)
request2doc_gui.py 文件源码 项目:request2doc 作者: kongxinchi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_transform_button_click(self, event):
        slice_startswith = self.slice_text.GetValue()
        template_path = self.get_template_path()
        response_body = self.GetParent().get_response_content()

        try:
            handler = Request2Doc()
            handler.set_slice_startswith(slice_startswith)
            handler.set_response_body(response_body)

            if not handler.get_response_data():
                return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal()

            self.GetParent().set_document_content(handler.render_string(template_path))

        except Exception, e:
            return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
about.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def update_check(parent):
    """Check for updates using the GitHub API

    Args:
        parent (wx.Window): The parent window (for the message dialog)

    Returns:
        None
    """
    r = requests.get('https://api.github.com/repos/10se1ucgo/pyjam/releases/latest')

    if not r.ok:
        return

    new = r.json()['tag_name']

    try:
        if StrictVersion(__version__) < StrictVersion(new.lstrip('v')):
            info = wx.MessageDialog(parent, message="pyjam {v} is now available!\nGo to download page?".format(v=new),
                                    caption="pyjam Update", style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
            if info.ShowModal() == wx.ID_OK:
                webbrowser.open_new_tab(r.json()['html_url'])
            info.Destroy()
    except ValueError:
        pass
PLCOpenEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _init_coll_HelpMenu_Items(self, parent):
        AppendMenu(parent, help='', id=wx.ID_HELP,
                   kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor') + '\tF1')
        # AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS,
        #      kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2')
        # AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT,
        #      kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3')

        def handler(event):
            return wx.MessageBox(
                version.GetCommunityHelpMsg(),
                _(u'Community support'),
                wx.OK | wx.ICON_INFORMATION)

        id = wx.NewId()
        parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support'))
        self.Bind(wx.EVT_MENU, handler, id=id)

        AppendMenu(parent, help='', id=wx.ID_ABOUT,
                   kind=wx.ITEM_NORMAL, text=_(u'About'))
        self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP)
        # self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS)
        self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
PLCOpenEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def OnGenerateProgramMenu(self, event):
        dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(),  _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE | wx.CHANGE_DIR)
        if dialog.ShowModal() == wx.ID_OK:
            filepath = dialog.GetPath()
            message_text = ""
            header, icon = _("Done"), wx.ICON_INFORMATION
            if os.path.isdir(os.path.dirname(filepath)):
                program, errors, warnings = self.Controler.GenerateProgram(filepath)
                message_text += "".join([_("warning: %s\n") % warning for warning in warnings])
                if len(errors) > 0:
                    message_text += "".join([_("error: %s\n") % error for error in errors])
                    message_text += _("Can't generate program to file %s!") % filepath
                    header, icon = _("Error"), wx.ICON_ERROR
                else:
                    message_text += _("Program was successfully generated!")
            else:
                message_text += _("\"%s\" is not a valid folder!") % os.path.dirname(filepath)
                header, icon = _("Error"), wx.ICON_ERROR
            message = wx.MessageDialog(self, message_text, header, wx.OK | icon)
            message.ShowModal()
            message.Destroy()
        dialog.Destroy()
email_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def on_button_email_passwd(self,event):# Button save email and password
        email=self.text_ctrl_email.Value
        passwd=self.text_ctrl_email_passwd.Value

        if not self.V.validate_email(email)[0]:
            msg="Invalid Email"
            dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR)                  
            dlg.ShowModal()
            dlg.Destroy()
            return 0
        self.DB.Set_SMS_Sender_Mail(email)
        self.DB.Set_SMS_Sender_Mail_Password(passwd)
        msg="Successfully Saved"
        dlg = wx.MessageDialog(self, msg, 'Success',wx.OK | wx.ICON_INFORMATION)                  
        dlg.ShowModal()
        dlg.Destroy()
user_operations.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def Login_Check(self,user,password):

        print "login check"

        passw=self.EN.Encrypt_Password(self.Secret_Key+password)
        query="SELECT PASSWORD FROM USER WHERE USER='%s' AND PASSWORD='%s'" %(user,passw)  
        #self.DB.cur.execute(query,(user,self.Secret_Key+password,))
        self.DB.cur.execute(query)
        #self.DB.con.commit()

        row=self.DB.cur.fetchone()


        if row:


            return True
        else:
            dlg = wx.MessageDialog(self.parent, 'Incorrect Password', '',wx.OK | wx.ICON_INFORMATION)                  
            dlg.ShowModal()
            dlg.Destroy()

            return False
institution.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def on_save(self, event):  # wxGlade: institution.<event_handler>
        try:
            self.DB.Set_School_Name(self.text_ctrl_name.Value) 
            self.DB.Set_School_Code(self.text_ctrl_code.Value)   

            self.DB.Set_School_Email(self.text_ctrl_email.Value)       
            self.DB.Set_School_Contact(self.text_ctrl_phone.Value)
            self.DB.Set_School_DEO(self.text_ctrl_deo.Value)
            dlg = wx.MessageDialog(self, 'Successfully Saved', '',wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
        except:
            dlg = wx.MessageDialog(self, 'Could not save some values', '',wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()




        self.Close(True)
        event.Skip()
sms_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def send_sms(self):


        print "sending",self.NO_MOBILE_LIST

        if  self.NO_MOBILE_LIST:



            msg="The following Student(s) got no valid mobile numbers. Go to Student Profile to add/edit mobile numbers\n"

            no=0

            for pupil in self.NO_MOBILE_LIST:
                no+=1
                msg+=str(no)+".  "+str(pupil)+"\n"

            #app = wx.PySimpleApp(0)

            dlg = wx.MessageDialog(None, msg,"No Mobile Number",wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
promotion_list.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def Failed_Report(self):

        if len(self.Failed_List)==0:
            msg="All Students Passed"
        else:
            msg="The following Student(s) detained\n"
            no=0
            for pupil in self.Failed_List:
                no+=1
                msg+=str(no)+".  "+str(pupil)+"\n"

        #app = wx.PySimpleApp(0)

        dlg = wx.MessageDialog(None, msg,str(self.class_)+self.div,wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
settings.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def OnSave(self, event):  # wxGlade: MyFrame2.<event_handler>
        CE=[self.ce_1,self.ce_2,self.ce_3,self.ce_4,self.ce_5,self.ce_6,self.ce_7,self.ce_8,self.ce_9,self.ce_10,self.ce_11,self.ce_12,self.ce_13]
        TE=[self.te_1,self.te_2,self.te_3,self.te_4,self.te_5,self.te_6,self.te_7,self.te_8,self.te_9,self.te_10,self.te_11,self.te_12,self.te_13]


        try:
            for i in range(13):
                if self.YEAR=='Select' or self.STD=='Select':
                    break
                else:
                    index=i#in deb oper Get_CE_CE() index for work exp starts at 12
                    if i>=10:
                        index+=2

                    self.DB.Set_CE_TE(self.YEAR,self.STD,index,CE[i].Value,TE[i].Value)
            dlg = wx.MessageDialog(self, 'Successfully Saved', '',wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
        except:
            dlg = wx.MessageDialog(self, 'Error! Could not Save', '',wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()

        event.Skip()
action_menu_pcb2dxf.py 文件源码 项目:kicad-action-plugins 作者: easyw 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def Run( self ):
        fileName = GetBoard().GetFileName()
        if len(fileName)==0:
            wx.LogMessage("a board needs to be saved/loaded!")
        else:
            dirpath = os.path.abspath(os.path.expanduser(fileName))
            path, fname = os.path.split(dirpath)
            ext = os.path.splitext(os.path.basename(fileName))[1]
            name = os.path.splitext(os.path.basename(fileName))[0]

            LogMsg="reading from "+ dirpath
            out_filename=path+os.sep+name+".dxf"
            LogMsg+="writing to "+out_filename
            content=[]
            txtFile = open(fileName,"r")
            content = txtFile.readlines()
            content.append(" ")
            txtFile.close()

            #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', 'Test', wx.OK | wx.ICON_INFORMATION).ShowModal()
            #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', content, wx.OK | wx.ICON_INFORMATION).ShowModal()
            #found_selected=False
            #board = pcbnew.GetBoard()

            dlg=wx.MessageBox( 'Only SAVED board file will be exported to DXF file', 'Confirm',  wx.OK | wx.CANCEL | wx.ICON_INFORMATION )
            if dlg == wx.OK:
                if os.path.isfile(out_filename):
                    dlg=wx.MessageBox( 'Overwrite DXF file?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION )
                    if dlg == wx.YES:
                        export_dxf(content, out_filename)
                else:
                    export_dxf(content, out_filename)
recipe-578681.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def Error(self, dialog):
        wx.MessageBox(dialog , 'Info', 
            wx.OK | wx.ICON_INFORMATION)
pyqhaGUI.py 文件源码 项目:pyqha 作者: mauropalumbo75 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnHelp(self, event):
        wx.MessageBox("A program to perform quasi-harmonic calculations based on the pyqha module",
        "Help Contents", wx.OK | wx.ICON_INFORMATION, self)
pyqhaGUI.py 文件源码 项目:pyqha 作者: mauropalumbo75 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnAbout(self, event):
        wx.MessageBox("pyqhaGUI: a program to perform quasi-harmonic calculations",
        "About pyQHA", wx.OK | wx.ICON_INFORMATION, self)
pySIMlastnum.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def OnPopupDeleteAll(self, event):
        dlg = wxskinMessageDialog(self, self.delete_confirm_text,
                              'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION)
        ret = dlg.ShowModal()
        dlg.Destroy()
        if ret == wx.ID_YES:

            dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            try:
                self.SIM.gotoFile(LND_FILE_PATH)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                i = 1
                for key in self.itemDataMap.keys()[:]:   # Make a copy of key table!!
                    if not dlg.Update(i):
                        break
                    self.writePhonebookEntry(key)
                    del self.itemDataMap[key]
                    i += 1
            except:
                print_exc()
                pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error")

            dlg.Destroy()
            self.UpdateView()

    # Override the column sorting function. We need to compare 'a' and 'A' as equal
pySIMphonebook.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnPopupDeleteAll(self, event):
        dlg = wxskinMessageDialog(self, self.delete_confirm_text,
                              'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION)
        ret = dlg.ShowModal()
        dlg.Destroy()
        if ret == wx.ID_YES:

            dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            try:
                self.SIM.gotoFile(self.filepath)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                i = 1
                for key in self.itemDataMap.keys()[:]:   # Make a copy of key table!!
                    if not dlg.Update(i):
                        break
                    self.writePhonebookEntry(key)
                    del self.itemDataMap[key]
                    i += 1
            except:
                print_exc()
                pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error")

            dlg.Destroy()
            self.UpdateView()

    # Override the column sorting function. We need to compare 'a' and 'A' as equal
pySimReader.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def menuHelpHelp(self, event):
        """Show help dialog"""
        dlg = wx.MessageDialog(self, 'Not Yet Implimented!', 'ToDo',
                             wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
pySimReader.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def menuHelpAbout(self, event):
        """Show about pySIM dialog"""
        dlg = wx.MessageDialog(self, self.aboutPySIM, 'About pySIM',
                             wx.OK | wx.ICON_INFORMATION)
        #~ ovr = html_module.HtmlWindow(dlg, -1, size=(400, 400))
        #~ ovr.SetPage(self.aboutPySIMhtml)
        dlg.ShowModal()
        dlg.Destroy()
pySIMserial.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def connectReader(self):
        if not self.getReaderName():
            self.selectNewReader()
        if self.getReaderName():
            res = self.openSession(self.getReaderName())
            if res == 0:
                self.state = SIM_STATE_CONNECTED
                self.gatherInfo()
            else:
                #~ print "Blah blah"
                dlg = wx.MessageDialog(self, 'Unable to connect to reader: %s' % self.getReaderName(), 'Reader error', 
                                     wx.OK | wx.ICON_INFORMATION) 
                dlg.ShowModal() 
                dlg.Destroy()
                self.readerName = ""
pySIMskin.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, parent, messageString, titleString="pySIM", style=wx.OK | wx.ICON_INFORMATION, pos=wx.DefaultPosition):
        wx.MessageDialog.__init__(self, parent, messageString, titleString, style, pos)
        self.SetBackgroundColour(backgroundColour)
pySIMskin.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent, messageString, titleString="pySIM", style=wx.OK | wx.ICON_INFORMATION):
        wxskinMessageDialog.__init__(self, parent, messageString, titleString, style)
        self.ShowModal() 
        self.Destroy()
mentaltasks.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def trainTDENet(self, segs):
        trainData = [seg.data for seg in segs]

        convs = ((25,7),) # first session
        maxIter = 400

        nHidden = None
        poolSize = 1
        poolMethod = 'average'

        self.stand = ml.ClassSegStandardizer(trainData)
        trainDataStd = self.stand.apply(trainData)

        dialog = wx.ProgressDialog('Training Classifier',
                                   'Featurizing', maximum=maxIter+2,
                                   style=wx.PD_ELAPSED_TIME | wx.PD_SMOOTH)

        def progressCB(optable, iteration, *args, **kwargs):
            dialog.Update(iteration, 'Iteration: %d/%d' % (iteration, maxIter))

        self.classifier = ml.CNA(trainDataStd, convs=convs, nHidden=nHidden, maxIter=maxIter,
                                 optimFunc=ml.optim.scg, accuracy=0.0, precision=0.0,
                                 poolSize=poolSize, poolMethod=poolMethod,
                                 verbose=False, callback=progressCB)

        trainCA = self.classifier.ca(trainDataStd)
        trainConfusion = np.round(100*self.classifier.confusion(trainDataStd))

        dialog.Destroy()

        resultText = (('Final Training CA: %f\n' % trainCA) +
                      ('Confusion Matrix:\n' + str(trainConfusion) + '\n') +
                      ('Choices: ' + str(self.choices)))

        wx.MessageBox(message=resultText,
                      caption='Training Completed!',
                      style=wx.OK | wx.ICON_INFORMATION)

        self.saveResultText(resultText)
mentaltasks.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def trainConvNet(self, segs):
        trainData = [seg.data for seg in segs]

        #convs = ((16,9), (8,9))
        #maxIter = 400 # 49
        convs = ((8,3), (8,3), (8,3))
        maxIter = 1000

        nHidden = None
        poolSize = 1
        poolMethod = 'average'

        self.stand = ml.ClassSegStandardizer(trainData)
        trainDataStd = self.stand.apply(trainData)

        dialog = wx.ProgressDialog('Training Classifier',
                                   'Featurizing', maximum=maxIter+2,
                                   style=wx.PD_ELAPSED_TIME | wx.PD_SMOOTH)

        def progressCB(optable, iteration, *args, **kwargs):
            dialog.Update(iteration, 'Iteration: %d/%d' % (iteration, maxIter))

        self.classifier = ml.CNA(trainDataStd, convs=convs, nHidden=nHidden, maxIter=maxIter,
                                 optimFunc=ml.optim.scg, accuracy=0.0, precision=0.0,
                                 poolSize=poolSize, poolMethod=poolMethod,
                                 verbose=False, callback=progressCB)

        trainCA = self.classifier.ca(trainDataStd)
        trainConfusion = np.round(100*self.classifier.confusion(trainDataStd))

        dialog.Destroy()

        resultText = (('Final Training CA: %f\n' % trainCA) +
                      ('Confusion Matrix:\n' + str(trainConfusion) + '\n') +
                      ('Choices: ' + str(self.choices)))

        wx.MessageBox(message=resultText,
                      caption='Training Completed!',
                      style=wx.OK | wx.ICON_INFORMATION)

        self.saveResultText(resultText)
bciplayer.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def trainKNN(self, classData, dialog, metric):
        ks = np.arange(1,10)

        trainAUC = np.zeros(ks.shape)
        validAUC = np.zeros(ks.shape)

        partitionGenerator = ml.part.classRandomSubSample(classData,
                self.trainFrac, self.nFold)

        for fold, trainData, validData in partitionGenerator:
            dialog.Update(fold, 'Validation Fold: %d' % fold)

            for i, k in enumerate(ks):
                classifier = ml.KNN(trainData, k=k, distMetric=metric)

                trainAUC[i] += classifier.auc(trainData)
                validAUC[i] += classifier.auc(validData)

        dialog.Update(self.nFold, 'Training Final Classifier')

        trainAUC /= self.nFold
        validAUC /= self.nFold

        print 'train AUC: ', trainAUC
        print 'valid AUC: ', validAUC

        bestK = ks[np.argmax(validAUC)]
        print 'best K: ', bestK

        self.classifier = ml.KNN(classData, k=bestK, distMetric=metric)

        finalAUC = self.classifier.auc(classData)

        dialog.Destroy()

        wx.MessageBox(message=('Best K: %d\n' % bestK) + \
            ('Mean Validation AUC: %f\n' % np.max(validAUC)) +
            ('Final Training AUC: %f' % finalAUC),
            caption='Training Completed!', style=wx.OK | wx.ICON_INFORMATION)


问题


面经


文章

微信
公众号

扫码关注公众号