Skip to content

Commit

Permalink
cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Dec 26, 2024
1 parent 281dbd7 commit 0149893
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 43 deletions.
14 changes: 10 additions & 4 deletions simba/labelling/labelling_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
from typing_extensions import Literal

import simba
from simba.ui.tkinter_functions import Entry_Box
from simba.mixins.config_reader import ConfigReader
from simba.utils.checks import (check_valid_dataframe, check_valid_boolean, check_str, check_valid_dict, check_file_exist_and_readable, check_float, check_int, check_that_column_exist)
from simba.ui.tkinter_functions import Entry_Box
from simba.utils.checks import (check_file_exist_and_readable, check_float,
check_int, check_str, check_that_column_exist,
check_valid_boolean, check_valid_dataframe,
check_valid_dict)
from simba.utils.enums import Options, TagNames
from simba.utils.errors import FrameRangeError, NoDataError, NoFilesFoundError
from simba.utils.lookups import (get_labelling_img_kbd_bindings, get_labelling_video_kbd_bindings)
from simba.utils.lookups import (get_labelling_img_kbd_bindings,
get_labelling_video_kbd_bindings)
from simba.utils.printing import log_event, stdout_success
from simba.utils.read_write import (read_frm_of_video, get_all_clf_names, get_fn_ext, get_video_meta_data, read_config_entry, read_df, write_df)
from simba.utils.read_write import (get_all_clf_names, get_fn_ext,
get_video_meta_data, read_config_entry,
read_df, read_frm_of_video, write_df)
from simba.utils.warnings import FrameRangeWarning

PLAY_VIDEO_SCRIPT_PATH = os.path.join(os.path.dirname(simba.__file__), "labelling/play_annotation_video.py")
Expand Down
5 changes: 3 additions & 2 deletions simba/mixins/train_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from json import loads
from subprocess import call

import cv2
import numpy as np
import pandas as pd
import seaborn as sns
import shap
import cv2
from imblearn.combine import SMOTEENN
from imblearn.over_sampling import SMOTE
from numba import njit, typed, types
Expand Down Expand Up @@ -65,7 +65,8 @@
check_if_dir_exists, check_if_valid_input,
check_instance, check_int, check_str,
check_that_column_exist, check_valid_array,
check_valid_dataframe, check_valid_lst, check_valid_boolean)
check_valid_boolean, check_valid_dataframe,
check_valid_lst)
from simba.utils.data import (detect_bouts, detect_bouts_multiclass,
get_library_version)
from simba.utils.enums import (OS, ConfigKey, Defaults, Dtypes, Formats,
Expand Down
25 changes: 15 additions & 10 deletions simba/plotting/shap_agg_stats_visualizer.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
__author__ = "Simon Nilsson"

import itertools
import os
from typing import Optional, Union, Tuple, List
from datetime import datetime
import itertools
from typing import List, Optional, Tuple, Union

import cv2
import numpy as np
import pandas as pd
import cv2
from simba.utils.enums import Paths

import simba
from simba.utils.checks import (check_file_exist_and_readable,
check_if_df_field_is_boolean,
check_if_dir_exists, check_if_valid_img,
check_instance, check_int, check_str,
check_that_column_exist, check_valid_boolean,
check_valid_dataframe, check_valid_tuple)
from simba.utils.enums import Paths
from simba.utils.errors import FeatureNumberMismatchError
from simba.utils.checks import (check_if_df_field_is_boolean,
check_if_dir_exists, check_instance, check_int,
check_str, check_that_column_exist, check_valid_boolean,
check_file_exist_and_readable, check_if_valid_img, check_valid_tuple, check_valid_dataframe)
from simba.utils.read_write import read_shap_feature_categories_csv, read_shap_img_paths, bgr_to_rgb_tuple
from simba.utils.printing import SimbaTimer, stdout_success
import simba
from simba.utils.read_write import (bgr_to_rgb_tuple,
read_shap_feature_categories_csv,
read_shap_img_paths)

SIMBA_DIR = os.path.dirname(simba.__file__)

Expand Down
12 changes: 6 additions & 6 deletions simba/sandbox/add_sheet_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
from typing_extensions import Literal

from simba.utils.checks import (check_file_exist_and_readable,
check_if_dir_exists, check_valid_boolean,
check_if_keys_exist_in_dict, check_valid_lst,
check_valid_dataframe, check_str)


check_if_dir_exists,
check_if_keys_exist_in_dict, check_str,
check_valid_boolean, check_valid_dataframe,
check_valid_lst)
from simba.utils.enums import Formats
from simba.utils.errors import CountError, DuplicationError
from simba.utils.printing import stdout_success
from simba.utils.read_write import (find_files_of_filetypes_in_directory, get_fn_ext, read_pickle)
from simba.utils.read_write import (find_files_of_filetypes_in_directory,
get_fn_ext, read_pickle)

