junshan-kit 2.1.3__py2.py3-none-any.whl → 2.1.6__py2.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.
@@ -0,0 +1,45 @@
1
+
2
+ import pandas as pd
3
+ import os
4
+
5
+ import junshan_kit.datahub
6
+
7
+ class CSVToPandas:
8
+ def __init__(self):
9
+ self.data_downloader = junshan_kit.datahub.kaggle_data()
10
+
11
+
12
+ def read_csv(self, data_name):
13
+ self.csv_path = f'exp_data/{data_name}/{data_name}.csv'
14
+ if not os.path.exists(self.csv_path):
15
+ self.data_downloader.download_data(f'{data_name}', f'exp_data/{data_name}')
16
+
17
+ # ----------------- ccfd_kaggle ----------------------------------
18
+ def ccfd_kaggle(self, data_name = 'ccfd-kaggle', show_info = True):
19
+ self.read_csv(data_name)
20
+
21
+ df = pd.read_csv(self.csv_path)
22
+ m_before, n_before = df.shape
23
+ df = df.dropna(axis=0, how='any')
24
+ m_after, n_after = df.shape
25
+ df['Class'] = df['Class'].replace(0, -1)
26
+
27
+ if show_info:
28
+ pos_count = (df['Class'] == 1).sum()
29
+ neg_count = (df['Class'] == -1).sum()
30
+
31
+ print('\n' + '='*60)
32
+ print(f"{'CCFD-Kaggle Dataset Info':^60}")
33
+ print('='*60)
34
+ print(f"{'Original size:':<25} {m_before} rows x {n_before} cols")
35
+ print(f"{'Size after dropping NaNs:':<25} {m_after} rows x {n_after} cols")
36
+ print(f"{'Export size:':<25} {m_after} rows x {n_after} cols")
37
+ print(f"{'Positive samples (+1):':<25} {pos_count}")
38
+ print(f"{'Negative samples (-1):':<25} {neg_count}")
39
+ print('-'*60)
40
+ print(f"More details: https://www.jianguoyun.com/p/Dd1clVgQ4ZThCxiwzZQGIAA")
41
+ print('='*60 + '\n')
42
+
43
+ return df
44
+
45
+
junshan_kit/datahub.py CHANGED
@@ -1,24 +1,30 @@
1
1
  import kagglehub
2
2
  import os
3
+ import warnings
3
4
  import shutil
4
5
  from kaggle.api.kaggle_api_extended import KaggleApi
5
6
 
6
7
  class kaggle_data:
7
- def list_user_datasets(self):
8
+ def list_datasets(self):
8
9
  api = KaggleApi()
9
10
  api.authenticate()
10
-
11
- # Get the list of datasets for a specific user
12
11
  datasets = api.dataset_list(user='junshan888')
13
-
12
+ print('Available datasets:')
14
13
  print('*' * 60)
15
14
  if datasets is not None:
16
15
  for ds in datasets:
17
16
  if ds is not None:
18
- # Print the dataset title
19
17
  print(ds.title)
20
18
  print('*' * 60)
21
19
 
20
+ def list_user_datasets(self):
21
+ warnings.warn(
22
+ "list_user_datasets() is deprecated. Use list_datasets() instead.",
23
+ DeprecationWarning,
24
+ stacklevel=2
25
+ )
26
+ return self.list_datasets()
27
+
22
28
  # example: list_user_datasets()
23
29
 
24
30
  #---------------------------------------------------------------
@@ -36,11 +42,13 @@ class kaggle_data:
36
42
  # example: read_data(copy_path='./exp_data')
37
43
 
38
44
 
45
+
46
+
47
+
39
48
  if __name__ == "__main__":
40
49
  # Your code here
41
50
  data = kaggle_data()
42
51
  # Example usage
43
- print('Available datasets:')
44
52
  data.list_user_datasets()
45
53
  data.download_data(data_name='letter-libsvm', copy_path='./exp_data/Letter')
46
54
 
junshan_kit/test.py ADDED
@@ -0,0 +1,5 @@
1
+ import DataProcessor
2
+
3
+
4
+ data_loader = DataProcessor.CSVToPandas()
5
+ data_loader.ccfd_kaggle()
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: junshan_kit
3
- Version: 2.1.3
3
+ Version: 2.1.6
4
4
  Summary: This is an optimization tool.
5
5
  Author-email: Junshan Yin <junshanyin@163.com>
6
6
  Requires-Dist: kaggle==1.7.4.5
7
7
  Requires-Dist: kagglehub==0.3.13
8
8
  Requires-Dist: numpy==2.2.6
9
+ Requires-Dist: pandas==2.3.3
9
10
  Requires-Dist: scikit-learn==1.7.1
10
11
  Description-Content-Type: text/markdown
11
12
 
@@ -0,0 +1,7 @@
1
+ junshan_kit/DataProcessor.py,sha256=9mlLYxdDiMX7baZmfJk5QuxT4vx_V728XIFbkXmCP0s,1594
2
+ junshan_kit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ junshan_kit/datahub.py,sha256=BWcG_TPW1xf_y_GzxRXanuOAB01WugBiO5r53EDbr8s,1815
4
+ junshan_kit/test.py,sha256=aEaobINtr4Ri0jX6D8u49xgftyA6SE12wx0P6m5x-2w,90
5
+ junshan_kit-2.1.6.dist-info/METADATA,sha256=KZTS690qvlgOduiYwo6oqshsk4dqY8m9HcVtWu-aXTI,599
6
+ junshan_kit-2.1.6.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
7
+ junshan_kit-2.1.6.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- junshan_kit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- junshan_kit/datahub.py,sha256=G1WmHEQvUnlpyZrC1vDCLBI-ZVeCA-lHoQ8qiL4I7p0,1655
3
- junshan_kit-2.1.3.dist-info/METADATA,sha256=HZwmPFyfHIJSdOfNWhBj0Ddg684BrpoV6_DCKkGxshk,570
4
- junshan_kit-2.1.3.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
5
- junshan_kit-2.1.3.dist-info/RECORD,,