featuresmith-core 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.
Files changed (50) hide show
  1. featuresmith_core-0.1.0/LICENSE +187 -0
  2. featuresmith_core-0.1.0/PKG-INFO +50 -0
  3. featuresmith_core-0.1.0/README.md +19 -0
  4. featuresmith_core-0.1.0/pyproject.toml +58 -0
  5. featuresmith_core-0.1.0/setup.cfg +4 -0
  6. featuresmith_core-0.1.0/src/featuresmith/__init__.py +7 -0
  7. featuresmith_core-0.1.0/src/featuresmith/api.py +180 -0
  8. featuresmith_core-0.1.0/src/featuresmith/connectors/__init__.py +18 -0
  9. featuresmith_core-0.1.0/src/featuresmith/connectors/_paths.py +25 -0
  10. featuresmith_core-0.1.0/src/featuresmith/connectors/base.py +54 -0
  11. featuresmith_core-0.1.0/src/featuresmith/connectors/csv_connector.py +44 -0
  12. featuresmith_core-0.1.0/src/featuresmith/connectors/dataframe_connector.py +40 -0
  13. featuresmith_core-0.1.0/src/featuresmith/connectors/excel_connector.py +45 -0
  14. featuresmith_core-0.1.0/src/featuresmith/connectors/parquet_connector.py +44 -0
  15. featuresmith_core-0.1.0/src/featuresmith/connectors/registry.py +55 -0
  16. featuresmith_core-0.1.0/src/featuresmith/core/__init__.py +50 -0
  17. featuresmith_core-0.1.0/src/featuresmith/core/dataset.py +107 -0
  18. featuresmith_core-0.1.0/src/featuresmith/core/exceptions.py +17 -0
  19. featuresmith_core-0.1.0/src/featuresmith/core/profile_result.py +412 -0
  20. featuresmith_core-0.1.0/src/featuresmith/core/rule_finding.py +44 -0
  21. featuresmith_core-0.1.0/src/featuresmith/core/rule_result.py +49 -0
  22. featuresmith_core-0.1.0/src/featuresmith/core/schema.py +34 -0
  23. featuresmith_core-0.1.0/src/featuresmith/profiling/__init__.py +5 -0
  24. featuresmith_core-0.1.0/src/featuresmith/profiling/categorical.py +108 -0
  25. featuresmith_core-0.1.0/src/featuresmith/profiling/correlation.py +67 -0
  26. featuresmith_core-0.1.0/src/featuresmith/profiling/datetime.py +105 -0
  27. featuresmith_core-0.1.0/src/featuresmith/profiling/duplicates.py +48 -0
  28. featuresmith_core-0.1.0/src/featuresmith/profiling/missing.py +70 -0
  29. featuresmith_core-0.1.0/src/featuresmith/profiling/numeric.py +248 -0
  30. featuresmith_core-0.1.0/src/featuresmith/profiling/profiler.py +209 -0
  31. featuresmith_core-0.1.0/src/featuresmith/profiling/quality.py +29 -0
  32. featuresmith_core-0.1.0/src/featuresmith/profiling/summary.py +117 -0
  33. featuresmith_core-0.1.0/src/featuresmith/profiling/text.py +109 -0
  34. featuresmith_core-0.1.0/src/featuresmith/py.typed +1 -0
  35. featuresmith_core-0.1.0/src/featuresmith/rules/__init__.py +27 -0
  36. featuresmith_core-0.1.0/src/featuresmith/rules/base.py +69 -0
  37. featuresmith_core-0.1.0/src/featuresmith/rules/cardinality.py +95 -0
  38. featuresmith_core-0.1.0/src/featuresmith/rules/constants.py +115 -0
  39. featuresmith_core-0.1.0/src/featuresmith/rules/correlation.py +77 -0
  40. featuresmith_core-0.1.0/src/featuresmith/rules/duplicates.py +76 -0
  41. featuresmith_core-0.1.0/src/featuresmith/rules/engine.py +156 -0
  42. featuresmith_core-0.1.0/src/featuresmith/rules/leakage.py +93 -0
  43. featuresmith_core-0.1.0/src/featuresmith/rules/missing.py +83 -0
  44. featuresmith_core-0.1.0/src/featuresmith/rules/outliers.py +113 -0
  45. featuresmith_core-0.1.0/src/featuresmith/rules/registry.py +81 -0
  46. featuresmith_core-0.1.0/src/featuresmith_core.egg-info/PKG-INFO +50 -0
  47. featuresmith_core-0.1.0/src/featuresmith_core.egg-info/SOURCES.txt +48 -0
  48. featuresmith_core-0.1.0/src/featuresmith_core.egg-info/dependency_links.txt +1 -0
  49. featuresmith_core-0.1.0/src/featuresmith_core.egg-info/requires.txt +3 -0
  50. featuresmith_core-0.1.0/src/featuresmith_core.egg-info/top_level.txt +1 -0
