How to use print_errors method in Gherkin-python

Best Python code snippet using gherkin-python

api.py

Source:api.py Github

copy

Full Screen

1import json2import csv3import redis4from typing import List5from flask import Flask, request, jsonify, send_file6import jobs7import print_errors8import logging9logging.basicConfig(level=logging.DEBUG)10#Creating app, an instance of the flask variable11app = Flask(__name__)12#This is the route that will show the user all the possible routes that they can choose from13@app.route("/", methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])14def info() -> str:15 """16 This function will show to the user all the possible routes that they can choose from17 Args: 18 None19 Output:20 (string)21 """22 if(request.method == 'GET'):23 return print_errors.welcome_message()24 else:25 return print_errors.error('curl -X GET localhost:5036/')26#This route is to load the data into redis, db=027@app.route('/data', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])28def load_asteroid_data_into_redis() -> str:29 '''30 This function will put the dataset.csv into the redis server. All of the 31 raw data will be saved on db = 032 Args:33 None34 Returns:35 (string) it will return a message to the user telling them that the data 36 has been stored or the incorrect method was used and an error message will37 be shown to the user38 '''39 #This if for storing the data into the redis database in db=040 if(request.method == 'POST'):41 #Deletes all the items inside db=042 jobs.rd.flushdb()43 #This will populate the redis db=044 data = {}45 count = 046 data['asteroid_data'] = []47 with open("dataset.csv", 'r') as f:48 dataset = csv.DictReader(f)49 for row in dataset:50 data['asteroid_data'].append(dict(row))51 count = count + 152 if(count == 100000):53 break54 #Populating the redis db=055 for item in data['asteroid_data']:56 jobs.rd.set(item['id'], json.dumps(item))57 return '\n\nThe data has been successfully been stored in redis, in db=0\n\n'58 else:59 return print_errors.error('curl -X POST localhost:5036/data')60#This route will return a list of all the items in redis db=061@app.route("/job/data/read", methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])62def read_data():63 '''64 This function will return a list of all the dictonaries that were added to the redis db=065 Input:66 (None)67 Output:68 (list of dicts) that contain all the information that was added to redis69 '''70 #We need to check that the db=0 is infact been populated71 if(len(jobs.rd.keys()) == 0):72 return print_errors.db0_is_empty('curl -x GET localhost:5036/data/read')73 #Checking that the verb is a GET74 if(request.method == 'GET'):75 job_dict = jobs.add_job('/job/data/read', 'list of dicts')76 jid = job_dict['id']77 #we are going to add the job_id into a new redis database, and the route as the key value78 jobs.job_list.set('/job/data/read', jid)79 #Returns a message to the user explaning the next steps that need to be done80 return print_errors.job_confi('curl -X GET localhost:5036/job/data/read', jid)81 else:82 return print_errors.error('curl -X GET localhost:5036/data/read')83#This function will return a list of all the job id84@app.route("/stored/job-ids", methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])85def return_all_ids():86 """87 This function will return a list of all the keys and values that are in the redis88 database, db=489 Input:90 (none)91 Output:92 (list) return a list of all the key and values that have been stored in db=493 """94 #Checking that db=4 is not empty95 if(len(jobs.job_list.keys()) == 0):96 return print_errors.db4_is_empty()97 if(request.method == 'GET'):98 list_of_id = []99 for item in jobs.job_list.keys():100 mini_list = []101 mini_list.append(item)102 mini_list.append(jobs.job_list.get(item))103 list_of_id.append(mini_list)104 return jsonify(list_of_id)105 else:106 return print_errors.error('curl -X GET localhost:5036/stored/job-ids')107#This route will return what is stored in the the answer database or it will return a print statemet108@app.route("/job/result/<jid>", methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])109def get_results(jid):110 """111 This function is going to return the result of the job id that was created112 Input:113 jid (str): It is the job id that created when the user instantiated the job114 Output:115 It will return the result back to the user.116 """117 #Checking if db=3 is empty118 if(len(jobs.answers.keys()) == 0):119 return print_errors.db3_is_empty()120 #Getting the result back to the user121 if(request.method == 'GET'):122 job_dictionary = jobs.get_job_by_id(jid)123 logging.warning('The item of job_dictionary is: ', print(job_dictionary['return_type']))124 125 #This will check if the return value has been completed126 if(job_dictionary['status'] != 'complete'):127 return print_errors.return_not_finished(jid)128 #Incase the return type is list of dictionaries129 if(job_dictionary['return_type'] == 'list of dicts'):130 logging.warning('It is inside the list of dicts')131 list_of_dict = json.loads(jobs.answers.get(jid))132 json.dumps(list_of_dict, sort_keys=False, indent=2)133 # logging.warning('the type of list_of_dict is:', type(list_of_dict))134 return jsonify(list_of_dict)135 #Incase the return type is a list136 elif(job_dictionary['return_type'] == 'list'):137 logging.warning('It is inside the list if statement')138 normal = json.loads(jobs.answers.get(jid))139 json.dumps(normal, sort_keys=False, indent=2)140 return jsonify(normal)141 #Incase the return type is a string142 elif(job_dictionary['return_type'] == 'string'):143 logging.warning('It is inside the string if statement')144 145 #Returns the string message to the user146 return jobs.answers.get(jid)147 148 #Incase the return type is a graph149 elif(job_dictionary['return_type'] == 'graph'):150 logging.warning("It is inside the graph statement")151 job_key = jobs._generate_job_key(jid)152 logging.warning("The value for images is: ", str(jobs.jdb.hget(job_key, 'images')))153 path = f'/pics/{job_key}.png'154 with open(path, 'wb') as f:155 f.write(jobs.jdb.hget(job_key, 'image'))156 return send_file(path, mimetype='image/png', as_attachment=True)157 #Incase the return type is dictionary158 elif(job_dictionary['return_type'] == 'dictionary'):159 logging.warning("It is inside the dictionary if statement")160 #It converts it from a string dictionary to a python dictionary161 returned_dictionary = json.loads(jobs.answers.get(jid))162 #returns the returned_dictionary163 return jsonify(returned_dictionary) 164 #This would happen if the return_type was different from anything else165 else:166 return f'''167The route that was curled below.168'''169 else:170 return print_errors.error('curl -X GET localhost:5036/job/id')171#This route will get rid of all the items in the job_list db=4172@app.route('/joblist/delete', methods =['DELETE', 'GET', 'PUT', 'PATCH', 'POST'])173def delete_all_ids():174 """175 This function will delete all the pending job in the job list176 Input:177 (None)178 Output:179 (string): It will tell the user of that the db=4 is empty180 """181 if(request.method == 'DELETE'):182 jobs.job_list.flushdb()183 return print_errors.db4_is_empty()184 else:185 return print_errors.error('curl -X DELETE localhost:5036/joblist/delete')186#This route will get rid of all the items in the jdb db=2187@app.route('/jdb/delete', methods = ['GET', 'DELETE', 'PUT', 'PATCH', 'POST'])188def delete_all_jdb():189 """190 This function will delete all the jdb in the db=2191 Input:192 (none)193 Output:194 (string): IT will tell the iser of that db=2 is empty195 """196 if(request.method == "DELETE"):197 jobs.jdb.flushdb()198 return print_errors.db2_is_empty()199 200 else:201 return print_errors.error('curl -X DELETE localhost:5036/jdb/delete')202#This function will get rid of all the items in the redis database for db=3203@app.route("/answers/delete", methods = ['DELETE', 'GET', 'PUT', 'PATCH', 'POST'])204def delete_all_answers():205 """206 This function will delete all the answers in the answers database, db=3207 Input:208 (None)209 Output:210 (string): It iwll tell the user that all the saved answers have been deleted211 """212 if(request.method == 'DELETE'):213 jobs.answers.flushdb()214 return print_errors.db3_is_empty2()215 else:216 return print_errors.error('curl -X DELETE localhost:5036/answers/delete')217# this route returns a list of all asteroid ids218@app.route("/job/ids", methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])219def list_ids():220 """221 This function will return a list that contains all the id's in the database.222 Input:223 (None)224 Output: 225 (list) that contains all the ids of the asteroid.226 """227 # checking that db 0 is populated228 if(len(jobs.rd.keys()) == 0):229 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/ids')230 # making sure that user is calling GET231 if(request.method == 'GET'):232 233 job_dict = jobs.add_job('/job/ids', 'list')234 jid = job_dict['id']235 #we are going to add the job_id into a new redis databse, and the route as the key value236 jobs.job_list.set('/job/ids', jid)237 #returns a message to the user explaning the next steps that need to be done238 return print_errors.job_confi('curl -X GET localhost:5036/job/ids', jid)239 else:240 return print_errors.error('curl -X GET localhost:5006/id')241# this route returns a list of all asteroid names242@app.route("/job/names", methods = ['GET', 'POST', 'DELETE', 'PATCH'])243def list_names():244 # checking that db 0 is populated245 if(len(jobs.rd.keys()) == 0):246 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/names')247 # making sure that user is calling GET248 if(request.method == 'GET'):249 #adds it to the queue, jdb250 job_dict = jobs.add_job('/job/names', 'list')251 jid = job_dict['id']252 #adds it to the job list253 jobs.job_list.set('/job/names', jid)254 #This prints a confirmation string to the user255 return print_errors.job_confi('curl -X GET localhost:5036/job/names', jid)256 else:257 return print_errors.error('curl -X GET localhost:5006/name')258# this route returns a list of names of near earth orbit asteroids259@app.route("/job/neo", methods = ['GET', 'POST', 'DELETE', 'PATCH'])260def list_neos():261 # checking that db 0 is populated262 if(len(jobs.rd.keys()) == 0):263 return print_errors.db0_is_empty('curl -x GET localhost:5036/neo')264 # making sure that user is calling GET265 if(request.method == 'GET'):266 #Adds it to the queue, jdb, it will determine at the very end it will return a list or a string267 job_dict = jobs.add_job('/job/neo', 'list')268 jid = job_dict['id']269 #adds it to the job list270 jobs.job_list.set('/job/neo', jid)271 #This prints a confirmation string to the user272 return print_errors.job_confi('curl -X GET localhost:5036/job/neo', jid)273 else:274 return print_errors.error('curl -X GET localhost:5006/neo')275# this route returns a list of names of potentially hazardous asteroids276@app.route("/job/pha", methods = ['GET', 'POST', 'DELETE', 'PATCH'])277def list_phas():278 # checking that db 0 is populated279 if(len(jobs.rd.keys()) == 0):280 return print_errors.db0_is_empty('curl -x GET localhost:5036/pha')281 # making sure that user is calling GET282 if(request.method == 'GET'):283 #Adds it to the queue, jdb, it will determine at the very end it will return a list or a string284 job_dict = jobs.add_job('/job/neo', 'list')285 jid = job_dict['id']286 #adds it to the job list287 jobs.job_list.set('/job/pha', jid)288 #This prints a confirmation string to the user289 return print_errors.job_confi('curl -X GET localhost:5036/job/pha', jid)290 else:291 return print_errors.error('curl -X GET localhost:5006/pha')292# this route returns a list of all asteroid diameterss293@app.route("/job/diameters", methods = ['GET', 'POST', 'DELETE', 'PATCH'])294def list_diameters():295 """296 This function is just going to get the job_id in order for the worker to do the work297 Input:298 (none)299 Output:300 (none)301 """302 # checking that db 0 is populated303 if(len(jobs.rd.keys()) == 0):304 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/diameters')305 # making sure that user is calling GET306 if(request.method == 'GET'):307 #Adds it to the queue, jdb, it will determine at the very end it iwll return a string or a list308 job_dict = jobs.add_job('/job/diameters', 'list')309 jid = job_dict['id']310 #We are going to add the job_id into a new redis database, and the route as the key value311 jobs.job_list.set('/job/diameters', jid)312 #Returns a confirmation string back to the user313 return print_errors.job_confi('curl -X GET localhost:5036/job/diameters', jid)314 else:315 return print_errors.error('curl -X GET localhost:5036/job/diameters')316'''317# This route returns a png of the bell curve of all the diameters318@app.route("/job/diameter/gaussian_distribution", method = ['GET', 'PUT', 'POST', 'DELETE'])319def bell_curve_diam():320 # checking that db 0 is populated321 if(len(jobs.rd.keys()) == 0):322 return print_errors.db0_is_empty('curl -x GET localhost:5031/job/diameter/guassian_distribution')323 # making sure that user is calling GET324 if(request.method == 'GET'):325 #Adds it to the queue, jdb, it will determine at the very end it iwll return a string or a list326 job_dict = jobs.add_job('/job/diameter/guassian_distribution', 'list')327 jid = job_dict['id']328 #We are going to add the job_id into a new redis database, and the route as the key value329 jobs.job_list.set('/job/diameter/guassian_distribution', jid)330 #Returns a confirmation string back to the user331 return print_errors.job_confi('curl -X GET localhost:5031/job/diameter/guassian_distribution', jid)332 else:333 return print_errors.error('curl -X GET localhost:5036/job/diameter/guassian_distribution')334'''335# this route returns the name and value of the asteroid with the largest diameter336@app.route("/job/diameters/max", methods =['GET', 'PUT', 'POST', 'DELETE'])337def diameter_largest():338 # checking that db 0 is populated339 if(len(jobs.rd.keys()) == 0):340 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/diameters/max')341 # making sure that user is calling GET342 if(request.method == 'GET'):343 #Adds it to the queue, jdb, it will determine at the very end it iwll return a string or a list344 job_dict = jobs.add_job('/job/diameters/max', 'string')345 jid = job_dict['id']346 #We are going to add the job_id into a new redis database, and the route as the key value347 jobs.job_list.set('/job/diameters/max', jid)348 #Returns a confirmation string back to the user349 return print_errors.job_confi('curl -X GET localhost:5036/job/diameters/max', jid)350 else:351 return print_errors.error('curl -X GET localhost:5036/job/diameters/max')352# this route returns the name and value of the asteroid with the smallest diameter353@app.route("/job/diameters/min", methods =['GET', 'PUT', 'POST', 'DELETE'])354def diameter_smallest():355 # checking that db 0 is populated356 if(len(jobs.rd.keys()) == 0):357 return print_errors.db0_is_empty('curl -x GET localhost:5036/diameter/min')358 # making sure that user is calling GET359 if(request.method == 'GET'):360 #Adds it to the queue, jdb, it will determine at the very end it will return a string361 job_dict = jobs.add_job('/job/diameters/min', 'string')362 jid = job_dict['id']363 #We are going to add the job_id into a new redis database, and the route as the key value364 jobs.job_list.set('/job/diameters/min', jid)365 #Returns a confirmation string back to the user366 return print_errors.job_confi('curl -X GET localhost:5036/job/diameters/min', jid)367 else:368 return print_errors.error('curl -X GET localhost:5036/job/diameters/max')369 370# this route returns a list of all asteroid moid_lds371@app.route("/job/moid_ld", methods =['GET', 'PUT', 'POST', 'DELETE'])372def list_moid_lds():373 # checking that db 0 is populated374 if(len(jobs.rd.keys()) == 0):375 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/moid_ld')376 # making sure that user is calling GET377 if(request.method == 'GET'):378 job_dict = jobs.add_job('/job/moid_ld', 'list')379 jid = job_dict['id']380 jobs.job_list.set('/job/moid_ld', jid)381 return print_errors.job_confi('curl -X GET localhost:5036/job/moid_ld', jid)382 else:383 return print_errors.error('curl -X GET localhost:5036/job/moid_ld')384# this route returns the list of moid_lds in ascending order (least to greatest)385@app.route("/job/moid_ld/ascending", methods =['GET', 'PUT', 'POST', 'DELETE'])386def ascending_moid_lds():387 388 # checking that db 0 is populated389 if(len(jobs.rd.keys()) == 0):390 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/moid_ld/ascending')391 # making sure that user is calling GET392 if(request.method == 'GET'):393 job_dict = jobs.add_job('/job/moid_ld/ascending', 'list')394 jid = job_dict['id']395 jobs.job_list.set('/job/moid_ld/ascending', jid)396 return print_errors.job_confi('curl -X GET localhost:5036/job/moid_ld/ascending', jid)397 else:398 return print_errors.error('curl -X GET localhost:5036/job/moid_ld/ascending')399'''400# this route returns a histogram of all moid_lds401@app.route("/job/moid_ld/graph", methods =['GET', 'PUT', 'POST', 'DELETE'])402def moid_graph():403 # checking that db 0 is populated404 if(len(jobs.rd.keys()) == 0):405 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/moid_ld/graph')406 # making sure that user is calling GET407 if(request.method == 'GET'):408 job_dict = jobs.add_job('/job/moid_ld/graph', 'graph')409 jid = job_dict['id']410 jobs.job_list.set('job/moid_ld/graph', jid)411 return print_errors.job_confi('curl -X GET localhost:5036/job/moid_ld/graph', jid)412 else:413 return print_errors.error('curl -X GET localhost:5036/job/moid_ld/graph')414'''415#This function will return a dictionary that to the user pertaining to an inputted id416@app.route('/job/ids/<specific_id>', methods=['POST', 'PUT', 'DELETE', 'PATCH', 'GET'])417def specific_id_info(specific_id):418 """419 This function the will start a job instance420 Input:421 specific_id (string): It is the id that the user is inputting 422 Output:423 None: Nothing, the only thing that is happening is putting this job into the queue 424 """425 # checking that db 0 is populated426 if(len(jobs.rd.keys()) == 0):427 return print_errors.db0_is_empty('curl -x GET localhost:5036/job/ids/<specific_id>')428 429 #Checking that the user is curling with get430 if(request.method == 'GET'):431 #This is a list that has all the query432 user_query = f'{specific_id}'433 #Strating thing434 job_dict = jobs.add_job('/job/ids/<specific_id>', 'dictionary', user_query)435 jid = job_dict['id']436 437 #we are going to add the job_id into a new redis databse, and the route as the key value438 jobs.job_list.set('/job/ids/<specific_id>', jid)439 #This will print a confimation string to the user440 return print_errors.job_confi('curl -X GET localhost:5036/job/ids/<specific_id>', jid)441 else:442 #This will print to the user the correct route that needs to be used443 return print_errors.error('curl -X GET localhost:5006/id/<specific_id>')444#Deletes all of the data in db=0 445@app.route("/data/reset", methods =['GET', 'PUT', 'POST', 'DELETE'])446def rest_db_data() -> str:447 """448 This function will delete all the data in the redis database (db=0).449 Input:450 (None)451 Output:452 (String) it will return a message to the user that the data inside the 453 redis db has been deleted454 """455 if(request.method=="DELETE"):456 jobs.rd.flushdb()457 return '\n\nThe redis container for db=0, is empty, all the data that was inside has been deleted.\n\n'458 else:459 return print_errors.error('curl -X DELETE localhost:5036/data/reset')460#Returns the data to the user, we start using the worker.py function through the usage of jobs.py 461 462if __name__ == "__main__":...

