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
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 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
@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 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',
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",