def inference(): if request.method == 'POST': sex = request.form['sex'] smoker =request.form['smoker'] bmi = request.form['bmi'] region = request.form['region'] age=request.form['age'] children = request.form['kid'] if not sex: flash('enter sex male or female') else: expense = read(sex,smoker,region,age, bmi,children) #Gcloud config ={ 'user': '******', 'password': '******', 'host': '34.121.155.244', 'database':'insurancedb', 'client_flags': [ClientFlag.SSL], 'ssl_ca': 'ssl/server-ca.pem', 'ssl_cert': 'ssl/client-cert.pem', 'ssl_key': 'ssl/client-key.pem' } # now we establish our connection with sql.connect(**config) as cnx: cur = cnx.cursor() # initialize connection cursor cur.execute("insert into data(sex,smoker,region,age,bmi,children,insurance) VALUES (%s,%s,%s,%s,%s,%s,%s)",(sex,smoker,region,age,bmi,children,expense)) cnx.commit() cnx.close() return render_template('inference.html',expense = expense) return render_template('inference.html')
def predict(*args): try: clients_data = model.read(self.filename.get()) except: tkMessageBox.showinfo( "Error", "Select a weather forecast from the browser") regr = model.load_regressor(self.picked_regressor.get()) try: clients_Y = model.predict(clients_data, regr) model.save_in_file(clients_Y) model.show_plots(np.arange(24), clients_Y) except ValueError: tkMessageBox.showinfo("Error", "Select a valid weather forecast")
def inference(): if request.method == 'POST': sex = request.form['sex'] smoker = request.form['smoker'] bmi = request.form['bmi'] region = request.form['region'] age = request.form['age'] children = request.form['kid'] if not sex: flash('enter sex male or female') else: expense = read(sex, smoker, region, age, bmi, children) return render_template('/inference.html', expense=expense) return render_template('/inference.html')
def accuracy_of_model(n): sample_data = pd.read_csv('data/insurance.csv') sum = 0 #print(sample_data) for i in sample_data.head(n).itertuples(): sex = i[2] smoker = i[5] location = i[6] age = i[1] bmi = i[3] kids = i[4] expenses = float(i[7]) #print(sex, smoker, location, age, bmi, kids) predicted = float(read(sex, smoker, location, age, bmi, kids)) accuracy = abs(predicted - expenses) / expenses sum += accuracy print(accuracy) #print(predicted) avg_accuracy = 100 - (sum / n) print(avg_accuracy) return avg_accuracy
#cut data from images # cut1 = observation.Datacut(img1, 500, 500) # cut2 = observation.Datacut(img2, 300, 300) # cut3 = observation.Datacut(img3, 400, 400) cut1 = observation.Datacut(img1, 660, 760) cut2 = observation.Datacut(img1, 660, 1040) cut3 = observation.Datacut(img1, 660, 1200) #create list of datacuts #NOTE: at present, datacuts = [cut1, cut2, cut3] #load initial atmospheric model init_model = model.read('init_model.dat') #check validity of initial atmosphere model init_model.check_validity() #write out model to a text file that is input to the fortran #adding/doubling code init_model.write_ft_input() # #Note: can also do init_model.write_ft_input(filename='workmodl000') #write out illumination geometry data for observation into #format that can be read by fortran code interface.write_geom_model(datacuts, filename = 'geom.dat') #note: "geom.dat" is not very descriptive, but this is the default #string that the fortran code automatically uses. Not sure how to
template() option = cnt.choise() if option not in ['c', 'r', 'u', 'd', 'e']: print("Opção Inválida!!!") #Create ---------------------------------------------------------- if option == "c": status = db.create() if status == True: print("Deu certo...") else: print("Deu Ruim...") #Read ------------------------------------------------------------ if option == "r": rows = db.read() print( "--------------------------------------------------------------------------------------------" ) for row in range(len(rows)): print("Serviço: {} | Usuário: {} | Senha: {} | ID: {} ". format(rows[row][1], rows[row][2], rows[row][3], rows[row][0])) print( "--------------------------------------------------------------------------------------------" ) #Update ------------------------------------------------------------ if option == "u": db.update()
def get(self, name): phone = model.read(name) if phone is None: return '', 404 return phone[0]
def combine_path_read(model, path_pre, path_name, path_postfix): path = join_path(path_pre, path_name, path_postfix) lines = model.read(path) return lines
def check_login(email): table_title = 'pkp_companies' list = ['email'] values = [email] result = read(table_title, list, values) return result
# cut2 = observation.Datacut(img2, 300, 300) # cut3 = observation.Datacut(img3, 400, 400) #NOTE: remember that this accepts coordinates in Python, which is row-major #whereas IDL is column-major. cut1 = observation.Datacut(img1, 660, 1000) cut2 = observation.Datacut(img1, 660, 1440) cut3 = observation.Datacut(img1, 660, 1600) #create list of datacuts #NOTE: at present, datacuts = [cut1, cut2, cut3] #load initial atmospheric model init_model = model.read('test_model.dat') #check validity of initial atmosphere model init_model.check_validity() #write out model to a text file that is input to the fortran #adding/doubling code init_model.write_ft_input() # #Note: can also do init_model.write_ft_input(filename='workmodl000') #write out illumination geometry data for observation into #format that can be read by fortran code interface.write_geom_model(datacuts, filename = 'geom.dat') #note: "geom.dat" is not very descriptive, but this is the default #string that the fortran code automatically uses. Not sure how to
#cut data from images # cut1 = observation.Datacut(img1, 500, 500) # cut2 = observation.Datacut(img2, 300, 300) # cut3 = observation.Datacut(img3, 400, 400) cut1 = observation.Datacut(img1, 600, 600) cut2 = observation.Datacut(img1, 700, 700) cut3 = observation.Datacut(img1, 500, 500) #create list of datacuts #Note: at present, datacuts must have at least 3 cuts or else #fortran code will reject the geom.dat file datacuts = [cut1, cut2, cut3] #load initial atmospheric model init_model = model.read('imodel000.dat') #check validity of initial atmosphere model init_model.check_validity() #write out model to a text file that is input to the fortran #adding/doubling code init_model.write_ft_input() # #Note: can also do init_model.write_ft_input(filename='workmodl000') #write out illumination geometry data for observation into #format that can be read by fortran code interface.write_geom_model(datacuts, filename = 'geom.dat') #note: "geom.dat" is not very descriptive, but this is the default #string that the fortran code automatically uses. Not sure how to