def get_columns(): response = jsonify({ 'teams':util.get_columns(), 'venues': util.get_venues() }) response.headers.add('Access-Control-Allow-Origin','*') return response
def predict(): if request.method == "POST": print("Achievment") PR = util.get_PROD_CD() SL = util.get_SLSMAN_CD() PROD_CD = str(request.form["PROD_CD"]) #1 SLSMAN_CD = str(request.form["SLSMAN_CD"]) #2 PLAN_MONTH = request.form["PLAN_MONTH"] #3 TARGET_IN_EA = request.form["TARGET_IN_EA"] #4 x = np.zeros(len(util.get_columns())) x[0] = PR.index(PROD_CD) x[1] = SL.index(SLSMAN_CD) x[2] = PLAN_MONTH x[3] = TARGET_IN_EA print(x) # x = np.reshape(x,(-1,1)) prd = model.predict([x]) #prd = np.reshape(prd,(1,) # response = jsonify({ # "predictions" : str(np.round(prd[0],4)) # }) # response.headers.add('Access-Control-Allow-Origin','*') if int(prd) > 0: return render_template('index.html', prediction_text="Achievment {}".format( np.round(prd.item(), 3))) elif int(prd) < 0: return render_template('index.html', prediction_text="Achievment ".format( np.round(-prd.item(), 3))) # elif int(output)==0: # return render_template('index.html', prediction_text="Achieved.") # return response return render_template('index.html')
def predict(): if request.method == "POST": print("Getting Flight detail's Flies") AL = util.get_Airlines() OA = util.get_Origin() DA = util.get_Dest() SD = request.form["SCHEDULED_DEPARTURE"] #1 ST = request.form["SCHEDULED_TIME"] #2 date = request.form["DATE"] #3 AIRLINE = str(request.form["AIRLINE"]) #4 ORIGIN = str(request.form["ORIGIN_AIRPORT"]) #5 DEST = str(request.form["DESTINATION_AIRPORT"]) #6 SDepart = int(SD[:2] + SD[3:5]) print(SDepart) STime = int(ST[:2] + ST[3:5]) print(STime) year, month, day = (int(x) for x in date.split('-')) dow = datetime.date(year, month, day).weekday() print(day, month, dow) print("Inputiing") x = np.zeros(len(util.get_columns())) x[0] = month x[1] = day x[2] = dow x[3] = AL.index(AIRLINE) x[4] = OA.index(ORIGIN) x[5] = DA.index(DEST) x[6] = SDepart x[7] = STime x[8] = float(request.form["ARRIVAL_DELAY"]) #7 print(x) x = preprocessing.scale(x) x = np.array([x]) prd = model.predict([x], verbose=0) prd = np.reshape(prd, (1, )) output = round(prd[0], 2) # response = jsonify({ # "predictions" : round(output.item(),2) # }) # response.headers.add('Access-Control-Allow-Origin','*') if int(output) > 0: return render_template( 'single.html', prediction_text= "Flight's probable departure will be {} minutes after the schedule" .format(round(output.item(), 2))) elif int(output) < 0: return render_template( 'single.html', prediction_text= "Flight's probable departure will be {} minutes before the schedule." .format(round(-output.item(), 2))) elif int(output) == 0: return render_template( 'single.html', prediction_text="Flight will be departing on time.") # return response return render_template('single.html')
def field_cov(fields, models, apps): columns = util.get_columns(fields, models, apps) columns = util.make_real(columns) return np.cov(columns)
def columns(): return get_columns([c_serial])
def columns(): return get_columns()
def _reinitialize(self): self.matrix = init_random_matrix(self.row_c, self.col_c) self.matrix.extend(get_columns(self.matrix)) self.reqs = self.row_c + self.col_c
def get_columns(self, table): return util.get_columns(self.conn, table)
def plot(file_1, file_2, coord, ip, flag): # Here, file_1 is thought as the output of the GetAperture routine and file_2 a MAD-X file # ----------------------------- # Text and plot characteristics # ----------------------------- DPI = 300 textwidth = 4 rc('font',**{'family':'serif','serif':['Computer Modern Roman'], 'size':10}) rc('text', usetex=True) rcParams['figure.figsize']=textwidth, textwidth/1.618 fig = plt.figure() ax = fig.add_subplot(111) coord = '%s'%coord # ----------------------------- # Deal with each possible case # ----------------------------- # -------------------------------- # Get the data for each coordinate # -------------------------------- if coord =='x': var_x, var_y = get_columns('LHCAperture_old.dat', 0, 1) var_x2, var_y2 = get_columns('LHCAperture_new.dat', 0, 1) ax.set_ylabel('x [m]') elif coord =='y': var_x, var_y = get_columns('LHCAperture_old.dat', 0, 2) var_x2, var_y2 = get_columns('LHCAperture_new.dat', 0, 2) ax.set_ylabel('y [m]') else: print '>> ERROR: input "x" or "y" in the 3rd argument' # --------------- # Choose your IR # --------------- y_limits = (0.2, 0.65, 0.2, 0.2, 0.4, 0.2, 0.2, 0.3) position, ylim = get_ir(ip, y_limits[ip-1]) if ip == 1: var_x, var_y = get_ip1(var_x, var_y) var_x2, var_y2 = get_ip1(var_x2, var_y2) # ------------------------------------- # Choose the elements you want to plot # ------------------------------------- regex_list = (['VC+', 'T'], ['VC+'], ['VC+'], ['VC+'], ['VC+', 'T'], ['VC+'], ['VC+'], ['VC+']) heights = (0.12, 0.42, 0.1, 0.13, 0.23, 0.1, 0.1, 0.2) name, pos, height = get_element('twiss_ip1_b1.tfs', 0, 3, regex_list[ip-1], heights[ip-1]) if flag == True: # ------------------ # Plot the elements # ------------------ if ip == 1: pos, name = get_ip1(pos, name) for s, n in zip(pos, name): plt.annotate(n, xy=(s, height), xytext=(s, height), name='Verdana', family='sans-serif', weight='light', va='bottom', ha='center', rotation=90, size=3) # plt.bar(s-l, 100, l, 150, color = '#249A27', edgecolor = 'black', linewidth = '1.7', alpha = 0. else: print 'No elements were plotted' # --------- # Plotting # --------- ax.plot(var_x, var_y, 'b-', linewidth=1, label='Old file') ax.plot(var_x2, var_y2, 'r-', linewidth=0.4, label='New file') ip = '%s'%ip ax.set_title('IR' + ip) ax.set_xlim([position - 150, position + 150]) ax.set_ylim([0, ylim]) ax.set_xlabel('s [m]') ax.ticklabel_format(style='sci',axis='y',scilimits=(0,0)) ax.grid(b=None, which='major') ax.legend(loc='upper right', prop={'size':6}) plt.subplots_adjust(left=0.12,bottom=0.16,right=0.94,top=0.88) # plt.show() # -------------- # Save the plot # -------------- plt.savefig('allapert_ip_' + ip + '_' + coord + '_new.png', dpi=DPI) plt.close()