dragon-ml-toolbox 1.2.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dragon-ml-toolbox
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A collection of tools for data science and machine learning projects
5
5
  Author-email: Karl Loza <luigiloza@gmail.com>
6
6
  License-Expression: MIT
@@ -11,6 +11,7 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
+ License-File: LICENSE-THIRD-PARTY.md
14
15
  Requires-Dist: numpy
15
16
  Requires-Dist: pandas
16
17
  Requires-Dist: matplotlib
@@ -1,9 +1,10 @@
1
- dragon_ml_toolbox-1.2.0.dist-info/licenses/LICENSE,sha256=2uUFNy7D0TLgHim1K5s3DIJ4q_KvxEXVilnU20cWliY,1066
1
+ dragon_ml_toolbox-1.2.1.dist-info/licenses/LICENSE,sha256=2uUFNy7D0TLgHim1K5s3DIJ4q_KvxEXVilnU20cWliY,1066
2
+ dragon_ml_toolbox-1.2.1.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=e1Hg5ZtaBpDV7ZvxhLe1ac28l7nMjvi1MSE5YvB1s-o,1472
2
3
  ml_tools/MICE_imputation.py,sha256=Xvupj6w4NJ7d8gcJbpp1y3LVVnWEfvx-It7oEksuT5I,7349
3
4
  ml_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- ml_tools/data_exploration.py,sha256=AMQ5XLrRhV6dLhptjl2Jppgk9JJ06ZjXEuvqkjC3gt0,26998
5
+ ml_tools/data_exploration.py,sha256=laTNbN5_xlhqWiKfF-cJ9yMZ8zAM2a-AryqgiIQBBLg,26649
5
6
  ml_tools/datasetmaster.py,sha256=VUneKshnmjOGbtqVVGTFcIMRKF3s6ZDYrosIYKDjD80,28956
6
- ml_tools/ensemble_learning.py,sha256=uA7A94CLv8o2l125oTEi0cjHusZkB-7Mnrtn7SGTfjs,29714
7
+ ml_tools/ensemble_learning.py,sha256=5UmlXI3Orm5zL0P07Ub_Y0gwjruH-REHY-cFWQpJWb0,29085
7
8
  ml_tools/handle_excel.py,sha256=IR0VQc3hYdmjwC31E5YxDnRcWig4jSIx7Y_7to-KZz4,11969
8
9
  ml_tools/logger.py,sha256=XwSpCUzw2Le24fJHyljBxNLgw63SwjZ0pMjTJqf0ylI,4622
9
10
  ml_tools/particle_swarm_optimization.py,sha256=jpkje4OETC9fyISxxUTx4XGrImSU6gDEcwz46ZDs2bQ,19250
@@ -11,7 +12,7 @@ ml_tools/pytorch_models.py,sha256=Oykw02sOZLCjvSadQd64UGesBN7kq0x1EGXHusvYiQI,99
11
12
  ml_tools/trainer.py,sha256=Zd7AaHeoNd8dEas2JChWoHaCUpWUVRDUMybuHaKJ0XY,16740
12
13
  ml_tools/utilities.py,sha256=mG_--EFplfI9H7OhrWI8VkdNJtTbs4Wbz32xvcFWps8,5518
13
14
  ml_tools/vision_helpers.py,sha256=lBAW6dzAK-HOswAt1fU_tfP9hkNLY5D8c_I_7hhEXno,7528
