Skip to content

Instantly share code, notes, and snippets.

View UrszulaCzerwinska's full-sized avatar
:octocat:
exploring

Urszula Czerwinska UrszulaCzerwinska

:octocat:
exploring
View GitHub Profile
detection_model_dir: str,
classification_model_dir: str,
recognition_model_dir: str,
detection_limit_side_len: float = 960,
detection_limit_type: str = "max",
detection_threshold: float = 0.3,
detection_box_threshold: float = 0.6,
detection_unclip_ratio: float = 1.5,
detection_use_dilation: bool = False,
detection_score_mode: str = "fast",
def parse_lang(lang):
latin_lang = [
'af', 'az', 'bs', 'cs', 'cy', 'da', 'de', 'es', 'et', 'fr', 'ga', 'hr',
'hu', 'id', 'is', 'it', 'ku', 'la', 'lt', 'lv', 'mi', 'ms', 'mt', 'nl',
'no', 'oc', 'pi', 'pl', 'pt', 'ro', 'rs_latin', 'sk', 'sl', 'sq', 'sv',
'sw', 'tl', 'tr', 'uz', 'vi', 'french', 'german'
]
arabic_lang = ['ar', 'fa', 'ug', 'ur']
cyrillic_lang = [
'ru', 'rs_cyrillic', 'be', 'bg', 'uk', 'mn', 'abq', 'ady', 'kbd', 'ava',
@UrszulaCzerwinska
UrszulaCzerwinska / model_params
Created February 14, 2023 15:40
paddle_model_params
{'use_angle_cls': False, 'text_detector': <tools.infer.predict_det.TextDetector object at 0x106576790>, 'text_recognizer': <tools.infer.predict_rec.TextRecognizer object at 0x29fa54e50>, 'drop_score': 0.5, 'args': Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, shape_info_filename=None, precision='fp32', gpu_mem=500, image_dir=None, det_algorithm='DB', det_model_dir='/Users/urszula.czerwinska/.paddleocr/whl/det/ch/ch_PP-OCRv3_det_infer', det_limit_side_len=960, det_limit_type='max', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_sast_polygon=False, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_box_type='quad', det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, det_fce_box_ty
def interactions_heatmap(shap_interaction_values, n, column_names, plot_heatmap=True):
"""
Sums over first tensor of shap interaction values dimension (axis =0), returns a matrix dim nfeatures x nfeatures of interaction values
Parameters
----------
shap_interaction_values (np.array): tensor of interaction values produced by shap estimator.shap_interaction_values()
n (int) - n top features to be kept
column_names (List[str], np.array[]) - names of colums for feature names
plot_heatmap (bool) - default True should the image be plotted
def simulate_with_shap(x,idx, col, val_range, explainer, pipeline_trans=None):
"""
Function starts with an instance `idx` of dataset x and varies values of selected column `col`,
it needs eplainer for dataset x and optionally it can use the pipeline transformer to transform values as in the initial model
Parameters
----------
n_min : int
minimal value to simulate
n_max : int
def interaction_plot(col1, col2, interaction_values, background_display, is_cat=True, width=700, height=500,opacity=0.7):
"""
This function plots shap interaction values between two selected columns (col1 & col2), where x axis are values of column 1, y axis are shap interaction values, and hue (color) is the second column.
Args:
col1 (str) : name of the first feature
col2 (str) : name of the second feature
interaction_values (numpy.array) : matrix obtained with shap shap_interaction_values
background_display (pandas.DataFrame) : the original values for background data used in shap explainer
is_cat (bool) : is the col2 a categorical value, True by default
import plotly.io as pio
pio.templates.default = "plotly_white"
from plotly.subplots import make_subplots
import pandas as pd
import plotly.express as px
import matplotlib.pylab as pl
import numpy as np
#ipmort finction from other gists
from entites_graph import NewsMining
from html_file_parsing import ArticleParsing
#imports
import pandas as pd
# set url
url = "https://towardsdatascience.com/cat-dog-or-elon-musk-145658489730"
class GraphShow():
""""Create demo page"""
def __init__(self):
self.base = '''
<html>
<head>
<script type="text/javascript" src="VIS/dist/vis.js"></script>
<link href="VIS/dist/vis.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
import re
from collections import Counter
import spacy
from graph_show import GraphShow
import itertools
from collections import defaultdict
class NewsMining():