How to use focussen method in SeleniumBase

Best Python code snippet using SeleniumBase

streamlit_labeler.py

Source:streamlit_labeler.py Github

copy

Full Screen

1import streamlit as st2import pandas as pd3import numpy as np4import zipfile5from PIL import Image6import os7from random import randrange8import random9import math10st.title('Label tool')11processed_path = "./processed.pkl"12zips_path = "./zips"13print("start refresh")14if not os.path.exists(zips_path):15 raise FileNotFoundError("folder containing zip files not found!")16if not os.path.exists(processed_path):17 # csv's in dir18 csv_list = ["Selecteer"] + [i for i in os.listdir() if i.endswith(".csv")]19 if len(csv_list) == 1:20 st.write("Place the .csv file in the same directory as the python script")21 else:22 option = st.selectbox('Select .csv file to start', csv_list)23 if option != "Selecteer":24 st.write('Processing ', option, "this can take a while ...")25 df = pd.read_csv(option, sep=";", skiprows=8, nrows=28901, engine='python') # python engine is nodig omdat de C engine de encoding van de file niet kan lezen26 df = df[df.columns[:-50]] # Er worden 50 columns teveel ingelezen27 df.dropna(how="all", axis=1, inplace=True) # Lege collumns verwijderen28 file_names = df["Camera4 : Hyperlink original picture filename"]29 # columns verwijderen30 df.drop("Cause sequence interrupt", axis=1, inplace=True) # voorlopig verwijderen, later misschien one hot encoden31 for col in df.columns:32 # Columns met 1 unieke value verwijderen33 counts = pd.value_counts(df[col])34 if len(counts) == 1:35 df.drop(col, axis=1, inplace=True)36 continue37 # object columns (strings) omzetten naar float38 if df[col].dtype == "object":39 # als er een komma is dit vervangen met een . en omzetten40 if df[col].str.contains(',').all():41 df[col] = df[col].str.replace(',', '.').astype("float32")42 # Er is geen komma dus het is geen getal43 else:44 df.drop(col, axis=1, inplace=True)45 # integer omzetten naar float3246 elif df[col].dtype == "int64":47 df[col] = df[col].astype("float32")48 df = df.fillna(0) # Nan's vervangen met 049 df["file_names"] = file_names50 # voorlopig enkel focussen op camera 4, deze hoort het meest accuraat te zijn51 verkeerde_cameras = ["Camera1", "Camera2", "Camera3", "Camera5"]52 for col in df.columns:53 for camera in verkeerde_cameras:54 if camera in col:55 df.drop(col, axis=1, inplace=True)56 continue57 df.drop("Sequence #", axis=1, inplace=True)58 df = df.set_index("file_names")59 df["Quality_label"] = np.nan60 df.to_pickle("processed.pkl")61 st.write("Processing done")62 st.button("Start labeling")63 print(df.shape)64else:65 def load_data(file_path):66 # data = pd.read_csv(file_path)67 data = pd.read_pickle(file_path)68 # data = data.set_index(["file_names"])69 return data70 @st.cache71 def get_available_images():72 available_zips = []73 for zip in os.listdir(zips_path):74 with zipfile.ZipFile(os.path.join(zips_path, zip), "r") as zip_data:75 available_zips += [i[:-12] for i in zip_data.namelist()]76 return available_zips77 # @st.cache78 def get_unlabled_row(data):79 # random beschikbare image selecteren80 # random.seed(0)81 # random_index = randrange(len(available_images))82 # index = available_images[random_index]83 # row = data.loc[index]84 # if not math.isnan(row["Quality_label"]):85 # get_unlabled_row(data)86 selection = data.loc[available_images]87 non_labled = selection[selection["Quality_label"].isna()]88 random_index = randrange(len(non_labled))89 row = selection[selection["Quality_label"].isna()].iloc[random_index]90 return row91 @st.cache92 def get_zipped_image(file_name):93 full_name = file_name + "_AIimage.png"94 # find image in zips95 for zip in os.listdir(zips_path):96 with zipfile.ZipFile(os.path.join(zips_path, zip), "r") as zip_data:97 if full_name in zip_data.namelist():98 imagePIL = Image.open(zip_data.open(full_name)) # Image data lezen uit de zip file99 imagePIL = np.flip(imagePIL, 0) # Image horizontaal spiegelen omdat Pil de image omgekeerd inleest100 imagePIL = imagePIL[348:482]101 return imagePIL102 raise Exception("Image is niet gevonden")103 data = load_data(processed_path)104 available_images = get_available_images()105 app_state = st.experimental_get_query_params()106 if "file_name" in app_state:107 row = data.loc[app_state["file_name"][0]]108 else:109 row = get_unlabled_row(data)110 st.experimental_set_query_params(file_name=row.name)111 image_filename = row.name112 if st.checkbox('Show raw data'):113 st.subheader('Raw data')114 # st.dataframe(data)115 aantal_gelabelde = len(data) - len(data[data["Quality_label"].isna()])116 st.write("Aantal gelabelde:", aantal_gelabelde)117 # st.dataframe(data[["MV Pressure (bar)", "RV4 off time (ms)", "file_names", "Quality_label"]])118 st.dataframe(row)119 st.write("file name:", image_filename)120 image = get_zipped_image(image_filename)121 st.image(image)122 start_pos = row["Quality_label"] if type(row["Quality_label"]) is np.nan else 5123 qual = st.slider("What's the quality score:", 0, 10, start_pos)124 if st.button('Confirm label'):125 row["Quality_label"] = qual126 # data.loc[image_filename, "Quality_label"] = qual127 data.loc[image_filename] = row128 print(data.loc[image_filename])129 print(data.loc[image_filename]["Quality_label"])130 data.to_pickle("./processed.pkl")131 st.write("Label:", qual, "confirmed")132 st.write('On to the next ...')133 st.experimental_set_query_params()134 st.experimental_rerun()135 if st.button("Export to .csv"):136 data.to_csv("./processed_labels.csv", index=True)...