14
- dragon_ml_toolbox-1.2.0.dist-info/METADATA,sha256=LmlbpETQETUcZuGatEtnP6JttrkN7kVObxjzvl5INfk,5128
15
- dragon_ml_toolbox-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- dragon_ml_toolbox-1.2.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
17
- dragon_ml_toolbox-1.2.0.dist-info/RECORD,,
15
+ dragon_ml_toolbox-1.2.1.dist-info/METADATA,sha256=_dLYb0G6dqpxh2jeWdWuG91LHQZCNDq2HVxbcBLlcu0,5165
16
+ dragon_ml_toolbox-1.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ dragon_ml_toolbox-1.2.1.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
18
+ dragon_ml_toolbox-1.2.1.dist-info/RECORD,,
@@ -0,0 +1,23 @@
1
+ # Third-Party Licenses
2
+
3
+ This project depends on the following third-party packages. Each is governed by its own license, linked below.
4
+
5
+ - [pandas](https://github.com/pandas-dev/pandas/blob/main/LICENSE)
6
+ - [numpy](https://github.com/numpy/numpy/blob/main/LICENSE.txt)
7
+ - [matplotlib](https://github.com/matplotlib/matplotlib/blob/main/LICENSE/LICENSE)
8
+ - [seaborn](https://github.com/mwaskom/seaborn/blob/main/LICENSE)
9
+ - [statsmodels](https://github.com/statsmodels/statsmodels/blob/main/LICENSE.txt)
10
+ - [ipython](https://github.com/ipython/ipython/blob/main/COPYING.rst)
11
+ - [torch](https://github.com/pytorch/pytorch/blob/main/LICENSE)
12
+ - [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)
13
+ - [imblearn](https://github.com/scikit-learn-contrib/imbalanced-learn/blob/main/LICENSE)
14
+ - [Pillow](https://github.com/python-pillow/Pillow/blob/main/LICENSE)
15
+ - [joblib](https://github.com/joblib/joblib/blob/main/LICENSE.txt)
16
+ - [xgboost](https://github.com/dmlc/xgboost/blob/main/LICENSE)
17
+ - [lightgbm](https://github.com/microsoft/LightGBM/blob/master/LICENSE)
18
+ - [shap](https://github.com/shap/shap/blob/master/LICENSE)
19
+ - [openpyxl](https://github.com/chronossc/openpyxl/blob/main/LICENSE)
20
+ - [miceforest](https://github.com/AnotherSamWilson/miceforest/blob/main/LICENSE)
21
+ - [polars](https://github.com/pola-rs/polars/blob/main/LICENSE)
22
+ - [torchvision](https://github.com/pytorch/vision/blob/main/LICENSE)
23
+ - [pyswarm](https://pythonhosted.org/pyswarm/#license)
@@ -15,8 +15,7 @@ from ml_tools.utilities import sanitize_filename
15
15
 
16
16
 
17
17
  # Keep track of all available functions, show using `info()`
18
- __all__ = ["load_dataframe",
19
- "summarize_dataframe",
18
+ __all__ = ["summarize_dataframe",
20
19
  "drop_rows_with_missing_data",
21
20
  "split_features_targets",
22
21
  "show_null_columns",
@@ -33,21 +32,6 @@ __all__ = ["load_dataframe",
33
32
  "drop_vif_based"]
34
33
 
35
34
 
36
- def load_dataframe(df_path: str) -> pd.DataFrame:
37
- """
38
- Loads a DataFrame from a CSV file.
39
-
40
- Args:
41
- df_path (str): Path to the CSV file.
42
-
43
- Returns:
44
- pd.DataFrame: Loaded DataFrame.
45
- """
46
- df = pd.read_csv(df_path, encoding='utf-8')
47
- print(f"DataFrame shape {df.shape}")
48
- return df
49
-
50
-
51
35
  def summarize_dataframe(df: pd.DataFrame, round_digits: int = 2):
52
36
  """
53
37
  Returns a summary DataFrame with data types, non-null counts, number of unique values,
@@ -21,6 +21,8 @@ from sklearn.preprocessing import StandardScaler, MaxAbsScaler, MinMaxScaler
21
21
  from sklearn.metrics import accuracy_score, classification_report, ConfusionMatrixDisplay, mean_absolute_error, mean_squared_error, r2_score, roc_curve, roc_auc_score
22
22
  import shap
23
23
 
24
+ from .utilities import yield_dataframes_from_dir
25
+
24
26
  import warnings # Ignore warnings
25
27
  warnings.filterwarnings('ignore', category=DeprecationWarning)
26
28
  warnings.filterwarnings('ignore', category=FutureWarning)
@@ -28,23 +30,6 @@ warnings.filterwarnings('ignore', category=UserWarning)
28
30
 
29
31
 
30
32
  ###### 1. Dataset Loader ######
31
- #Load imputed datasets as a generator
32
- def yield_imputed_dataframe(datasets_dir: str):
33
- '''
34
- Yields a tuple `(dataframe, dataframe_name)`
35
- '''
36
- dataset_filenames = [dataset for dataset in os.listdir(datasets_dir) if dataset.endswith(".csv")]
37
- if not dataset_filenames:
38
- raise IOError(f"No imputed datasets have been found at {datasets_dir}")
39
-
40
- for dataset_filename in dataset_filenames:
41
- full_path = os.path.join(datasets_dir, dataset_filename)
42
- df = pd.read_csv(full_path)
43
- #remove extension
44
- filename = os.path.splitext(os.path.basename(dataset_filename))[0]
45
- print(f"Working on dataset: {filename}")
46
- yield (df, filename)
47
-
48
33
  #Split a dataset into features and targets datasets
49
34
  def dataset_yielder(df: pd.DataFrame, target_cols: list[str]):
50
35
  '''
@@ -543,7 +528,7 @@ def get_shap_values(model, model_name: str,
543
528
  plot_size=figsize,
544
529
  max_display=max_display_features,
545
530
  alpha=0.7,
546
- color=plt.get_cmap('viridis')
531
+ color=plt.get_cmap('viridis') # type: ignore
547
532
  )
548
533
 
549
534
  # Add professional styling
@@ -674,7 +659,7 @@ def run_pipeline(datasets_dir: str, save_dir: str, target_columns: list[str], ta
674
659
  #Check paths
675
660
  _check_paths(datasets_dir, save_dir)
676
661
  #Yield imputed dataset
677
- for dataframe, dataframe_name in yield_imputed_dataframe(datasets_dir):
662
+ for dataframe, dataframe_name in yield_dataframes_from_dir(datasets_dir):
678
663
  #Yield features dataframe and target dataframe
679
664
  for df_features, df_target, feature_names, target_name in dataset_yielder(df=dataframe, target_cols=target_columns):
680
665
  #Dataset pipeline