dwvml 0.1.0__tar.gz

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.
dwvml-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dwvml-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwvml
3
+ Version: 0.1.0
4
+ Summary: Reusable preprocessing utilities for machine learning
5
+ Author: Dev
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/dwvml
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy>=1.23
12
+ Requires-Dist: pandas>=1.5
13
+ Requires-Dist: scipy>=1.9
14
+ Requires-Dist: scikit-learn>=1.2
15
+ Dynamic: license-file
16
+ Dynamic: requires-python
17
+
18
+ # DWVML
19
+
20
+ Reusable preprocessing utilities for tabular machine learning.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install dwvml
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ from dwvml import preprocess_train_test
32
+
33
+ x_train_final, x_test_final, preprocessors = preprocess_train_test(
34
+ x_train,
35
+ x_test
36
+ )
37
+ ```
38
+
39
+ The package automatically detects numerical and categorical columns, imputes missing values, scales numerical features, one-hot encodes categorical features, and combines the resulting features.
40
+
41
+ Transform another dataset later with the fitted preprocessors:
42
+
43
+ ```python
44
+ from dwvml import transform_new_data
45
+ x_new_final = transform_new_data(x_new, preprocessors)
46
+ ```
dwvml-0.1.0/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # DWVML
2
+
3
+ Reusable preprocessing utilities for tabular machine learning.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install dwvml
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from dwvml import preprocess_train_test
15
+
16
+ x_train_final, x_test_final, preprocessors = preprocess_train_test(
17
+ x_train,
18
+ x_test
19
+ )
20
+ ```
21
+
22
+ The package automatically detects numerical and categorical columns, imputes missing values, scales numerical features, one-hot encodes categorical features, and combines the resulting features.
23
+
24
+ Transform another dataset later with the fitted preprocessors:
25
+
26
+ ```python
27
+ from dwvml import transform_new_data
28
+ x_new_final = transform_new_data(x_new, preprocessors)
29
+ ```
@@ -0,0 +1,10 @@
1
+ """DWVML - reusable preprocessing utilities for machine learning."""
2
+
3
+ from .preprocessing import preprocess_train_test, transform_new_data
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = [
8
+ "preprocess_train_test",
9
+ "transform_new_data",
10
+ ]
@@ -0,0 +1,111 @@
1
+ """Preprocessing helpers for tabular machine-learning data."""
2
+
3
+ import numpy as np
4
+ import pandas as pd
5
+ from scipy.sparse import hstack
6
+ from sklearn.impute import SimpleImputer
7
+ from sklearn.preprocessing import OneHotEncoder, StandardScaler
8
+
9
+
10
+ def preprocess_train_test(x_train: pd.DataFrame, x_test: pd.DataFrame):
11
+ """Preprocess train/test tabular data with consistent fitted transformers.
12
+
13
+ Numerical columns: median imputation -> StandardScaler
14
+ Categorical columns: most-frequent imputation -> OneHotEncoder
15
+ The transformers are fitted only on x_train.
16
+
17
+ Returns
18
+ -------
19
+ x_train_final, x_test_final, preprocessors
20
+ """
21
+ if not isinstance(x_train, pd.DataFrame):
22
+ raise TypeError("x_train must be a pandas DataFrame.")
23
+ if not isinstance(x_test, pd.DataFrame):
24
+ raise TypeError("x_test must be a pandas DataFrame.")
25
+
26
+ missing_in_test = [c for c in x_train.columns if c not in x_test.columns]
27
+ extra_in_test = [c for c in x_test.columns if c not in x_train.columns]
28
+ if missing_in_test:
29
+ raise ValueError(f"Columns missing in x_test: {missing_in_test}")
30
+ if extra_in_test:
31
+ raise ValueError(f"Extra columns in x_test: {extra_in_test}")
32
+
33
+ x_test = x_test[x_train.columns]
34
+
35
+ numeric_cols = x_train.select_dtypes(include="number").columns.tolist()
36
+ categorical_cols = x_train.select_dtypes(include=["object", "category", "string"]).columns.tolist()
37
+
38
+ num_imputer = SimpleImputer(strategy="median")
39
+ scaler = None
40
+ if numeric_cols:
41
+ x_train_num = num_imputer.fit_transform(x_train[numeric_cols])
42
+ x_test_num = num_imputer.transform(x_test[numeric_cols])
43
+ scaler = StandardScaler()
44
+ x_train_scl = scaler.fit_transform(x_train_num)
45
+ x_test_scl = scaler.transform(x_test_num)
46
+ else:
47
+ x_train_scl = np.empty((len(x_train), 0))
48
+ x_test_scl = np.empty((len(x_test), 0))
49
+
50
+ cat_imputer = SimpleImputer(strategy="most_frequent")
51
+ ohe = None
52
+ if categorical_cols:
53
+ x_train_cat = cat_imputer.fit_transform(x_train[categorical_cols])
54
+ x_test_cat = cat_imputer.transform(x_test[categorical_cols])
55
+ ohe = OneHotEncoder(handle_unknown="ignore")
56
+ x_train_ohe = ohe.fit_transform(x_train_cat)
57
+ x_test_ohe = ohe.transform(x_test_cat)
58
+ else:
59
+ x_train_ohe = None
60
+ x_test_ohe = None
61
+
62
+ if numeric_cols and categorical_cols:
63
+ x_train_final = hstack((x_train_scl, x_train_ohe)).tocsr()
64
+ x_test_final = hstack((x_test_scl, x_test_ohe)).tocsr()
65
+ elif numeric_cols:
66
+ x_train_final = x_train_scl
67
+ x_test_final = x_test_scl
68
+ elif categorical_cols:
69
+ x_train_final = x_train_ohe
70
+ x_test_final = x_test_ohe
71
+ else:
72
+ raise ValueError("No numerical or categorical feature columns were found.")
73
+
74
+ preprocessors = {
75
+ "numeric_cols": numeric_cols,
76
+ "categorical_cols": categorical_cols,
77
+ "num_imputer": num_imputer,
78
+ "cat_imputer": cat_imputer,
79
+ "scaler": scaler,
80
+ "ohe": ohe,
81
+ }
82
+ return x_train_final, x_test_final, preprocessors
83
+
84
+
85
+ def transform_new_data(x_new: pd.DataFrame, preprocessors: dict):
86
+ """Transform new data using preprocessors already fitted by preprocess_train_test."""
87
+ if not isinstance(x_new, pd.DataFrame):
88
+ raise TypeError("x_new must be a pandas DataFrame.")
89
+
90
+ numeric_cols = preprocessors["numeric_cols"]
91
+ categorical_cols = preprocessors["categorical_cols"]
92
+
93
+ if numeric_cols:
94
+ x_new_num = preprocessors["num_imputer"].transform(x_new[numeric_cols])
95
+ x_new_scl = preprocessors["scaler"].transform(x_new_num)
96
+ else:
97
+ x_new_scl = np.empty((len(x_new), 0))
98
+
99
+ if categorical_cols:
100
+ x_new_cat = preprocessors["cat_imputer"].transform(x_new[categorical_cols])
101
+ x_new_ohe = preprocessors["ohe"].transform(x_new_cat)
102
+ else:
103
+ x_new_ohe = None
104
+
105
+ if numeric_cols and categorical_cols:
106
+ return hstack((x_new_scl, x_new_ohe)).tocsr()
107
+ if numeric_cols:
108
+ return x_new_scl
109
+ if categorical_cols:
110
+ return x_new_ohe
111
+ raise ValueError("No numerical or categorical feature columns were found.")
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwvml
3
+ Version: 0.1.0
4
+ Summary: Reusable preprocessing utilities for machine learning
5
+ Author: Dev
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/dwvml
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy>=1.23
12
+ Requires-Dist: pandas>=1.5
13
+ Requires-Dist: scipy>=1.9
14
+ Requires-Dist: scikit-learn>=1.2
15
+ Dynamic: license-file
16
+ Dynamic: requires-python
17
+
18
+ # DWVML
19
+
20
+ Reusable preprocessing utilities for tabular machine learning.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install dwvml
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ from dwvml import preprocess_train_test
32
+
33
+ x_train_final, x_test_final, preprocessors = preprocess_train_test(
34
+ x_train,
35
+ x_test
36
+ )
37
+ ```
38
+
39
+ The package automatically detects numerical and categorical columns, imputes missing values, scales numerical features, one-hot encodes categorical features, and combines the resulting features.
40
+
41
+ Transform another dataset later with the fitted preprocessors:
42
+
43
+ ```python
44
+ from dwvml import transform_new_data
45
+ x_new_final = transform_new_data(x_new, preprocessors)
46
+ ```
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ dwvml/__init__.py
6
+ dwvml/preprocessing.py
7
+ dwvml.egg-info/PKG-INFO
8
+ dwvml.egg-info/SOURCES.txt
9
+ dwvml.egg-info/dependency_links.txt
10
+ dwvml.egg-info/requires.txt
11
+ dwvml.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ numpy>=1.23
2
+ pandas>=1.5
3
+ scipy>=1.9
4
+ scikit-learn>=1.2
@@ -0,0 +1 @@
1
+ dwvml
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dwvml"
7
+ version = "0.1.0"
8
+ description = "Reusable preprocessing utilities for machine learning"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Dev" }]
13
+ dependencies = [
14
+ "numpy>=1.23",
15
+ "pandas>=1.5",
16
+ "scipy>=1.9",
17
+ "scikit-learn>=1.2",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/yourusername/dwvml"
22
+
23
+ [tool.setuptools.packages.find]
24
+ include = ["dwvml*"]
dwvml-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
dwvml-0.1.0/setup.py ADDED
@@ -0,0 +1,16 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="dwvml",
5
+ version="0.1.0",
6
+ description="Reusable preprocessing utilities for machine learning",
7
+ author="Dev",
8
+ packages=find_packages(),
9
+ python_requires=">=3.9",
10
+ install_requires=[
11
+ "numpy>=1.23",
12
+ "pandas>=1.5",
13
+ "scipy>=1.9",
14
+ "scikit-learn>=1.2",
15
+ ],
16
+ )