ADJ_MUTUAL_INFO = "adjusted mutual information"
FOWLKES_MALLOWS = "fowlkes mallows"
Expand Down
29 changes: 19 additions & 10 deletions simba/sandbox/create_shap_log_mp.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
from typing import Optional, Union, List, Tuple
import functools
import multiprocessing
import os
from typing import List, Optional, Tuple, Union

import cv2
import pandas as pd
import numpy as np
import pandas as pd
import shap
import os
from sklearn.ensemble import RandomForestClassifier
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.enums import Formats, Defaults
from simba.utils.warnings import NotEnoughDataWarning, ShapWarning

from simba.mixins.train_model_mixin import TrainModelMixin
from simba.plotting.shap_agg_stats_visualizer import \
ShapAggregateStatisticsCalculator
from simba.utils.checks import (check_file_exist_and_readable,
check_if_dir_exists, check_instance, check_int,
check_str, check_valid_array,
check_valid_boolean, check_valid_dataframe,
check_valid_lst)
from simba.utils.enums import Defaults, Formats
from simba.utils.errors import NoDataError
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.read_write import find_core_cnt
from simba.plotting.shap_agg_stats_visualizer import ShapAggregateStatisticsCalculator
import multiprocessing, functools
from simba.utils.checks import (check_valid_dataframe, check_valid_array, check_instance, check_valid_boolean, check_valid_lst, check_str, check_int, check_file_exist_and_readable, check_if_dir_exists)
from simba.mixins.train_model_mixin import TrainModelMixin
from simba.utils.warnings import NotEnoughDataWarning, ShapWarning


def _create_shap_mp_helper(data: Tuple[int, pd.DataFrame],
explainer: shap.TreeExplainer,
Expand Down
8 changes: 6 additions & 2 deletions simba/sandbox/unsupervised/cluster_frequentist_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

import numpy as np
import pandas as pd

from simba.mixins.statistics_mixin import Statistics
from simba.utils.checks import (check_file_exist_and_readable,
check_if_dir_exists,
check_if_keys_exist_in_dict,
check_valid_boolean, check_if_dir_exists)
check_valid_boolean)
from simba.utils.enums import UML
from simba.utils.errors import InvalidInputError
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.read_write import (find_files_of_filetypes_in_directory, get_unique_values_in_iterable, read_pickle, df_to_xlsx_sheet)
from simba.utils.read_write import (df_to_xlsx_sheet,
find_files_of_filetypes_in_directory,
get_unique_values_in_iterable, read_pickle)


class ClusterFrequentistCalculator():
Expand Down
6 changes: 4 additions & 2 deletions simba/sandbox/unsupervised/cluster_xai_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
DESCRIPTIVE_STATISTICS = "descriptive_statistics"
ANOVA_HEADERS = ["FEATURE NAME", "F-STATISTIC", "P-VALUE"]

from simba.utils.checks import check_if_dir_exists, check_valid_boolean, check_valid_dict
from simba.utils.enums import Formats, UML
from simba.utils.checks import (check_if_dir_exists, check_valid_boolean,
check_valid_dict)
from simba.utils.enums import UML, Formats


class ClusterXAICalculator():
"""
Expand Down
16 changes: 10 additions & 6 deletions simba/sandbox/unsupervised/clusterer_comparisons_metrics.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
import itertools
import os
from typing import Union
import pandas as pd

from simba.utils.checks import (check_if_dir_exists, check_valid_boolean, check_if_keys_exist_in_dict)
import pandas as pd

from simba.mixins.statistics_mixin import Statistics
from simba.utils.enums import Formats, UML
from simba.utils.checks import (check_if_dir_exists,
check_if_keys_exist_in_dict,
check_valid_boolean)
from simba.utils.enums import UML, Formats
from simba.utils.errors import CountError
from simba.utils.printing import stdout_success, SimbaTimer
from simba.utils.read_write import (find_files_of_filetypes_in_directory, get_fn_ext, read_pickle, create_empty_xlsx_file, df_to_xlsx_sheet)
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.read_write import (create_empty_xlsx_file, df_to_xlsx_sheet,
find_files_of_filetypes_in_directory,
get_fn_ext, read_pickle)

# HOMOGENEITY_SCORE, V_MEASURE_SCORE, COMPLETENESS_SCORE, SILHOUETTE_SCORE

Expand Down
2 changes: 1 addition & 1 deletion simba/utils/read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from shapely.geometry import (LineString, MultiLineString, MultiPolygon, Point,
Polygon)

import simba
from simba.utils.checks import (check_file_exist_and_readable, check_float,
check_if_dir_exists,
check_if_filepath_list_is_empty,
Expand All @@ -65,7 +66,6 @@
NoDataFoundWarning, NoFileFoundWarning,
ThirdPartyAnnotationsInvalidFileFormatWarning)

import simba
SIMBA_DIR = os.path.dirname(simba.__file__)

PARSE_OPTIONS = csv.ParseOptions(delimiter=",")
Expand Down

0 comments on commit 0149893

Please sign in to comment.