Full Screen

Full Screen

acsadviesjargon.py

Source:acsadviesjargon.py Github

copy

Full Screen

1import random2items1 = [3 "Human capital",4 "De factor mens",5 "Het management",6 "De communicatie",7 "De kerncompetentie",8 "De organisatie-ontwikkeling",9 "De missie",10 "Kennismanagement",11 "De eerste aanzet",12 "Human capital",13 "Globalisatie",14 "Knowledge management",15 "Management",16 "The mission",17 "New business development",18 "Process management",19 "The human factor",20 "ICT",21 "Verduurzaming",22 "Het klimaatbeleid",23]24items2 = [25 "moet meerwaarde leveren bij",26 "stelt eisen aan",27 "dient te faciliteren bij",28 "is uitgangspunt bij",29 "is onlosmakelijk verbonden met",30 "schept voorwaarden voor",31 "dient te focussen op",32 "stuurt",33 "hangt nauw samen met",34 "moet een opstap bieden voor",35 "moet een kader bieden voor",36 "zet doelstellingen voor",37 "geeft een nieuw momentum voor",38]39items3 = [40 "de implementatie van",41 "de terugkoppeling van",42 "het aftimmeren van",43 "het aansturen van",44 "de ontwikkeling van",45 "de flexibilisering van",46 "de integratie van",47 "de inventarisatie van",48 "de definitie van",49 "de insteek van",50 "de inbedding",51 "het design van",52 "de marketing van",53 "de herstructurering van",54 "de marktpenetratie van",55 "het groeiproces van",56]57items4 = [58 "optimale",59 "in elkaar grijpende",60 "eenduidige onderling afhankelijke",61 "structurele",62 "pro-actieve",63 "resultaatgerichte",64 "efficiënte",65 "self learning",66 "consistente",67 "individuele",68 "highly developped",69 "duurzame",70 "klimaatneutrale",71]72items5 = [73 "supply chain processen",74 "business architecture",75 "mijlpalen",76 "targets",77 "business units",78 "organisatie-onderdelen",79 "scenario's",80 "best practices",81 "business models",82 "conceptplannen",83 "organizational units",84 "milestones",85 "supply chain",86 "systems",87 "product concepts",88 "human resource",89]90items6 = [91 "waarbij het belang van",92 "waarbij de feedback van",93 "waarbij het kader voor",94 "waarbij afstemming met",95 "waarbij de structuur van",96 "waarbij de synergie met",97 "waarbij de interface met",98 "waarbij input van",99 "waarbij commitment van",100 "waarbij klankborden met",101 "waarbij inbedding van",102]103items7 = [104 "strategisch beleid",105 "de taskforce",106 "de communicatie",107 "de werkgroepen",108 "new business",109 "development",110 "de systeemintegratie",111 "de markt",112 "de stakeholders",113 "het management",114 "de projectorganisatie",115 "management",116 "core business",117 "task force",118 "feedback",119 "niche marketing",120 "strategic partnership",121 "cutting edge solutions",122 "de holding",123 "de aandeelhouders",124 "de commisarissen",125 "de directie",126 "duurzame ontwikkeling",127 "persoonljke ontwikkeling",128 "klimaatneutraal beleid",129 "de vermindering van CO2-uitstoot",130 "de vermindering van stiksofuitstoot",131 "eye-openers",132]133items8 = [134 "moet uitkristalliseren",135 "voorop staat",136 "centraal staat",137 "wordt aangestuurd",138 "leading is",139 "toegevoegde waarde levert",140 "win-win situaties creëert",141 "moet worden gemanaged",142 "voldoende draagvlak heeft",143 "doorslaggevend is",144 "essentieel is",145 "gewaarborgd is",146 "cruciaal is",147 "nieuwe mogelijkheden biedt",148 "een nieuwe standaard zet",149 "vanzelfsprekend is",150 "een blijvende voorsprong geeft",151 "in het bedrijf wordt ingebed",152]153def random_item(items):154 random.seed()155 return items[random.randint(0, len(items)-1)]156def report_adviesjargon(reply_to):157 reply = (158 "cc @" + reply_to + "\n\n" +159 random_item(items1) + " " +160 random_item(items2) + " " +161 random_item(items3) + " " +162 random_item(items4) + " " +163 random_item(items5) + " " +164 random_item(items6) + " " +165 random_item(items7) + " " +166 random_item(items8) + "." +167 " #adviesjargon"168 )...