@@ -0,0 +1,187 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as defined by Sections 2(b), any work of
48
+ authorship, including the original version of the Work and any
49
+ modifications or additions to that Work or Derivative Works of the Work,
50
+ that is intentionally submitted to the Licensor for inclusion in the Work
51
+ by the copyright owner or by an individual or Legal Entity authorized to
52
+ submit on behalf of the copyright owner. For the purposes of this
53
+ definition, "submitted" means any form of electronic, verbal, or written
54
+ communication sent to the Licensor or its representatives, including but
55
+ not limited to communication on electronic mailing lists, source code
56
+ control systems, and issue tracking systems that are managed by, or on
57
+ behalf of, the Licensor for the purpose of discussing and improving the
58
+ Work, but excluding communication that is conspicuously marked or
59
+ otherwise designated in writing by the copyright owner as "Not a
60
+ Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
63
+ whom a Contribution has been received by the Licensor and subsequently
64
+ incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, You must include a readable copy of the
108
+ attribution notices contained within such NOTICE file, in
109
+ at least one of the following places: within a NOTICE text
110
+ file distributed as part of the Derivative Works; within
111
+ the Source form or documentation, if provided along with the
112
+ Derivative Works; or, within a display generated by the
113
+ Derivative Works, if and wherever such third-party notices
114
+ normally appear. The contents of the NOTICE file are for
115
+ informational purposes only and do not modify the License.
116
+ You may add Your own attribution notices within Derivative
117
+ Works that You distribute, alongside or as an addendum to
118
+ the NOTICE text from the Work, provided that such additional
119
+ attribution notices cannot be construed as modifying the
120
+ License.
121
+
122
+ You may add Your own license statement for Your modifications and
123
+ may provide additional grant of rights to use, copy, modify, merge,
124
+ publish, distribute, sublicense, and/or sell copies of the
125
+ Contribution, either on its own or as part of the Work.
126
+
127
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
128
+ any Contribution intentionally submitted for inclusion in the Work
129
+ by You to the Licensor shall be under the terms and conditions of
130
+ this License, without any additional terms or conditions.
131
+ Notwithstanding the above, nothing herein shall supersede or modify
132
+ the terms of any separate license agreement you may have executed
133
+ with Licensor regarding such Contributions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor,
137
+ except as required for reasonable and customary use in describing the
138
+ origin of the Work and reproducing the content of the NOTICE file.
139
+
140
+ 7. Disclaimer of Warranty. Unless required by applicable law or
141
+ agreed to in writing, Licensor provides the Work (and each
142
+ Contributor provides its Contributions) on an "AS IS" BASIS,
143
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
+ implied, including, without limitation, any warranties or conditions
145
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
+ PARTICULAR PURPOSE. You are solely responsible for determining the
147
+ appropriateness of using or redistributing the Work and assume any
148
+ risks associated with Your exercise of permissions under this License.
149
+
150
+ 8. Limitation of Liability. In no event and under no legal theory,
151
+ whether in tort (including negligence), contract, or otherwise,
152
+ unless required by applicable law (such as deliberate and grossly
153
+ negligent acts) or agreed to in writing, shall any Contributor be
154
+ liable to You for damages, including any direct, indirect, special,
155
+ incidental, or exemplary damages of any character arising as a
156
+ result of this License or out of the use or inability to use the
157
+ Work (including but not limited to damages for loss of goodwill,
158
+ work stoppage, computer failure or malfunction, or all other
159
+ commercial damages or losses), even if such Contributor has been
160
+ advised of the possibility of such damages.
161
+
162
+ 9. Accepting Warranty or Additional Liability. While redistributing
163
+ the Work or Derivative Works thereof, You may choose to offer,
164
+ and charge a fee for, acceptance of support, warranty, indemnity,
165
+ or other liability obligations and/or rights consistent with this
166
+ License. However, in accepting such obligations, You may act only
167
+ on Your own behalf and on Your sole responsibility, not on behalf
168
+ of any other Contributor, and only if You agree to indemnify,
169
+ defend, and hold each Contributor harmless for any liability
170
+ incurred by, or claims asserted against, such Contributor by reason
171
+ of your accepting any such warranty or additional liability.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
175
+ Copyright 2026 Featuresmith Contributors
176
+
177
+ Licensed under the Apache License, Version 2.0 (the "License");
178
+ you may not use this file except in compliance with the License.
179
+ You may obtain a copy of the License at
180
+
181
+ http://www.apache.org/licenses/LICENSE-2.0
182
+
183
+ Unless required by applicable law or agreed to in writing, software
184
+ distributed under the License is distributed on an "AS IS" BASIS,
185
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
+ See the License for the specific language governing permissions and
187
+ limitations under the License.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: featuresmith-core
3
+ Version: 0.1.0
4
+ Summary: Deterministic tabular data profiling and quality-rule engine.
5
+ Author: Featuresmith contributors
6
+ Maintainer: Featuresmith contributors
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/adityagangwani30/FeatureSmith
9
+ Project-URL: Documentation, https://featuresmith.adityagangwani.me
10
+ Project-URL: Repository, https://github.com/adityagangwani30/FeatureSmith
11
+ Project-URL: Issues, https://github.com/adityagangwani30/FeatureSmith/issues
12
+ Project-URL: Changelog, https://github.com/adityagangwani30/FeatureSmith/blob/main/CHANGELOG.md
13
+ Keywords: data-quality,feature-engineering,profiling,tabular-data
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: openpyxl~=3.1
28
+ Requires-Dist: pandas~=2.2
29
+ Requires-Dist: polars~=1.30
30
+ Dynamic: license-file
31
+
32
+ # featuresmith-core
33
+
34
+ `featuresmith-core` is the public Python SDK and deterministic analysis engine for Featuresmith.
35
+
36
+ It provides:
37
+
38
+ - `featuresmith.load()` for local CSV, Excel, Parquet, pandas, and Polars sources.
39
+ - `featuresmith.profile()` for reproducible tabular profiling.
40
+ - `featuresmith.analyze()` for data quality and leakage rule findings.
41
+ - Typed, serializable result dataclasses and a PEP 561 `py.typed` marker.
42
+
43
+ Install featuresmith-core directly from PyPI:
44
+
45
+ ```bash
46
+ pip install featuresmith-core
47
+ ```
48
+
49
+ For comprehensive guides and API reference, visit the official website:
50
+ <https://featuresmith.adityagangwani.me>
@@ -0,0 +1,19 @@
1
+ # featuresmith-core
2
+
3
+ `featuresmith-core` is the public Python SDK and deterministic analysis engine for Featuresmith.
4
+
5
+ It provides:
6
+
7
+ - `featuresmith.load()` for local CSV, Excel, Parquet, pandas, and Polars sources.
8
+ - `featuresmith.profile()` for reproducible tabular profiling.
9
+ - `featuresmith.analyze()` for data quality and leakage rule findings.
10
+ - Typed, serializable result dataclasses and a PEP 561 `py.typed` marker.
11
+
12
+ Install featuresmith-core directly from PyPI:
13
+
14
+ ```bash
15
+ pip install featuresmith-core
16
+ ```
17
+
18
+ For comprehensive guides and API reference, visit the official website:
19
+ <https://featuresmith.adityagangwani.me>
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "featuresmith-core"
7
+ version = "0.1.0"
8
+ description = "Deterministic tabular data profiling and quality-rule engine."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ authors = [
13
+ { name = "Featuresmith contributors" },
14
+ ]
15
+ maintainers = [
16
+ { name = "Featuresmith contributors" },
17
+ ]
18
+ requires-python = ">=3.11"
19
+ keywords = [
20
+ "data-quality",
21
+ "feature-engineering",
22
+ "profiling",
23
+ "tabular-data",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Developers",
28
+ "Intended Audience :: Science/Research",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3 :: Only",
34
+ "Topic :: Scientific/Engineering :: Information Analysis",
35
+ "Typing :: Typed",
36
+ ]
37
+ dependencies = [
38
+ "openpyxl~=3.1",
39
+ "pandas~=2.2",
40
+ "polars~=1.30",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/adityagangwani30/FeatureSmith"
45
+ Documentation = "https://featuresmith.adityagangwani.me"
46
+ Repository = "https://github.com/adityagangwani30/FeatureSmith"
47
+ Issues = "https://github.com/adityagangwani30/FeatureSmith/issues"
48
+ Changelog = "https://github.com/adityagangwani30/FeatureSmith/blob/main/CHANGELOG.md"
49
+
50
+ [tool.setuptools]
51
+ package-dir = {"" = "src"}
52
+
53
+ [tool.setuptools.package-data]
54
+ featuresmith = ["py.typed"]
55
+
56
+ [tool.setuptools.packages.find]
57
+ where = ["src"]
58
+ include = ["featuresmith*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ """Featuresmith core package."""
2
+
3
+ from featuresmith.api import analyze, load, profile
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["analyze", "load", "profile"]
@@ -0,0 +1,180 @@
1
+ """Public SDK entry module for Featuresmith."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from featuresmith.connectors.registry import default_registry
8
+ from featuresmith.core.dataset import Dataset as Dataset
9
+ from featuresmith.core.exceptions import (
10
+ ConnectorError as ConnectorError,
11
+ )
12
+ from featuresmith.core.exceptions import (
13
+ SourceNotFoundError as SourceNotFoundError,
14
+ )
15
+ from featuresmith.core.exceptions import (
16
+ SourceParseError as SourceParseError,
17
+ )
18
+ from featuresmith.core.exceptions import (
19
+ UnsupportedFormatError as UnsupportedFormatError,
20
+ )
21
+ from featuresmith.core.profile_result import ProfileResult as ProfileResult
22
+ from featuresmith.core.rule_result import RuleResult as RuleResult
23
+ from featuresmith.profiling import profile_dataset
24
+
25
+
26
+ def load(source: object) -> Dataset:
27
+ """Load a supported tabular source into a normalized Dataset.
28
+
29
+ Args:
30
+ source: The data source to load. This can be a string representing a
31
+ local file path (CSV, Excel, Parquet), or an in-memory pandas
32
+ DataFrame or Polars DataFrame.
33
+
34
+ Returns:
35
+ Dataset: A normalized view of the loaded tabular dataset, containing
36
+ the dataframe backend, schema, dtypes, and metadata.
37
+
38
+ Raises:
39
+ ConnectorError: If the source is missing, has an unsupported format,
40
+ is corrupted, or is of an invalid type.
41
+
42
+ Notes:
43
+ For file paths, Featuresmith utilizes Polars for CSV and Parquet formats
44
+ by default, and pandas for Excel formats. In-memory dataframes are
45
+ wrapped without copying the underlying memory.
46
+
47
+ Examples:
48
+ >>> import pandas as pd
49
+ >>> import featuresmith as fs
50
+ >>> df = pd.DataFrame({"a": [1, 2, 3]})
51
+ >>> dataset = fs.load(df)
52
+ >>> dataset.row_count
53
+ 3
54
+ """
55
+ return default_registry().load(source)
56
+
57
+
58
+ def profile(
59
+ source: object,
60
+ *,
61
+ max_correlation_columns: int = 100,
62
+ max_frequency_table_size: int = 1000,
63
+ ) -> ProfileResult:
64
+ """Profile a supported source or Dataset and compute statistical summaries.
65
+
66
+ Args:
67
+ source: The data source to profile. This can be a pre-loaded Dataset
68
+ object, a string representing a local file path (CSV, Excel,
69
+ Parquet), or an in-memory pandas or Polars DataFrame.
70
+ max_correlation_columns: Limit correlation computations to prevent
71
+ combinatorial blowup (default 100).
72
+ max_frequency_table_size: Maximum entries to keep in categorical
73
+ frequency tables (default 1000).
74
+
75
+ Returns:
76
+ ProfileResult: A strongly-typed statistical profile containing dataset
77
+ summaries, column profiles, correlations, and logical types.
78
+
79
+ Raises:
80
+ ConnectorError: If the source is a file path or dataframe that fails to
81
+ load before profiling.
82
+
83
+ Notes:
84
+ This is a deterministic profiling engine. The statistical calculations
85
+ run on the underlying dataframe backend using vectorized Polars or pandas
86
+ APIs. The resulting ProfileResult is frozen and fully serializable.
87
+
88
+ Examples:
89
+ >>> import polars as pl
90
+ >>> import featuresmith as fs
91
+ >>> df = pl.DataFrame({"a": [1.0, 2.0, None]})
92
+ >>> prof = fs.profile(df)
93
+ >>> prof.dataset_summary.column_count
94
+ 1
95
+ >>> prof.column_profiles["a"].missing_count
96
+ 1
97
+ """
98
+ if isinstance(source, Dataset):
99
+ dataset = source
100
+ else:
101
+ dataset = load(source)
102
+ return profile_dataset(
103
+ dataset,
104
+ max_correlation_columns=max_correlation_columns,
105
+ max_frequency_table_size=max_frequency_table_size,
106
+ )
107
+
108
+
109
+ def analyze(
110
+ source: object,
111
+ *,
112
+ target_column: str | None = None,
113
+ enabled_rules: list[str] | None = None,
114
+ rule_config: dict[str, Any] | None = None,
115
+ max_correlation_columns: int = 100,
116
+ max_frequency_table_size: int = 1000,
117
+ ) -> RuleResult:
118
+ """Analyze a tabular source or Dataset, computing profile stats and running rules.
119
+
120
+ Args:
121
+ source: The data source to analyze. This can be a pre-loaded Dataset
122
+ object, a string representing a local file path (CSV, Excel,
123
+ Parquet), or an in-memory pandas or Polars DataFrame.
124
+ target_column: Optional name of the target column in the dataset, used
125
+ specifically for evaluating potential target leakage.
126
+ enabled_rules: Optional list of rule IDs to execute. If not provided,
127
+ the engine runs all rules that are enabled by default.
128
+ rule_config: Optional dictionary of configurations keyed by rule ID.
129
+ For example, `{"quality.missing_value_threshold": {"threshold": 15.0}}`.
130
+ max_correlation_columns: Limit correlation computations during profiling to
131
+ prevent combinatorial blowup (default 100).
132
+ max_frequency_table_size: Maximum entries to keep in categorical
133
+ frequency tables (default 1000).
134
+
135
+ Returns:
136
+ RuleResult: The canonical output of the Rule Engine containing the
137
+ computed ProfileResult, aggregated list of RuleFindings, list of
138
+ executed rule IDs, and execution time metadata.
139
+
140
+ Raises:
141
+ ConnectorError: If the source is a file path or dataframe that fails to
142
+ load before profiling.
143
+
144
+ Notes:
145
+ This function integrates connector loading, profiling, and rule
146
+ evaluation into a single public endpoint. The evaluation of rules is
147
+ deterministic and isolated; a crash in any single rule does not cause
148
+ the function to fail, but is recorded in the failed_rules mapping.
149
+
150
+ Examples:
151
+ >>> import pandas as pd
152
+ >>> import featuresmith as fs
153
+ >>> df = pd.DataFrame({
154
+ ... "x": [1, 2, 3, 4, 5],
155
+ ... "y": [1.0, 2.0, 3.0, 4.0, 5.0],
156
+ ... "target": [0, 1, 0, 1, 0]
157
+ ... })
158
+ >>> result = fs.analyze(df, target_column="target")
159
+ >>> len(result.findings) >= 0
160
+ True
161
+ """
162
+ if isinstance(source, Dataset):
163
+ dataset = source
164
+ else:
165
+ dataset = load(source)
166
+ prof_res = profile(
167
+ dataset,
168
+ max_correlation_columns=max_correlation_columns,
169
+ max_frequency_table_size=max_frequency_table_size,
170
+ )
171
+
172
+ from featuresmith.rules.engine import RuleEngine
173
+
174
+ engine = RuleEngine()
175
+ return engine.run(
176
+ prof_res,
177
+ target_column=target_column,
178
+ enabled_rules=enabled_rules,
179
+ rule_config=rule_config,
180
+ )
@@ -0,0 +1,18 @@
1
+ """Connector package for Featuresmith."""
2
+
3
+ from featuresmith.connectors.base import BaseConnector
4
+ from featuresmith.connectors.csv_connector import CsvConnector
5
+ from featuresmith.connectors.dataframe_connector import DataFrameConnector
6
+ from featuresmith.connectors.excel_connector import ExcelConnector
7
+ from featuresmith.connectors.parquet_connector import ParquetConnector
8
+ from featuresmith.connectors.registry import ConnectorRegistry, default_registry
9
+
10
+ __all__ = [
11
+ "BaseConnector",
12
+ "ConnectorRegistry",
13
+ "CsvConnector",
14
+ "DataFrameConnector",
15
+ "ExcelConnector",
16
+ "ParquetConnector",
17
+ "default_registry",
18
+ ]
@@ -0,0 +1,25 @@
1
+ """Private helpers shared by local-file connectors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ from featuresmith.core.exceptions import SourceNotFoundError, UnsupportedFormatError
8
+
9
+
10
+ def validate_file_source(source: object, suffixes: tuple[str, ...]) -> Path:
11
+ """Return a validated local file path for one of the supplied suffixes."""
12
+ if not isinstance(source, (str, Path)):
13
+ raise UnsupportedFormatError("Expected a local file path.")
14
+
15
+ path = Path(source)
16
+ if path.suffix.lower() not in suffixes:
17
+ formats = ", ".join(suffixes)
18
+ raise UnsupportedFormatError(
19
+ f"Unsupported file format. Expected one of: {formats}."
20
+ )
21
+ if not path.exists():
22
+ raise SourceNotFoundError(f"Source file does not exist: {path}.")
23
+ if not path.is_file():
24
+ raise SourceNotFoundError(f"Source path is not a file: {path}.")
25
+ return path
@@ -0,0 +1,54 @@
1
+ """Base contract for source connectors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from abc import ABC, abstractmethod
6
+
7
+ from featuresmith.core.dataset import Dataset
8
+
9
+
10
+ class BaseConnector(ABC):
11
+ """Abstract base class for all Featuresmith data connectors.
12
+
13
+ Connectors are responsible for loading and normalizing external tabular
14
+ sources (such as files or database connections) or in-memory representations
15
+ into a standardized Dataset object.
16
+ """
17
+
18
+ @abstractmethod
19
+ def can_load(self, source: object) -> bool:
20
+ """Determine whether the connector supports the supplied source.
21
+
22
+ Args:
23
+ source: The input source object (e.g. file path or DataFrame).
24
+
25
+ Returns:
26
+ bool: True if this connector supports loading from the source,
27
+ False otherwise.
28
+ """
29
+
30
+ @abstractmethod
31
+ def validate(self, source: object) -> None:
32
+ """Validate the source structurally or raise a typed connector error.
33
+
34
+ Args:
35
+ source: The input source object to validate.
36
+
37
+ Raises:
38
+ ConnectorError: If validation fails because the source is missing,
39
+ unsupported, or invalid.
40
+ """
41
+
42
+ @abstractmethod
43
+ def load(self, source: object) -> Dataset:
44
+ """Load and normalize a validated source into a Dataset.
45
+
46
+ Args:
47
+ source: The input source object to load.
48
+
49
+ Returns:
50
+ Dataset: The loaded and normalized dataset wrapper.
51
+
52
+ Raises:
53
+ ConnectorError: If loading fails due to parsing or read errors.
54
+ """
@@ -0,0 +1,44 @@
1
+ """CSV connector backed by Polars."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import polars as pl
8
+
9
+ from featuresmith.connectors._paths import validate_file_source
10
+ from featuresmith.connectors.base import BaseConnector
11
+ from featuresmith.core.dataset import Dataset
12
+ from featuresmith.core.exceptions import SourceParseError
13
+
14
+
15
+ class CsvConnector(BaseConnector):
16
+ """Load local CSV files into Polars-backed datasets."""
17
+
18
+ _SUFFIXES = (".csv",)
19
+
20
+ def can_load(self, source: object) -> bool:
21
+ """Return whether the source is a CSV path."""
22
+ return (
23
+ isinstance(source, (str, Path))
24
+ and Path(source).suffix.lower() in self._SUFFIXES
25
+ )
26
+
27
+ def validate(self, source: object) -> None:
28
+ """Validate that the CSV source exists and is a regular file."""
29
+ validate_file_source(source, self._SUFFIXES)
30
+
31
+ def load(self, source: object) -> Dataset:
32
+ """Load a CSV file as a normalized Polars dataset."""
33
+ path = validate_file_source(source, self._SUFFIXES)
34
+ try:
35
+ dataframe = pl.read_csv(path)
36
+ except (OSError, pl.exceptions.PolarsError) as error:
37
+ raise SourceParseError(f"Could not read CSV file '{path}'.") from error
38
+ return Dataset.from_dataframe(
39
+ dataframe,
40
+ backend="polars",
41
+ source=str(path),
42
+ file_size=path.stat().st_size,
43
+ metadata={"format": "csv"},
44
+ )