Full Screen

Full Screen

MINSTexperiment.py

Source:MINSTexperiment.py Github

copy

Full Screen

...49print('\n-------------------------------------------')50print("Nearest Centroid Classifier:")5152NC_MNISTexp_lbls = odap.nc_classify(MNISTtrain, MNISTtest, MNISTtrain_lbls)53odap.print_errors(MNISTtest, MNISTtest_lbls, NC_MNISTexp_lbls) # Print errors5455# PCA of MNIST56print('\n-------------------------------------------')57print("Nearest Centroid Classifier (PCA data):")5859NCpca_MNISTexp_lbls = odap.nc_classify(60 MNISTtrainPCA, MNISTtestPCA, MNISTtrain_lbls)61odap.print_errors(MNISTtestPCA, MNISTtest_lbls,62 NCpca_MNISTexp_lbls) # Print errors636465# -------------------------------------------66# 2.Nearest subclass centroid Classifier {2,3,5}67print('\n-------------------------------------------')68print("Nearest subclass centroid classifier (2 subclasses):")6970NSC2_MNISTexp_lbls = odap.nsc_classify(71 MNISTtrain, 2, MNISTtest, MNISTtrain_lbls)72odap.print_errors(MNISTtest, MNISTtest_lbls,73 NSC2_MNISTexp_lbls) # Print errors7475print('\n-------------------------------------------')76print("Nearest subclass centroid classifier (PCA data) (2 subclasses):")7778NSC2pca_MNISTexp_lbls = odap.nsc_classify(79 MNISTtrainPCA, 2, MNISTtestPCA, MNISTtrain_lbls)80odap.print_errors(MNISTtestPCA, MNISTtest_lbls,81 NSC2pca_MNISTexp_lbls) # Print errors8283print('\n-------------------------------------------')84print("Nearest subclass centroid classifier (3 subclasses):")85NSC3_MNISTexp_lbls = odap.nsc_classify(86 MNISTtrain, 3, MNISTtest, MNISTtrain_lbls)87odap.print_errors(MNISTtest, MNISTtest_lbls,88 NSC3_MNISTexp_lbls) # Print errors8990print('\n-------------------------------------------')91print("Nearest subclass centroid classifier (PCA data) (3 subclasses):")92NSC3pca_MNISTexp_lbls = odap.nsc_classify(93 MNISTtrainPCA, 3, MNISTtestPCA, MNISTtrain_lbls)94odap.print_errors(MNISTtestPCA, MNISTtest_lbls,95 NSC3pca_MNISTexp_lbls) # Print errors9697print('\n-------------------------------------------')98print("Nearest subclass centroid classifier (5 subclasses):")99NSC5_MNISTexp_lbls = odap.nsc_classify(100 MNISTtrain, 5, MNISTtest, MNISTtrain_lbls)101odap.print_errors(MNISTtest, MNISTtest_lbls,102 NSC5_MNISTexp_lbls) # Print errors103104print('\n-------------------------------------------')105print("Nearest subclass centroid classifier (PCA data) (5 subclasses):")106NSC5pca_MNISTexp_lbls = odap.nsc_classify(107 MNISTtrainPCA, 5, MNISTtestPCA, MNISTtrain_lbls)108odap.print_errors(MNISTtestPCA, MNISTtest_lbls,109 NSC5pca_MNISTexp_lbls) # Print errors110111# -------------------------------------------112# 3. Nearest neighbour classifier113print('\n-------------------------------------------')114print("Nearest neighbour classifier:")115NNC_MNISTexp_lbls = odap.nn_classify(MNISTtrain, MNISTtest, MNISTtrain_lbls)116odap.print_errors(MNISTtest, MNISTtest_lbls, NNC_MNISTexp_lbls) # Print errors117118print('\n-------------------------------------------')119print("Nearest neighbour classifier (PCA data):")120NNCpca_MNISTexp_lbls = odap.nn_classify(121 MNISTtrainPCA, MNISTtestPCA, MNISTtrain_lbls)122odap.print_errors(MNISTtestPCA, MNISTtest_lbls,123 NNCpca_MNISTexp_lbls) # Print errors124125# -------------------------------------------126# 4. Perceptron trained using Backpropagation127128print('\n-------------------------------------------')129print("Perceptron Clasifier trained using Backpropagation")130131eta = 0.1132epoch = 20133134pbp = odap.PerceptronBP(eta=eta, epochs=epoch)135pbp.fit(MNISTtrain, MNISTtrain_lbls)136137138139PBB_MNISTexp_lbls = pbp.predict_lbls(MNISTtest)140odap.print_errors(MNISTtest, MNISTtest_lbls, PBB_MNISTexp_lbls) # Print errors141142print('\n-------------------------------------------')143print("Perceptron Clasifier trained using Backpropagation (PCA data)")144pbp_pca = odap.PerceptronBP(eta=eta, epochs=epoch)145pbp_pca.fit(MNISTtrainPCA, MNISTtrain_lbls)146147PBBpca_MNISTexp_lbls = pbp_pca.predict_lbls(MNISTtestPCA)148odap.print_errors(MNISTtestPCA, MNISTtest_lbls,149 PBBpca_MNISTexp_lbls) # Print errors150151# -------------------------------------------152# 5. Nearest neighbour classifier153154print('\n-------------------------------------------')155print("Perceptron Clasifier trained using MSE")156157pmse = odap.PerceptronMSE()158pmse.fit(MNISTtrain, MNISTtrain_lbls)159160PMSE_MNISTexp_lbls = pmse.predict_lbls(MNISTtest)161odap.print_errors(MNISTtest, MNISTtest_lbls,162 PMSE_MNISTexp_lbls) # Print errors163164print('\n-------------------------------------------')165print("Perceptron Clasifier trained using MSE (PCA data)")166167pmse_pca = odap.PerceptronMSE()168pmse_pca.fit(MNISTtrainPCA, MNISTtrain_lbls)169170PMSEpca_MNISTexp_lbls = pmse_pca.predict_lbls(MNISTtestPCA)171odap.print_errors(MNISTtestPCA, MNISTtest_lbls, ...

