This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dotenv import load_dotenv | |
from langchain_openai import ChatOpenAI | |
from pydantic import BaseModel | |
from browser_use import ActionResult, Agent, Controller | |
from browser_use.browser.context import BrowserContext | |
from browser_use.browser.browser import Browser, BrowserConfig | |
import asyncio | |
import os | |
import json | |
import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################### | |
# Suppress matplotlib user warnings | |
# Necessary for newer version of matplotlib | |
import warnings | |
warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib") | |
# | |
# Display inline matplotlib plots with IPython | |
from IPython import get_ipython | |
get_ipython().run_line_magic('matplotlib', 'inline') | |
########################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################### | |
# Suppress matplotlib user warnings | |
# Necessary for newer version of matplotlib | |
import warnings | |
warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib") | |
# | |
# Display inline matplotlib plots with IPython | |
from IPython import get_ipython | |
get_ipython().run_line_magic('matplotlib', 'inline') | |
########################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import itertools | |
from sklearn.metrics import confusion_matrix | |
def plot_confusion_matrix(cm, classes, | |
normalize=False, | |
title='Confusion matrix', | |
cmap=plt.cm.winter): | |
if normalize: | |
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import confusion_matrix, classification_report | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.pipeline import Pipeline, make_pipeline | |
from sklearn.metrics import roc_auc_score, roc_curve | |
def find_best_threshold(thresholds, fpr, tpr): | |
""" | |
find the best threshold from the roc curve. by finding the threshold for the point which is closest to (fpr=0,tpr=1) | |
""" | |
fpr_tpr = pd.DataFrame({'thresholds': thresholds, 'fpr': fpr, 'tpr': tpr}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def describe_categorical_values(df, non_interesting_columns=[], num_categories=5): | |
values_df = pd.DataFrame() | |
for i, column in enumerate(df.columns): | |
if column in non_interesting_columns: | |
continue | |
top_values0 = ["{}: {}%".format(x,int(round(100*y/len(df)))) | |
for x, y in zip(df[column].value_counts(dropna=False).head(num_categories).index, | |
df[column].value_counts(dropna=False).head(num_categories).values)] | |
if len(top_values0) < num_categories: | |
top_values = [None]*num_categories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################### | |
# Import libraries | |
#################### | |
library(rvest) | |
library(XML) | |
library(xml2) | |
library(stringr) | |
library(data.table) | |
#################### |