def buildCategories(self): multiclass_exp = self.buildMulticlassClassifier() train = self.multiclass_model.datasets.train_instances test = self.multiclass_model.datasets.test_instances all_instances = copy.deepcopy(test) all_instances.union(train) if test.numInstances() > 0: predicted_families = self.multiclass_model.testing_monitoring.getPredictedLabels() all_families = list(predicted_families) + train.families predicted_proba = self.multiclass_model.testing_monitoring.getAllPredictedProba() for family in train.families: probas = [int(family == s) for s in self.multiclass_model.class_labels] predicted_proba = np.vstack((predicted_proba, np.array(probas))) else: all_families = self.annotated_instances.families predicted_proba = None for family in self.annotated_instances.families: probas = [int(family == s) for s in self.multiclass_model.class_labels] if predicted_proba is None: predicted_proba = np.array(probas) else: predicted_proba = np.vstack((predicted_proba, np.array(probas))) labels_values = list(self.multiclass_model.class_labels) assigned_categories = [labels_values.index(x) for x in all_families] self.categories = Categories(multiclass_exp, all_instances, assigned_categories, predicted_proba, self.label, self.multiclass_model.class_labels)
def setCategories(self, all_instances, assigned_categories, predicted_proba): self.categories = Categories(self.iteration, all_instances, assigned_categories, predicted_proba, self.label, self.multiclass_model.class_labels)
def get_category_by_id(self, cat_id): if cat_id == None: return None Category = Categories(self.db) category = Category.find_by_id(cat_id) if not category: return None return category
def __init__(self, nTrial, nStim): self.nTrial = nTrial self.nStim = nStim self.categs = Categories(nTrial, nStim) self.stims = self.categs.encDF # self.trials = data.TrialHandler(self.stims, # 1, # method='sequential') self.poslist = []
def __init__(self,nTrial,nStim): ''' Parameters ---------- nTrial: number of runs for a subject nStim: number of new images used in each phase in a trial ''' self.log = logging.LogFile(f='imTaskLogFile') self.nTrial = nTrial self.nStim = nStim self.categs = Categories(nTrial,nStim) self.encDict = self.categs.encDF.to_dict(orient="index") self.recDict = self.categs.recDF.to_dict(orient="index") self.stimpos = {'0':(-250.0, 250.0), '1':(250.0, 250.0), '2':(250.0, -250.0), '3':(-250.0, -250.0)} self.outputlist = [] self.encInstStartText = '''\ Memorize the following images and their location on screen. Press space to start.\ '''.format() self.recInstStartText = '''\ A series of {x} images will appear. Indicate if shown image corresponds to a previously seen image and in which quadrant it has appeared earlier. Press SPACE to start\ '''.format(x=self.nStim+1) self.recInstText1 = '''\ Have you seen this picture before? If yes, press "y". If not, press "n".\ '''.format() self.recInstText2 = '''\ Where have you seen it? Press 0, 1, 2 or 3 to answer\ '''.format() self.recInstPosText = '''\ Where have you seen it? 0 = upper-left, 1 = upper-right 2 = lower-left, 3 = lower-right\ '''.format() self.ansSaveText = 'Answer saved!' self.endText = 'Thank you for your time, goodbye!'
def __init__(self, whichTrial, nTrial, nStim): self.whichTrial = whichTrial self.nTrial = nTrial self.nStim = nStim self.categs = Categories(nTrial, nStim) self.encDict = self.categs.encDF.to_dict(orient="index") self.thisEncTrial = self.encDict[self.whichTrial] self.recDict = self.categs.recDF.to_dict(orient="index") self.thisRecTrial = self.recDict[self.whichTrial] self.thisTrialTarg = self.categs.Targs[self.whichTrial] self.encStimlist = [] self.answerlist = [] self.stimpos = { '0': (-250.0, 250.0), '1': (250.0, 250.0), '2': (250.0, -250.0), '3': (-250.0, -250.0) } self.targetPos = self.getTargPos() self.encInstStartText = '''\ Memorize the following images and their location on screen. Press space to start.\ '''.format() self.recInstStartText = '''\ A series of {x} images will appear. Indicate if shown image corresponds to a previously seen image and in which quadrant it has appeared earlier. Press SPACE to start\ '''.format(x=self.nStim + 1) self.recInstText1 = '''\ Have you seen this picture before? If yes, press "y". If not, press "n".\ '''.format() self.recInstText2 = '''\ Where have you seen it? Press 0, 1, 2 or 3 to answer\ '''.format() self.recInstPosText = '''\ Where have you seen it? 0 = upper-left, 1 = upper-right 2 = lower-left, 3 = lower-right\ '''.format() self.ansSaveText = 'Answer saved!' self.endText = 'Thank you for your time, goodbye!'
def get_or_create_category_by_name(self, cat_name, gender=None, parent=None): if cat_name == None: return None if gender != None: gender = gender["id"] if parent != None: parent = parent["id"] Category = Categories(self.db) category = Category.find_by_name_and_gender(cat_name.strip(), gender) if not category: category = Category.save(cat_name.strip(), gender=gender, category=parent) if not category: return None return category
def adminMenu(): print(" ~~ Administration MAIN MENUE ~~\n\n") print(" 1- Manage Categories") print(" 2- Manage Products") print(" 3- Manage Customers\n") manageGRP = input("Please choose your option [1-3] >>") # admin select manage categories if manageGRP[:1] == '1': clear() Category = Categories() Category.main() # admin select manage Products elif manageGRP[:1] == '2': clear() product = Products() product.main() # admin select manage Customers elif manageGRP[:1] == '3': clear() # Category = Categories() # Category.main() else: print("Invalid Option")
def __init__(self,nTrial,nStim): self.nTrial = nTrial self.nStim = nStim self.categs = Categories(nTrial,nStim) self.encResults = pd.read_csv(os.getcwd()+'\\stimDF.csv') self.stims = self.categs.recDF self.TargStims = self.categs.Targs self.stimpos = {'0':np.array((-250.0, 250.0)), '1':np.array((250.0, 250.0)), '2':np.array((250.0, -250.0)), '3':np.array((-250.0, -250.0))} self.instStartText = '''\ ... A series of {x} images will appear. ... Indicate if shown image corresponds to a previously seen image ... and in which quadrant it has appeared earlier. ... Press SPACE to start\ '''.format(x=len(self.stims)+1) self.inst1Text = '''\ ... Have you seen this picture before? ... If yes, press "y". If not, press "n".\ '''.format() self.inst2Text = '''\ ... Where have you seen it? ... Press 0, 1, 2 or 3 to answer\ '''.format() self.instPosText = '''\ ... Where have you seen it? ... 0 = upper-left, 1 = upper-right ... 2 = lower-left, 3 = lower-right\ '''.format() self.ansSaveText = 'Answer saved!'
def __init__(self): self.trials = data.TrialHandler(Categories(2, 5).trialslist, 1, method='sequential')
# -*- coding: utf-8 -*- """ Created on Sun Sep 22 00:37:31 2019 @author: Francois """ from psychopy import core from psychopy import data from psychopy import event from psychopy import visual from Categories import Categories from randSign import randSign trials = data.TrialHandler(Categories(2, 8).trialslist, 1, method='sequential') def runtask(trials): win = visual.Window(size=(1000, 1000), color=(0, 0, 0), units='pix') eachTrial = 0 while eachTrial <= len(trials.trialList) - 1: def encodingphase( win ): # Shows stimuli in each trial list in "trials"(also list) #stimpos = [(250.0, 250.0),(-250.0, -250.0),(250.0, -250.0),(-250.0, -250.0)] #Possibly replacing randSign() instructionStart = visual.TextStim( win, text= 'Memorize the following images and their location on screen. Press space to start.'
def main(self): product = Products() self.clear() print(" ***** Manage Products *****\n\n") print(" 1- Add a new product") print(" 2- Edit existing product") print(" 3- Remove existing product\n") productOperation = input("Please choose your option [1-3] >>") if productOperation[:1] == '1': category = Categories() self.clear() # Retrive real state data from database print("Options:") print( "\n\n1- Choose a category from the existing categories to add your product to") print("\n2- Add a new category to connect your product to") option = input("\nPlease make a selection [1-2] >>") if category.ValidateUserInputAsNumber(option): option = int(option) if(option == 1 or option == 2): if(option == 1): self.clear() SQLStatment = category.selectStatment( "*", "categories", "") cursor = self.executeSQLStatment(SQLStatment) rows = cursor.fetchall() cursor.close() print( "-------------------------------------------------------------:") print( "---------------------- Categories List ----------------------") #ProductCategory = Category() if(rows): counter = 0 for row in rows: print(f"{counter+1} - {row[1]} ") counter += 1 categoryNo = input( "\n\nPlease enter a valid category from the list above>>") if category.ValidateUserInputAsNumber(categoryNo): categoryNo = int(categoryNo) if(categoryNo > 0 and categoryNo <= counter and categoryNo is not None): rowIndex = int(categoryNo)-1 category_id = int(rows[rowIndex][0]) print("\n\n ***New Product Information:***") productName = input( "Please enter the product name >> ") productDescription = input( "Please enter the product description >> ") productPrice = input( "Please enter the product price >> ") self.addNewProduct( category_id, productName, productDescription, productPrice) else: categoryName = input( "Please enter the Category name that you want to add >>") rows = category.addNewCategory(categoryName) category_id = rows.fetchone()[0] print("\n\n ***New Product Information:***") productName = input( "Please enter the product name >> ") productDescription = input( "Please enter the product description >> ") productPrice = input( "Please enter the product price >> ") self.addNewProduct( category_id, productName, productDescription, productPrice) else: print("invalid option") elif productOperation[:1] == '2': # self.EditProduct("Edit") # self.editExistingProduct( print("\n\n- Search Products by Name -") productName = input( "Please enter a keyword to search for Product Name >> ") whereStatment = f"LOWER(product_name) like '%{productName}%' " self.editExistingProduct(whereStatment) elif productOperation[:1] == '3': self.searchMainMenu("Delete") else: print("Invalid entry\n")