Full Screen

Full Screen

ORLexperiment.py

Source:ORLexperiment.py Github

copy

Full Screen

...48print('\n-------------------------------------------')49print("Nearest Centroid Classifier:")5051NC_ORLexp_lbls = odap.nc_classify(ORLtrain, ORLtest, ORLtrain_lbls)52odap.print_errors(ORLtest, ORLtest_lbls, NC_ORLexp_lbls) # Print errors5354# PCA of ORL55print('\n-------------------------------------------')56print("Nearest Centroid Classifier (PCA data):")5758NCpca_ORLexp_lbls = odap.nc_classify(ORLtrainPCA, ORLtestPCA, ORLtrain_lbls)59odap.print_errors(ORLtestPCA, ORLtest_lbls, NCpca_ORLexp_lbls) # Print errors606162# -------------------------------------------63# 2.Nearest subclass centroid Classifier {2,3,5}64print('\n-------------------------------------------')65print("Nearest subclass centroid classifier (2 subclasses):")6667NSC2_ORLexp_lbls = odap.nsc_classify(ORLtrain, 2, ORLtest, ORLtrain_lbls)68odap.print_errors(ORLtest, ORLtest_lbls, NSC2_ORLexp_lbls) # Print errors6970print('\n-------------------------------------------')71print("Nearest subclass centroid classifier (PCA data) (2 subclasses):")7273NSC2pca_ORLexp_lbls = odap.nsc_classify(74 ORLtrainPCA, 2, ORLtestPCA, ORLtrain_lbls)75odap.print_errors(ORLtestPCA, ORLtest_lbls,76 NSC2pca_ORLexp_lbls) # Print errors7778print('\n-------------------------------------------')79print("Nearest subclass centroid classifier (3 subclasses):")80NSC3_ORLexp_lbls = odap.nsc_classify(ORLtrain, 3, ORLtest, ORLtrain_lbls)81odap.print_errors(ORLtest, ORLtest_lbls, NSC3_ORLexp_lbls) # Print errors8283print('\n-------------------------------------------')84print("Nearest subclass centroid classifier (PCA data) (3 subclasses):")85NSC3pca_ORLexp_lbls = odap.nsc_classify(86 ORLtrainPCA, 3, ORLtestPCA, ORLtrain_lbls)87odap.print_errors(ORLtestPCA, ORLtest_lbls,88 NSC3pca_ORLexp_lbls) # Print errors8990print('\n-------------------------------------------')91print("Nearest subclass centroid classifier (5 subclasses):")92NSC5_ORLexp_lbls = odap.nsc_classify(ORLtrain, 5, ORLtest, ORLtrain_lbls)93odap.print_errors(ORLtest, ORLtest_lbls, NSC5_ORLexp_lbls) # Print errors9495print('\n-------------------------------------------')96print("Nearest subclass centroid classifier (PCA data) (5 subclasses):")97NSC5pca_ORLexp_lbls = odap.nsc_classify(98 ORLtrainPCA, 5, ORLtestPCA, ORLtrain_lbls)99odap.print_errors(ORLtestPCA, ORLtest_lbls,100 NSC5pca_ORLexp_lbls) # Print errors101102# -------------------------------------------103# 3. Nearest neighbour classifier104print('\n-------------------------------------------')105print("Nearest neighbour classifier:")106NNC_ORLexp_lbls = odap.nn_classify(ORLtrain, ORLtest, ORLtrain_lbls)107odap.print_errors(ORLtest, ORLtest_lbls, NNC_ORLexp_lbls) # Print errors108109print('\n-------------------------------------------')110print("Nearest neighbour classifier (PCA data):")111NNCpca_ORLexp_lbls = odap.nn_classify(ORLtrainPCA, ORLtestPCA, ORLtrain_lbls)112odap.print_errors(ORLtestPCA, ORLtest_lbls, NNCpca_ORLexp_lbls) # Print errors113114# -------------------------------------------115# 4. Perceptron trained using Backpropagation116117print('\n-------------------------------------------')118print("Perceptron Clasifier trained using Backpropagation")119120eta = 0.1121epoch = 20122123pbp = odap.PerceptronBP(eta=eta, epochs=epoch)124pbp.fit(ORLtrain, ORLtrain_lbls)125126PBB_ORLexp_lbls = pbp.predict_lbls(ORLtest)127odap.print_errors(ORLtest, ORLtest_lbls, PBB_ORLexp_lbls) # Print errors128129print('\n-------------------------------------------')130print("Perceptron Clasifier trained using Backpropagation (PCA data)")131pbp_pca = odap.PerceptronBP(eta=eta, epochs=epoch)132pbp_pca.fit(ORLtrainPCA, ORLtrain_lbls)133134PBBpca_ORLexp_lbls = pbp_pca.predict_lbls(ORLtestPCA)135odap.print_errors(ORLtestPCA, ORLtest_lbls, PBBpca_ORLexp_lbls) # Print errors136137# -------------------------------------------138# 5. Nearest neighbour classifier139140print('\n-------------------------------------------')141print("Perceptron Clasifier trained using MSE")142143pmse = odap.PerceptronMSE()144pmse.fit(ORLtrain, ORLtrain_lbls)145146PMSE_ORLexp_lbls = pmse.predict_lbls(ORLtest)147odap.print_errors(ORLtest, ORLtest_lbls, PMSE_ORLexp_lbls) # Print errors148149print('\n-------------------------------------------')150print("Perceptron Clasifier trained using MSE (PCA data)")151152pmse_pca = odap.PerceptronMSE()153pmse_pca.fit(ORLtrainPCA, ORLtrain_lbls)154155PMSEpca_ORLexp_lbls = pmse_pca.predict_lbls(ORLtestPCA)156odap.print_errors(ORLtestPCA, ORLtest_lbls, ...

