def menu(self): helpers().clearScreen() # warning = statistics(chr(1), chr(1), False) #warning.checkCurruption() print("Please select one of the following options:") print("[1] Start Trivia") print("[2] View Statistics") print("[3] About") print("[q] Speed Run") print("[e] Exit") return ord(helpers().getchTrivia())
def __init__(self,basedir=".",mode="initial",cores=-1): self.basedir = basedir self.mode = mode self.lastAcceptedPath = "start" if cores == -1: self.cores = multiprocessing.cpu_count() else: self.cores = cores self.wrapper = wrappers.gromacswrapper() self.distparser = parser.gdistparser() self.filesystem = filesystem.filesystem() self.interfaces = interfaces.interfaces() self.stablestates = stablestates.stablestates() self.helper = helpers.helpers() #Initialize the logger self.log = gtpslogging.log("debug",basedir) self.log.log.debug("logfile created") self.log.log.info(str(self.cores) + " CPUs detected") #read the stables states from a file self.stablestates.readStates(os.path.join(basedir,"stablestates.txt")) self.log.log.info("Read States : " + str(self.stablestates.states)) """ This array holds all the information about the paths. Each trajectory consists of a forward-part and a backward-part. The trajectory can either be a forward trajectory or a backward trajectory. Forward trajectroies start in A. """ self.paths = [] self.paths.append(pathsimulation.pathdata(0,basedir,mode,forward=True,forwardpart=True)) self.paths.append(pathsimulation.pathdata(0,basedir,mode,forward=True,forwardpart=False))
def __init__(self, logger, dict_X, dict_y, shouldSMOTE=False, smote_N=100, smote_k=5, doLASSO=False, alpha=1.0, kCrossValPos=0, kCrossValNeg=0, verbose=False): # class variables to initialize general classifier self.logger = logger self.verbose = verbose self.helperObj = helpers(logger) self.dict_X = dict_X.copy() self.dict_y = dict_y.copy() self.kCrossValPos = kCrossValPos self.kCrossValNeg = kCrossValNeg self.hidden_X = [] self.hidden_y = [] self.totalExamples = len(self.dict_X) self.featureDims = len(self.dict_X.values()[0]) print self.featureDims (self.allPosExampleKeys, self.allNegExampleKeys) = self.helperObj.getLabelSets(dict_y) self.numAllPosExamples = len(self.allPosExampleKeys) self.numAllNegExamples = len(self.allNegExampleKeys) self.crossValExcludeSet = set() self._hideSamples() if shouldSMOTE: sampler = ExampleSampler(dict_X, dict_y, self.logger) trainPosKeys = list(set(self.allPosExampleKeys) - set(self.hiddenPosExampleKeys)) self.dict_X, self.dict_y, self.crossValExcludeSet = sampler.smote(trainPosKeys, smote_N, smote_k, 1) self.crossValExcludeSet = set(self.crossValExcludeSet) self.totalExamples = len(self.dict_X) self.featureDims = len(self.dict_X.values()[0]) (self.allPosExampleKeys, self.allNegExampleKeys) = self.helperObj.getLabelSets(dict_y) self.numAllPosExamples = len(self.allPosExampleKeys) self.numAllNegExamples = len(self.allNegExampleKeys) if doLASSO: positiveExampleKeys = set(self.allPosExampleKeys) - set(self.hiddenPosExampleKeys) negativeExampleKeys = set(self.allNegExampleKeys) - set(self.hiddenNegExampleKeys) y = ([1] * len(positiveExampleKeys)) + ([0] * len(negativeExampleKeys)) X = self.helperObj.dictOfFeaturesToList(self.dict_X, positiveExampleKeys) + \ self.helperObj.dictOfFeaturesToList(self.dict_X, negativeExampleKeys) clf = linear_model.Lasso(alpha=alpha, selection="random") clf.fit(X, y) coefs = np.array(clf.coef_) zeroCoefIndices = np.where(coefs == 0)[0].tolist() for key in self.dict_X.iterkeys(): self.dict_X[key] = np.delete(self.dict_X[key], zeroCoefIndices, 0).tolist() self.hidden_X = np.delete(self.hidden_X, zeroCoefIndices, 1).tolist() self.featureDims = len(self.dict_X.values()[0]) self.logger.log("Data size: {0} x {1}".format(self.featureDims, self.totalExamples)) self.logger.log("Total Number of Positive Examples: {0}".format(self.numAllPosExamples)) self.logger.log("Number of Hidden Positive Examples: {0}".format(self.numHiddenPosExamples)) self.logger.log("Total Number of Negative Examples: {0}".format(self.numAllNegExamples)) self.logger.log("Number of Hidden Negative Examples: {0}".format(self.numHiddenNegExamples)) # holds the trained classifier after training self.trainedClassifier = None
def density(self, dataset): hp = helpers() db = DensityBasedClustering() distance = db.findDistanceMatrix(dataset) eps = float(input("Enter the value for epsilon parameter: ")) minpts = int( input("Enter the minimum number of pts for a core point: ")) db.dbScan(dataset, eps=eps, minpts=minpts, distance=distance) result = hp.sort_result(dataset) return dataset, result
def kmeans(self, dataset): hp = helpers() km = k_means() datadict = km.convertToDict(dataset) k = int(input("Enter number of required clusters: ")) centroids = np.array(km.initializeCentroids(datadict, k)) iterations = int(input("Enter number of max iterations: ")) centroids = km.assignClusters(dataset, centroids, iterations) result = hp.sort_result(dataset) return dataset, result, centroids
def getFavoriteInits( self): #get favorite category, get favorite difficultry() favoriteCat = helpers().mostFrequent(self.gameCategories) favoriteDiff = helpers().mostFrequent(self.gameDifficulties) if favoriteCat == 49: favoriteCatString = "Random" if favoriteCat == 50: favoriteCatString = "General Knowledge" if favoriteCat == 51: favoriteCatString = "Books" if favoriteCat == 52: favoriteCatString = "Film" if favoriteCat == 53: favoriteCatString = "Musicals/Theater" if favoriteCat == 54: favoriteCatString = "Television" if favoriteCat == 55: favoriteCatString = "Math" if favoriteCat == 56: favoriteCatString = "Geography" if favoriteCat == 57: favoriteCatString = "Sports" if favoriteCat == 97: favoriteCatString = "History" if favoriteCat == 98: favoriteCatString = "Politics" if favoriteCat == 99: favoriteCatString = "Art" if favoriteCat == 100: favoriteCatString = "Trash" if favoriteCat == 102: favoriteCatString = "Japanese Anime and Manga" if favoriteDiff == 49: favoriteDiffString = "Easy" if favoriteDiff == 50: favoriteDiffString = "Medium" if favoriteDiff == 51: favoriteDiffString = "Hard" return [favoriteCatString, favoriteDiffString]
def gmmClustering(self): flag = int(input("Enter 1 for Kmeans initialization else Enter 0: ")) centroids = [] if flag == 1: hp = helpers() dataset, fileName = hp.get_file() _, _, centroids = m.kmeans(dataset) else: fileName = input("Enter data file name (without extension): ") filePath = "../Data/" + fileName + ".txt" # filePath = "CSE-601/project2/Data/"+ fileName + ".txt" g = gmm(filePath, centroids) dataset, predicted, ids = g.emAlgorithm() return dataset, predicted, ids, fileName
def __init__(self,basedir=".",mode="initial",kernel=0): self.basedir = basedir self.mode = mode self.cores = multiprocessing.cpu_count() self.wrapper = wrappers.gromacswrapper() self.distparser = parser.gdistparser() self.filesystem = filesystem.filesystem() self.helper = helpers.helpers() self.kernels = kernels.kernels(kernel) self.qsubsystem = qsubsystem.qsubsystem() #Initialize the logger if kernel=="head": self.log = gtpslogging.log("info",basedir,kernel) else: self.log = gtpslogging.log("debug",basedir,kernel) self.log.log.debug("logfile created") self.log.log.info(str(self.cores) + " CPUs detected") self.kernels.readKernelOptions(os.path.join(basedir,"options","kerneloptions.txt")) #read the stables states from a file self.stablestates.readStates(os.path.join(basedir,"options","stablestates.txt")) self.log.log.info("Read States : " + str(self.stablestates.states)) """ This array holds all the information about the paths. Each trajectory consists of a forward-part and a backward-part. The trajectory can either be a forward trajectory or a backward trajectory. Forward trajectroies start in A. """ self.paths = [] self.npaths = 0 for i in range(self.kernels.ntps): self.paths.append(pathdata.pathdata(i,basedir,mode,forward=True,forwardpart=True,interface=0)) self.paths.append(pathdata.pathdata(i,basedir,mode,forward=True,forwardpart=False,interface=0)) self.npaths += 1 self.kernels.generateKernelLists(self.npaths)
def normalIntro(self): helpers().clearScreen() self.bar = " " + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" print("access user") time.sleep(0.1) #print(current_time) datetime.now().strftime('%Y-%m-%d %H:%M:%S') time.sleep(0.1) print("AQ_SECURE_SYSTEMS_v3.2654.2\n") time.sleep(0.5) user = input("USERNAME: "******"Initializing . . . ." print("Kuarry Terminal Trivia Version 2.1.3") time.sleep(.1) print("\n*** connecting to port_6667 of #channel irc") time.sleep(0.1) print("*** loading .ircr version 2.9+Crlf+F08") time.sleep(0.1) print("*** users on #channel: " + user) for dot in dots: sys.stdout.write(dot) sys.stdout.flush() if dot == '.': time.sleep(0.4) else: time.sleep(0.05) helpers().clearScreen() print(" ") print(" ") print(" ") print(" ``........`` ") print(" `.---------------.` ") print(" `.------..`.o``..------.` ") print(" `.----.` `dMy `.----. ") print(" `----. .mMMMh` `.----` ") print(" `----` .mMm/NMd` .---- ") print(" ----` -NMh` .mMd` .---. ") print(" `---- :NMy `dMm. ---- ") print(" `---. /MMo `hMN- ----` ") print(" `---- +MM/ sMN: ---- ") print(" ----` oMMy///////////dMM/ .---. ") print(" `----`sMMMMMMMMMMMMMMMMMMM/.----`````` ") print(" `----. .sMMMMMMMMM/ ") print(" `-----.` `.---/mMo +MM: ") print(" `------..```````..-----.``yMmMN: ") print(" `.----------------..` /NN- ") print(" ``....-....`` .. ") print(" ") print(" ") print(" LOADING . . . ") for d in self.bar: sys.stdout.write(d) sys.stdout.flush() if d == ' ': time.sleep(0.001) else: time.sleep(0.4) time.sleep(.5)
def adminIntro(self): helpers().clearScreen() time.sleep(1) text = "Initiating . . . . . ." bar = " " + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" + u"\u2588" for c in text: sys.stdout.write(c) sys.stdout.flush() if c == '.': time.sleep(0.8) else: time.sleep(0.1) t = time.localtime() current_date = time.strftime("%Y-%m-%d %H:%M:%S", t) current_time = time.strftime("%H:%M:%S", t) print("\nStarting AQmap at " + current_date + "\n") time.sleep(1) intro = "AQ:\\Documents and Settings\\Program Files\\Netcat-nc-n -1 -v -p listening . . . \nconnect to [AQ_SECURE_ROUTINE] from <UNKNOWN> [:442-327-4]\nsh: no job control in this shell sh-32$ wget --00:18:54\n\nResolving . . . .\nConnecting . . . .\n" for q in intro: sys.stdout.write(q) sys.stdout.flush() if q == ".": time.sleep(0.8) else: time.sleep(0.015) intro1 = "\ninit connection @Server 23.86.111.0 \naccess folder [AQ_SECRET_ROUTINE]\noverride security settings \n\n" for q1 in intro1: sys.stdout.write(q1) sys.stdout.flush() time.sleep(0.03) print("PID USER PRI NI VIRT RES SHR TIME+ Command") time.sleep(0.5) print( "357 root 20 8 281M 2105 0.1 0:00.16 /lib/systend/sytemd-journald" ) time.sleep(0.05) print( "375 root 20 8 KD11 1392 0.8 0:00.46 /lib/systend/sytemd-udevd" ) time.sleep(0.05) print( "235 systend-1 20 3 257M 1392 0.1 0:00.16 /lib/systend/sytemd-kuarrytime" ) time.sleep(0.05) print( "65 root 20 8 281M 2105 0.1 0:00.32 /lib/systend/sytemd-account" ) time.sleep(0.05) print( "234 whop3 20 3 346D 1392 0.1 0:00.16 /lib/systend/accountservice/account-daemon" ) time.sleep(0.05) print( "123 root 18 8 281M 1392 0.1 0:00.33 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "77 quarry2 20 8 281M 2105 0.1 0:00.12 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "55 root 20 4 AQ55 1392 0.1 0:00.22 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "821 kua 20 2 264M 1392 0.8 0:00.06 /usr/bin/downtime3" ) time.sleep(0.05) print( "357 root 20 8 251M 2105 0.3 0:00.13 /usr/lib/kubernetes-upfall" ) time.sleep(0.05) print( "357 syslag 20 0 281M 2105 0.1 0:00.18 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "444 syslag 20 8 581M 2105 0.1 0:00.20 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "357 syslag 20 2 281M 2105 0.2 0:00.1 /usr/lib/sbin/w2444" ) time.sleep(0.05) print( "326 syslag 13 8 284M 1392 0.1 0:00.22 /lib/userbin/dbus/account/files" ) time.sleep(0.05) print( "357 syslag 20 8 751M 1392 0.1 0:00.42 /lib/systend/syslogcheck" ) time.sleep(0.05) print( "347 root 20 3 281M 1392 0.1 0:00.16 /usr/core/client -d - q -sf" ) time.sleep(0.05) print( "886 avahi 20 8 284M 1392 0.3 0:00.53 /usr/core/client -f -d --j" ) time.sleep(0.05) print( "156 root 20 7 281M 1392 0.1 0:00.23 /avaht-daemon-chroot-helper" ) time.sleep(0.05) print( "374 root 20 8 581M 4442 0.1 0:00.16 /service-purefile/leaf-de" ) time.sleep(0.05) print( "284 avahi 24 8 281M 1392 0.1 0:00.65 /usr/direct/files/documents - no pass" ) time.sleep(0.05) print( "347 root 20 1 281M 2236 0.5 0:00.86 /auth/usr/direct/upend" ) time.sleep(0.05) print( "357 kuarry 20 8 250D 1392 0.5 0:00.37 /lib/systend/sytemd-journald" ) time.sleep(0.05) print( "274 root 20 8 261M 1392 0.1 0:00.48 /lightdm-session child 3 5 1" ) time.sleep(0.05) print( "357 root 20 8 781M 2343 0.1 0:00.23 /lightdm-session child 18 5 3" ) time.sleep(0.05) print( "269 avahi 20 8 281M 1392 0.3 0:00.24 /lightdm-session child 43 12 5" ) time.sleep(0.05) print( "357 root 20 3 281M 2105 0.1 0:00.21 /lightdm-session child 22 33 6" ) time.sleep(0.05) print( "357 root 20 8 381M 2105 0.2 0:00.16 /lightdm-session child 7 44 0" ) time.sleep(0.05) print( "235 root 20 8 281M 2105 0.3 0:00.16 /rsnor/latch/bugsetup" ) time.sleep(0.05) print( "357 root 20 2 281M 2105 0.4 0:00.12 /checkfile-waccess-access_auth" ) time.sleep(0.05) print( "123 root 20 8 840F 1392 0.5 0:00.16 /lib/systend/blue-polkdet" ) time.sleep(0.05) print( "357 root 20 8 281M 1392 0.1 0:00.16 /auth/insert/file/uncheck" ) time.sleep(0.05) print( "235 systend-1 20 3 257M 1392 0.1 0:00.16 /lib/systend/sytemd-kuarrytime" ) time.sleep(0.05) print( "65 root 20 8 281M 2105 0.1 0:00.32 /lib/systend/sytemd-account" ) time.sleep(0.05) print( "234 whop3 20 3 346D 1392 0.1 0:00.16 /lib/systend/accountservice/account-daemon" ) time.sleep(0.05) print( "123 root 18 8 281M 1392 0.1 0:00.33 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "77 quarry2 20 8 281M 2105 0.1 0:00.12 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "55 root 20 4 AQ55 1392 0.1 0:00.22 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "821 kua 20 2 264M 1392 0.8 0:00.06 /usr/bin/downtime3" ) time.sleep(0.05) print( "357 root 20 8 251M 2105 0.3 0:00.13 /usr/lib/kubernetes-upfall" ) time.sleep(0.05) print( "357 syslag 20 0 281M 2105 0.1 0:00.18 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "444 syslag 20 8 581M 2105 0.1 0:00.20 /usr/lib/sytemd-snapd" ) time.sleep(0.05) print( "357 syslag 20 2 281M 2105 0.2 0:00.1 /usr/lib/sbin/w2444" ) time.sleep(0.05) print( "326 syslag 13 8 284M 1392 0.1 0:00.22 /lib/userbin/dbus/account/files" ) time.sleep(0.05) print( "357 syslag 20 8 751M 1392 0.1 0:00.42 /lib/systend/syslogcheck" ) time.sleep(0.05) print( "347 root 20 3 281M 1392 0.1 0:00.16 /usr/core/client -d - q -sf" ) time.sleep(0.05) print( "886 avahi 20 8 284M 1392 0.3 0:00.53 /usr/core/client -f -d --j" ) time.sleep(0.05) print( "156 root 20 7 281M 1392 0.1 0:00.23 /avaht-daemon-chroot-helper" ) time.sleep(0.05) print( "374 root 20 8 581M 4442 0.1 0:00.16 /service-purefile/leaf-de" ) time.sleep(0.05) print( "284 avahi 24 8 281M 1392 0.1 0:00.65 /usr/direct/files/documents - no pass" ) time.sleep(0.05) print( "347 root 20 1 281M 2236 0.5 0:00.86 /auth/usr/direct/upend" ) time.sleep(0.05) print( "357 kuarry 20 8 250D 1392 0.5 0:00.37 /lib/systend/sytemd-journald" ) time.sleep(0.05) print( "274 root 20 8 261M 1392 0.1 0:00.48 /lightdm-session child 3 5 1" ) time.sleep(0.05) print( "357 root 20 8 781M 2343 0.1 0:00.23 /lightdm-session child 18 5 3" ) time.sleep(0.05) print( "269 avahi 20 8 281M 1392 0.3 0:00.24 /lightdm-session child 43 12 5" ) time.sleep(0.05) print( "357 root 20 3 281M 2105 0.1 0:00.21 /lightdm-session child 22 33 6" ) time.sleep(0.05) print( "357 root 20 8 381M 2105 0.2 0:00.16 /lightdm-session child 7 44 0" ) time.sleep(0.05) print( "235 root 20 8 281M 2105 0.3 0:00.16 /rsnor/latch/bugsetup" ) time.sleep(0.05) print( "357 root 20 2 281M 2105 0.4 0:00.12 /checkfile-waccess-access_auth" ) time.sleep(0.05) print( "123 root 20 8 840F 1392 0.5 0:00.16 /lib/systend/blue-polkdet" ) time.sleep(0.05) print( "357 root 20 8 281M 1392 0.1 0:00.16 /auth/insert/file/uncheck" ) time.sleep(0.05) print( "235 systend-1 20 3 257M 1392 0.1 0:00.16 /lib/systend/sytemd-kuarrytime" ) time.sleep(0.05) print( "65 root 20 8 281M 2105 0.1 0:00.32 /lib/systend/sytemd-account" ) time.sleep(0.05) print( "234 whop3 20 3 346D 1392 0.1 0:00.16 /lib/systend/accountservice/account-daemon" ) time.sleep(0.05) print( "357 syslag 20 2 281M 2105 0.2 0:00.1 /usr/lib/sbin/w2444" ) time.sleep(0.05) print( "326 syslag 13 8 284M 1392 0.1 0:00.22 /lib/userbin/dbus/account/files" ) time.sleep(0.05) print( "357 syslag 20 8 751M 1392 0.1 0:00.42 /lib/systend/syslogcheck" ) time.sleep(0.05) print( "347 root 20 3 281M 1392 0.1 0:00.16 /usr/core/client -d - q -sf" ) time.sleep(0.05) print( "886 avahi 20 8 284M 1392 0.3 0:00.53 /usr/core/client -f -d --j" ) time.sleep(0.05) print( "156 root 20 7 281M 1392 0.1 0:00.23 /avaht-daemon-chroot-helper" ) time.sleep(0.05) print( "374 root 20 8 581M 4442 0.1 0:00.16 /service-purefile/leaf-de" ) time.sleep(0.05) print( "284 avahi 24 8 281M 1392 0.1 0:00.65 /usr/direct/files/documents - no pass" ) time.sleep(0.05) print( "347 root 20 1 281M 2236 0.5 0:00.86 /auth/usr/direct/upend" ) time.sleep(0.05) print( "357 kuarry 20 8 250D 1392 0.5 0:00.37 /lib/systend/sytemd-journald" ) time.sleep(0.05) print( "274 root 20 8 261M 1392 0.1 0:00.48 /lightdm-session child 3 5 1" ) time.sleep(0.05) print( "357 root 20 8 781M 2343 0.1 0:00.23 /lightdm-session child 18 5 3" ) time.sleep(0.05) print( "269 avahi 20 8 281M 1392 0.3 0:00.24 /lightdm-session child 43 12 5" ) time.sleep(0.05) print( "357 root 20 3 281M 2105 0.1 0:00.21 /lightdm-session child 22 33 6" ) time.sleep(0.05) print( "357 root 20 8 381M 2105 0.2 0:00.16 /lightdm-session child 7 44 0" ) time.sleep(0.05) print( "235 root 20 8 281M 2105 0.3 0:00.16 /rsnor/latch/bugsetup" ) time.sleep(0.05) print( "357 root 20 2 281M 2105 0.4 0:00.12 /checkfile-waccess-access_auth" ) time.sleep(0.05) print( "123 root 20 8 840F 1392 0.5 0:00.16 /lib/systend/blue-polkdet" ) time.sleep(0.05) print( "357 root 20 8 281M 1392 0.1 0:00.16 /auth/insert/file/uncheck" ) time.sleep(0.05) print( "235 systend-1 20 3 257M 1392 0.1 0:00.16 /lib/systend/sytemd-kuarrytime" ) time.sleep(0.05) print( "65 root 20 8 281M 2105 0.1 0:00.32 /lib/systend/sytemd-account" ) time.sleep(0.05) print( "234 whop3 20 3 346D 1392 0.1 0:00.16 /lib/systend/accountservice/account-daemon" ) helpers().clearScreen() time.sleep(2) print("access user") time.sleep(0.1) print(current_time) time.sleep(0.1) print("AQ_SECURE_SYSTEMS_v3.2654.2\n") time.sleep(0.5) print("WARNING: LEVEL 5 Authorization Needed\n") time.sleep(0.5) user = input("USERNAME: "******"Password: "******"\nACCESS TO SYSTEM") else: while pswd != 'Quarry1': print("ACCESS DENIED\nPassword or username invalid\n") pswd = getpass.getpass("Password: "******"\nACCESS TO SYSTEM") time.sleep(2) dots = "Initializing . . . ." print("Kuarry Terminal Trivia Version 2.1.3") time.sleep(.1) print("\n*** connecting to port_6667 of #channel irc") time.sleep(0.1) print("*** loading .ircr version 2.9+Crlf+F08") time.sleep(0.1) print("*** users on #channel: " + user) for dot in dots: sys.stdout.write(dot) sys.stdout.flush() if dot == '.': time.sleep(0.4) else: time.sleep(0.05) helpers().clearScreen() print(" ") print(" ") print(" ") print(" ``........`` ") print(" `.---------------.` ") print(" `.------..`.o``..------.` ") print(" `.----.` `dMy `.----. ") print(" `----. .mMMMh` `.----` ") print(" `----` .mMm/NMd` .---- ") print(" ----` -NMh` .mMd` .---. ") print(" `---- :NMy `dMm. ---- ") print(" `---. /MMo `hMN- ----` ") print(" `---- +MM/ sMN: ---- ") print(" ----` oMMy///////////dMM/ .---. ") print(" `----`sMMMMMMMMMMMMMMMMMMM/.----`````` ") print(" `----. .sMMMMMMMMM/ ") print(" `-----.` `.---/mMo +MM: ") print(" `------..```````..-----.``yMmMN: ") print(" `.----------------..` /NN- ") print(" ``....-....`` .. ") print(" ") print(" ") print(" LOADING . . . ") for d in bar: sys.stdout.write(d) sys.stdout.flush() if d == ' ': time.sleep(0.001) else: time.sleep(0.4) time.sleep(.5)
def __init__(self,basedir=".",mode="initial",kernel=0): self.basedir = basedir self.mode = mode self.cores = multiprocessing.cpu_count() self.wrapper = wrappers.gromacswrapper() self.distparser = parser.gdistparser() self.filesystem = filesystem.filesystem() self.interfaces = interfaces.interfaces() self.orderparameters = orderparameters.orderparameters() self.helper = helpers.helpers() self.kernels = kernels.kernels(kernel) self.qsubsystem = qsubsystem.qsubsystem() #Initialize the logger if kernel=="head": self.log = gtpslogging.log("info",basedir,kernel) elif kernel=="reverse": self.log = gtpslogging.log("info",basedir,kernel) else: self.log = gtpslogging.log("info",basedir,kernel) self.log.log.debug("logfile created") self.log.log.info(str(self.cores) + " CPUs detected") self.interfaces.readInterfaces(os.path.join(basedir,"options","interfaces.txt")) self.log.log.info("Read Interfaces Forward : " + str(self.interfaces.interfaces[0])) self.log.log.info("Read Interfaces Backward : " + str(self.interfaces.interfaces[1])) self.kernels.readKernelOptions(os.path.join(basedir,"options","kerneloptions.txt")) #read the stables states from a file self.orderparameters.readOP(os.path.join(basedir,"options","orderparameters.txt")) self.log.log.info("Read OP : " + str(self.orderparameters.op[0])) """ This array holds all the information about the paths. Each trajectory consists of a forward-part and a backward-part. The trajectory can either be a forward trajectory or a backward trajectory. Forward trajectroies start in A. """ self.paths = [] self.npaths = 0 for i in range(self.interfaces.ninterfaces[0]): self.paths.append(pathdata.pathdata(i,basedir,mode,forward=True,forwardpart=True,interface=self.interfaces.interfaces[0][i])) self.paths.append(pathdata.pathdata(i,basedir,mode,forward=True,forwardpart=False,interface=self.interfaces.interfaces[0][i])) self.npaths += 1 for i in range(self.interfaces.ninterfaces[1]): n = i + self.interfaces.ninterfaces[0] self.paths.append(pathdata.pathdata(n,basedir,mode,forward=False,forwardpart=True,interface=self.interfaces.interfaces[1][i])) self.paths.append(pathdata.pathdata(n,basedir,mode,forward=False,forwardpart=False,interface=self.interfaces.interfaces[1][i])) self.npaths += 1 self.reversePaths = [] for rp in self.interfaces.reversepaths[0]: self.reversePaths.append(pathdatareverse.pathdatareverse(0, basedir, mode, forward=True, forwardpart=True, interface=rp, state=0)) for rp in self.interfaces.reversepaths[1]: self.reversePaths.append(pathdatareverse.pathdatareverse(0, basedir, mode, forward=True, forwardpart=True, interface=rp, state=1)) self.kernels.generateKernelLists(self.npaths) self.interfacedir = int(float(self.paths[0].options.runoptions["interfacecoordinate"])) print self.interfacedir
) elif featureFilters[i] == "byCount": filter = lambda feature, count: count >= 40 and count <= 2000 else: filter = lambda feature, count: True featureDataFiles.append( dataFileDescriptor( os.path.join(featureFileBaseDir, featureFiles[i]), filter)) logOutputDir = knowEngRoot + "KnowEng/logs/" + date.today().isoformat() if not os.path.isdir(logOutputDir): os.mkdir(logOutputDir) loggerObj = logger(baseDir=logOutputDir) helperObj = helpers(loggerObj) dataRetriever = dataGrabber(loggerObj) featureFiles[0] = os.path.join(featureFileBaseDir, featureFiles[0]) #featureFiles[1] = os.path.join(featureFileBaseDir, featureFiles[1]) loggerObj.log("Features from file: {0}\nLabels from file: {1}".format( featureFiles[0], labelFile)) (dict_X, dict_y, positiveKeys, negativeKeys) = dataRetriever.getDCAData2(featureFiles[0], labelFile) doLASSO = bool( grabOptionOrDefault(config, testName, "LASSO", default="False") in ["True", "true", "1"]) alpha = float( grabOptionOrDefault(config, testName, "alpha", default=1.0)) x = Classifier(loggerObj,
# params DIRECTORY = 'C:\AI\DATA' # os.path.dirname(__file__) DIRECTORY2 = 'C:\AI\WEIGHTS' SHUTDOWN_AFTER_TRAINING = True NUMBER_OF_IMAGES = 700 ##### SET UP FASTENET ##### ##### SET UP FASTENET ##### ##### SET UP FASTENET ##### VERSION_NUMBER = 5 MARK_NUMBER = 506 # instantiate helper object FasteNet_helper = helpers(mark_number=MARK_NUMBER, version_number=VERSION_NUMBER, weights_location=DIRECTORY2) device = FasteNet_helper.get_device() # set up net and make sure in inference mode FasteNet = FasteNet_v2().to(device) FasteNet.eval() FasteNet.freeze_model() # get latest weight file weights_file = FasteNet_helper.get_latest_weight_file() if weights_file != -1: FasteNet.load_state_dict(torch.load(weights_file)) ##### SET UP ACTORCRITIC ##### ##### SET UP ACTORCRITIC #####
def __init__(self, logger, dict_X, dict_y, shouldSMOTE=False, smote_N=100, smote_k=5, doLASSO=False, alpha=1.0, kCrossValPos=0, kCrossValNeg=0, verbose=False): # class variables to initialize general classifier self.logger = logger self.verbose = verbose self.helperObj = helpers(logger) self.dict_X = dict_X.copy() self.dict_y = dict_y.copy() self.kCrossValPos = kCrossValPos self.kCrossValNeg = kCrossValNeg self.hidden_X = [] self.hidden_y = [] self.totalExamples = len(self.dict_X) self.featureDims = len(self.dict_X.values()[0]) print self.featureDims (self.allPosExampleKeys, self.allNegExampleKeys) = self.helperObj.getLabelSets(dict_y) self.numAllPosExamples = len(self.allPosExampleKeys) self.numAllNegExamples = len(self.allNegExampleKeys) self.crossValExcludeSet = set() self._hideSamples() if shouldSMOTE: sampler = ExampleSampler(dict_X, dict_y, self.logger) trainPosKeys = list( set(self.allPosExampleKeys) - set(self.hiddenPosExampleKeys)) self.dict_X, self.dict_y, self.crossValExcludeSet = sampler.smote( trainPosKeys, smote_N, smote_k, 1) self.crossValExcludeSet = set(self.crossValExcludeSet) self.totalExamples = len(self.dict_X) self.featureDims = len(self.dict_X.values()[0]) (self.allPosExampleKeys, self.allNegExampleKeys) = self.helperObj.getLabelSets(dict_y) self.numAllPosExamples = len(self.allPosExampleKeys) self.numAllNegExamples = len(self.allNegExampleKeys) if doLASSO: positiveExampleKeys = set(self.allPosExampleKeys) - set( self.hiddenPosExampleKeys) negativeExampleKeys = set(self.allNegExampleKeys) - set( self.hiddenNegExampleKeys) y = ([1] * len(positiveExampleKeys)) + ([0] * len(negativeExampleKeys)) X = self.helperObj.dictOfFeaturesToList(self.dict_X, positiveExampleKeys) + \ self.helperObj.dictOfFeaturesToList(self.dict_X, negativeExampleKeys) clf = linear_model.Lasso(alpha=alpha, selection="random") clf.fit(X, y) coefs = np.array(clf.coef_) zeroCoefIndices = np.where(coefs == 0)[0].tolist() for key in self.dict_X.iterkeys(): self.dict_X[key] = np.delete(self.dict_X[key], zeroCoefIndices, 0).tolist() self.hidden_X = np.delete(self.hidden_X, zeroCoefIndices, 1).tolist() self.featureDims = len(self.dict_X.values()[0]) self.logger.log("Data size: {0} x {1}".format(self.featureDims, self.totalExamples)) self.logger.log("Total Number of Positive Examples: {0}".format( self.numAllPosExamples)) self.logger.log("Number of Hidden Positive Examples: {0}".format( self.numHiddenPosExamples)) self.logger.log("Total Number of Negative Examples: {0}".format( self.numAllNegExamples)) self.logger.log("Number of Hidden Negative Examples: {0}".format( self.numHiddenNegExamples)) # holds the trained classifier after training self.trainedClassifier = None
def __init__(self, dict_X, dict_y, logger): self.helpersObj = helpers(logger) self.logger = logger self.dict_X = dict_X self.dict_y = dict_y
from dataGrabber import dataGrabber, dataFileDescriptor from helpers import helpers from logger import logger loggerObj = logger(shouldLog=False) helperObj = helpers(loggerObj) filterTermsByCount = lambda feature, count: count >= 40 and count <= 2000 breastCancerLabelFile = "/home/alex/KnowEng/data/VANTVEER_BREAST_CANCER_ESR1.CB.txt" keggDataFile = dataFileDescriptor("/home/alex/KnowEng/data/ENSG.kegg_pathway.txt") goDataFile = dataFileDescriptor("/home/alex/KnowEng/data/ENSG.go_%_evid.txt", filterTermsByCount) dataRetriever = dataGrabber(loggerObj) (featureVectorDict, labelDict, dataIndices) = dataRetriever.getData(breastCancerLabelFile, [goDataFile, keggDataFile]) dataRetriever.convertToCSV(featureVectorDict, labelDict, "test.csv", 45)
if len(errList) > 0: print("The following pathon3 modules need to be installed for thos app:") print(", ".join(errList)) exit("exiting...") #------------------------------------ from flask import Flask, request, session #import ldap3 from ldap3 import Server, Connection, SAFE_SYNC from helpers import helpers, ldaptool, mysqltool #------------------------------------------------------------------ #-Global Vars------------------------------------------------------ CurPath = os.path.dirname(os.path.realpath(__file__)) myHelper = helpers() myLdapTool = ldaptool() myMysqlTool = mysqltool() # try: myHelper # except: myHelper = helpers() # try: myLdapTool.con_check() # except: myLdapTool = ldaptool() # try: myMysqlTool.con_check() # except: myMysqlTool = mysqltool() #-Build the flask app object--------------------------------------- app = Flask(__name__) app.secret_key = "changeit" app.debug = True
distance = db.findDistanceMatrix(dataset) eps = float(input("Enter the value for epsilon parameter: ")) minpts = int( input("Enter the minimum number of pts for a core point: ")) db.dbScan(dataset, eps=eps, minpts=minpts, distance=distance) result = hp.sort_result(dataset) return dataset, result if __name__ == "__main__": choice = int( input( "\nPress 1 for k-means\nPress 2 for Hierarchical Clustering\nPress 3 for Density based Clustering\nPress 4 for Gaussian Mixture Model Clustering\nPress 5 for Spectral Clustering\n" )) m = main() hp = helpers() if choice == 1: dataset, filename = hp.get_file() dataset, result, centroids = m.kmeans(dataset) dataset, ids, predicted = hp.create_pd(dataset) elif choice == 2: dataset, predicted, ids, filename = m.hrClustering() elif choice == 3: dataset, filename = hp.get_file() dataset, result = m.density(dataset) dataset, ids, predicted = hp.create_pd(dataset) elif choice == 4: dataset, predicted, ids, filename = m.gmmClustering() else: dataset, filename = hp.get_file() dataset, result = m.spectral(dataset)
import sys import googlemaps from datetime import datetime, date from datetime import timedelta try: from config import config except: print("No existe el archivo config, stop") sys.exit() from helpers import helpers H = helpers() def groute(start, end, timet, mode="walking"): gmaps = googlemaps.Client(key=config.gmapsAPI) if mode == "transit": today = datetime.today() #last_monday = today - datetime.timedelta(days=today.weekday()) timet = today + timedelta((4 - today.weekday()) % 7) #print("timet",str(int(timet.timestamp()))) #timet=(int(timet.timestamp())) # Geocoding an address #geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA') # Look up an address with reverse geocoding #reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452)) # Request directions via public transit