Full Screen

Full Screen

oef4.py

Source:oef4.py Github

copy

Full Screen

1import matplotlib.pyplot as plt2import pandas as pd3import seaborn as sns4df = pd.read_csv("student-mat.csv", header=0, delimiter=";")5print(df.head())6# Hoeveel studenten steken in de dataset?7print("Er zitten ", df.sex.count(), "studenten")8# Gebruik de describe-functie om een overzicht te bekomen van de variabelen in de dataset9print(df.describe())10# Bepaal het geslacht en de leeftijd van de vijf studenten met de beste score11highest_five = df.nlargest(5, "G3")12print(highest_five[["sex", "age", "G3"]])13# Gebruik een countplot om een staafdiagramma met de leeftijden weer te geven14# sns.countplot(x="age", data=df)15# We focussen ons nu op de leeftijd van de studenten.16ages = df['age']17# Bereken de volgende centrummaten en de spreidingsmaten18# -Het gemiddelde19print("Gemiddelde: ", ages.mean())20# -De mediaan21print("Median: ", ages.median())22# -Variantie23print("Variance: ", ages.var())24# -Standaardafwijking25print("Standard: ", ages.std())26# -De range27print("Range: ", ages.max() - ages.min())28# -Q1 en Q3 en bereken hieruit de interkwartielafstand29print("IQR: ", ages.quantile(0.75) - ages.quantile(0.25))30# -scheefheid31print("Skew: ", ages.skew())32# -De kurtosis33print("Skew: ", ages.kurt())34# Bepaal een boxplot van de leeftijd(voorbeeld zie onder)35# sns.boxplot(x=df["age"])36# Kan je ook een onderscheid maken tussen mannen en vrouwen?37sns.boxplot(x=df["sex"], y=df["age"])...

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 SeleniumBase 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