Full Screen

Full Screen

install.py

Source:install.py Github

copy

Full Screen

...92 # check OS93 print("Checking if running a supported OS version...")94 checked_os = check_os()95 if (is_error(checked_os)):96 return print_errors(checked_os)97 else:98 success = print_errors(checked_os)99 100 # check space available101 print("Checking if enough disk space is available...")102 checked_space = check_space()103 if (is_error(checked_space)):104 return print_errors(checked_space)105 else:106 success = print_errors(checked_space)107 # check package manager108 print("Checking if machine has a supported package manager...")109 checked_pkg_manager = update_pkg_manager()110 if (is_error(checked_pkg_manager)):111 return print_errors(checked_pkg_manager)112 else:113 success = print_errors(checked_pkg_manager)114 115 # check packages are installed116 print("Checking if packages installed correctly...")117 checked_packages = check_packages()118 if (is_error(checked_packages)):119 return print_errors(checked_packages)120 else:121 success = print_errors(checked_packages)122 # check OMS version123 print("Checking if running a supported version of OMS...")124 checked_oms = check_oms(interactive)125 if (is_error(checked_oms)):126 return print_errors(checked_oms)127 else:128 success = print_errors(checked_oms)129 # check all files130 if (os.path.isdir(DFS_PATH)):131 print("Checking if all files installed correctly (may take some time)...")132 checked_files = check_filesystem(DFS_PATH)133 if (is_error(checked_files)):134 return print_errors(checked_files)135 else:136 success = print_errors(checked_files)137 else:138 print("WARNING (INTERNAL): Datafiles have not been successfully copied over.")139 print("Skipping all files installed correctly check...")140 # check certs141 print("Checking certificate and RSA key are correct...")142 # check cert143 checked_cert = check_cert()144 if (checked_cert != NO_ERROR):145 success = print_errors(checked_cert)146 # check key147 checked_key = check_key()148 if (checked_key != NO_ERROR):149 success = print_errors(checked_key)150 # return if at least one is false151 if (is_error(checked_cert) or is_error(checked_key)):152 return ERR_FOUND153 154 return success...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gherkin-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful