sanice 1.0.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.
- sanice-1.0.0/LICENSE +201 -0
- sanice-1.0.0/PKG-INFO +458 -0
- sanice-1.0.0/README.md +414 -0
- sanice-1.0.0/core/__init__.py +0 -0
- sanice-1.0.0/core/core.py +620 -0
- sanice-1.0.0/sanice.egg-info/PKG-INFO +458 -0
- sanice-1.0.0/sanice.egg-info/SOURCES.txt +10 -0
- sanice-1.0.0/sanice.egg-info/dependency_links.txt +1 -0
- sanice-1.0.0/sanice.egg-info/requires.txt +18 -0
- sanice-1.0.0/sanice.egg-info/top_level.txt +1 -0
- sanice-1.0.0/setup.cfg +4 -0
- sanice-1.0.0/setup.py +58 -0
sanice-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently 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
|
|
95
|
+
Derivative 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, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
sanice-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sanice
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Biblioteca fluente para Data Science ágil (ETL, AutoML e Plotting).
|
|
5
|
+
Home-page: https://github.com/wSanice/sanice
|
|
6
|
+
Author: wSanice
|
|
7
|
+
Author-email: wansanice@proton.me
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pandas>=2.0.0
|
|
18
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
19
|
+
Requires-Dist: seaborn>=0.12.0
|
|
20
|
+
Requires-Dist: scikit-learn>=1.2.0
|
|
21
|
+
Requires-Dist: joblib>=1.2.0
|
|
22
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
23
|
+
Requires-Dist: pyarrow>=11.0.0
|
|
24
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
25
|
+
Provides-Extra: api
|
|
26
|
+
Requires-Dist: fastapi>=0.95.0; extra == "api"
|
|
27
|
+
Requires-Dist: uvicorn>=0.22.0; extra == "api"
|
|
28
|
+
Requires-Dist: pydantic>=1.10.0; extra == "api"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
Requires-Dist: twine; extra == "dev"
|
|
32
|
+
Requires-Dist: wheel; extra == "dev"
|
|
33
|
+
Dynamic: author
|
|
34
|
+
Dynamic: author-email
|
|
35
|
+
Dynamic: classifier
|
|
36
|
+
Dynamic: description
|
|
37
|
+
Dynamic: description-content-type
|
|
38
|
+
Dynamic: home-page
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
Dynamic: provides-extra
|
|
41
|
+
Dynamic: requires-dist
|
|
42
|
+
Dynamic: requires-python
|
|
43
|
+
Dynamic: summary
|
|
44
|
+
|
|
45
|
+
<div align="center">
|
|
46
|
+
|
|
47
|
+
# sanice
|
|
48
|
+
> **S.A.N.I.C.E.**<br>
|
|
49
|
+
(Sistema Automatizado de Normalização, Inteligência Computacional e Estatística)<br>
|
|
50
|
+
> (System for Automated Normalization, Intelligence, Computation, and Statistics)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+

|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
[🇺🇸 English](#-english) | [🇧🇷 Português](#-português) | [🇨🇳 🇮🇳 Multi-language](#-Multilanguage)
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<p align="center">
|
|
62
|
+
<img src="https://raw.githubusercontent.com/wSanice/sanice/refs/heads/main/assets/sanice.png" alt="Sanice Banner" width="100%"/>
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
<a name="-english"></a>
|
|
68
|
+
## 🇺🇸 English
|
|
69
|
+
|
|
70
|
+
**Sanice** is a fluent Python wrapper designed to accelerate Data Science workflows. It abstracts the complexity of Pandas, Scikit-Learn, and FastAPI into a method-chaining interface, allowing you to focus on business logic rather than syntax.
|
|
71
|
+
|
|
72
|
+
### Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install sanice
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Quick Start
|
|
79
|
+
|
|
80
|
+
**How to turn a dirty CSV into a deployed AI model in minutes.**
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from sanice import Sanice
|
|
84
|
+
|
|
85
|
+
(Sanice("raw_data.csv")
|
|
86
|
+
.fix_columns() # Standardize names to snake_case
|
|
87
|
+
.transform("price", "money") # Cleans money format ("$ 1,000.00" -> 1000.0)
|
|
88
|
+
.drop_nulls() # Removes empty rows
|
|
89
|
+
.create_column("total", "price * qty")
|
|
90
|
+
.handle_outliers("total") # Removes statistical anomalies (IQR)
|
|
91
|
+
.auto_ml( # Trains Random Forest & saves model
|
|
92
|
+
target="sold",
|
|
93
|
+
type="classification",
|
|
94
|
+
save_path="my_model.pkl"
|
|
95
|
+
)
|
|
96
|
+
.serve_api() # Deploys a REST API on localhost:8000
|
|
97
|
+
)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Snippets & Command Reference
|
|
101
|
+
|
|
102
|
+
Here is the complete list of available methods organized by category.
|
|
103
|
+
|
|
104
|
+
#### 1. Cleaning & ETL
|
|
105
|
+
| Command | Description |
|
|
106
|
+
| :--- | :--- |
|
|
107
|
+
| `app.fix_columns()` | Converts all column names to `snake_case`. |
|
|
108
|
+
| `app.transform(col, rule)` | Applies logic: `'money'`, `'digits'`, `'email'`, `'upper'`, `'lower'`. |
|
|
109
|
+
| `app.drop_nulls(strategy, val)` | Strategy: `'drop'` or `'fill'`. |
|
|
110
|
+
| `app.clean_text([cols])` | Strips spaces and converts text to Title Case. |
|
|
111
|
+
| `app.convert_date(col, fmt)` | Converts a string column to datetime objects. |
|
|
112
|
+
|
|
113
|
+
> **Use Cases:**
|
|
114
|
+
> * Standardization of data extracted from legacy systems or unformatted Excel sheets.
|
|
115
|
+
> * Rapid conversion of currency strings to float before calculations.
|
|
116
|
+
> * Preparation of web form data where users input dates in various formats.
|
|
117
|
+
|
|
118
|
+
**Application Example:**
|
|
119
|
+
```python
|
|
120
|
+
# Cleaning a messy HR dataset
|
|
121
|
+
(Sanice("raw_employees.csv")
|
|
122
|
+
.fix_columns() # "Emp Name" -> "emp_name"
|
|
123
|
+
.clean_text(["emp_name", "dept"])
|
|
124
|
+
.transform("salary", "money") # "$ 2,500.00" -> 2500.0
|
|
125
|
+
.convert_date("hire_date") # String -> Datetime
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### 2. Data Manipulation
|
|
130
|
+
| Command | Description |
|
|
131
|
+
| :--- | :--- |
|
|
132
|
+
| `app.create_column(name, logic)` | Creates a column using a string expression or lambda. |
|
|
133
|
+
| `app.filter(query)` | Filters rows using SQL-like syntax (e.g., `"age > 18"`). |
|
|
134
|
+
| `app.sort(col, ascending)` | Sorts the dataset by a specific column. |
|
|
135
|
+
| `app.join(other_df, keys, how)` | Merges two datasets (Left, Right, Inner, Outer). |
|
|
136
|
+
| `app.group([cols], val, op)` | Groups data and calculates sum, mean, or count. |
|
|
137
|
+
| `app.pivot_table(idx, col, val)` | Creates a Pivot Table from the data. |
|
|
138
|
+
|
|
139
|
+
> **Use Cases:**
|
|
140
|
+
> * Feature Engineering (e.g., creating "average ticket" or "days since last purchase").
|
|
141
|
+
> * Merging "Sales" and "Customers" tables to enrich the dataset (VLOOKUP/JOIN).
|
|
142
|
+
> * Customer segmentation for specific marketing campaigns.
|
|
143
|
+
|
|
144
|
+
**Application Example:**
|
|
145
|
+
```python
|
|
146
|
+
# Total Sales Analysis by Region
|
|
147
|
+
(Sanice("sales.csv")
|
|
148
|
+
.filter("status == 'Completed'")
|
|
149
|
+
.create_column("revenue", "price * quantity")
|
|
150
|
+
.group(
|
|
151
|
+
cols=["region", "category"],
|
|
152
|
+
value_col="revenue",
|
|
153
|
+
operation="sum"
|
|
154
|
+
)
|
|
155
|
+
.sort("revenue", ascending=False)
|
|
156
|
+
)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### 3. Analytics & Visualization
|
|
160
|
+
| Command | Description |
|
|
161
|
+
| :--- | :--- |
|
|
162
|
+
| `app.describe()` | Displays mean, std, min, max, and percentiles. |
|
|
163
|
+
| `app.correlation_matrix()` | Plots a heatmap of correlations between numeric vars. |
|
|
164
|
+
| `app.handle_outliers([cols])` | Removes outliers automatically using the IQR method. |
|
|
165
|
+
| `app.plot(type, x, y, hue)` | Plots charts: `'bar'`, `'line'`, `'scatter'`, `'hist'`, `'box'`. |
|
|
166
|
+
|
|
167
|
+
> **Use Cases:**
|
|
168
|
+
> * Exploratory Data Analysis (EDA) to understand data profiles before modeling.
|
|
169
|
+
> * Visual identification of variables that influence the target result (correlation).
|
|
170
|
+
> * Detection and removal of anomalies (e.g., negative ages or exorbitant prices).
|
|
171
|
+
|
|
172
|
+
**Application Example:**
|
|
173
|
+
```python
|
|
174
|
+
# Rapid Dataset Diagnosis
|
|
175
|
+
(Sanice("biological_data.csv")
|
|
176
|
+
.describe()
|
|
177
|
+
.handle_outliers(["age", "glucose"]) # Remove anomalies
|
|
178
|
+
.correlation_matrix() # Shows influence factors
|
|
179
|
+
.plot("scatter", x="age", y="glucose", hue="diagnosis")
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### 4. AI & Machine Learning
|
|
184
|
+
| Command | Description |
|
|
185
|
+
| :--- | :--- |
|
|
186
|
+
| `app.scale(method)` | Normalizes data using `'minmax'` or `'standard'` scaler. |
|
|
187
|
+
| `app.auto_ml(target, type, path)` | AutoML pipeline: encodes, splits, trains, and saves model. |
|
|
188
|
+
| `app.load_ai(path)` | Loads a pre-trained `.pkl` model into memory. |
|
|
189
|
+
| `app.predict(output_col)` | Generates predictions using the loaded model. |
|
|
190
|
+
|
|
191
|
+
> **Use Cases:**
|
|
192
|
+
> * Quick creation of baselines to validate business hypotheses.
|
|
193
|
+
> * Churn Prediction (customers likely to cancel) or Credit Scoring.
|
|
194
|
+
> * Demand forecasting based on sales history (Regression).
|
|
195
|
+
|
|
196
|
+
**Application Example:**
|
|
197
|
+
```python
|
|
198
|
+
# Training and using a Churn prediction model
|
|
199
|
+
(Sanice("telecom_churn.csv")
|
|
200
|
+
.scale("minmax")
|
|
201
|
+
.auto_ml(target="churn", type="classification", save_path="my_ai.pkl")
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
# ... In another script, loading and predicting:
|
|
205
|
+
(Sanice("new_customers.csv")
|
|
206
|
+
.load_ai("my_ai.pkl")
|
|
207
|
+
.predict(output_col="churn_prob")
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### 5. Export & Deployment
|
|
212
|
+
| Command | Description |
|
|
213
|
+
| :--- | :--- |
|
|
214
|
+
| `app.save(path)` | Exports data to `.csv`, `.xlsx`, or `.parquet`. |
|
|
215
|
+
| `app.export_sql(url, table)` | Pushes the dataframe to a SQL database. |
|
|
216
|
+
| `app.serve_api()` | Starts a FastAPI server to serve predictions. |
|
|
217
|
+
|
|
218
|
+
> **Use Cases:**
|
|
219
|
+
> * Exporting treated data (Bronze -> Silver) to BI tools like Power BI or Tableau.
|
|
220
|
+
> * Instant creation of AI microservices for Mobile or Web App integration.
|
|
221
|
+
> * Persistence of clean data into relational databases (PostgreSQL/MySQL).
|
|
222
|
+
|
|
223
|
+
**Application Example:**
|
|
224
|
+
```python
|
|
225
|
+
# Final Pipeline: Clean -> Save Parquet -> Deploy API
|
|
226
|
+
(Sanice("raw_data.csv")
|
|
227
|
+
.fix_columns()
|
|
228
|
+
.auto_ml("target", "regression", "model.pkl")
|
|
229
|
+
.save("clean_data.parquet") # Data Backup
|
|
230
|
+
.serve_api() # API Online at http://localhost:8000
|
|
231
|
+
)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### License
|
|
235
|
+
|
|
236
|
+
This project is licensed under the Apache License, Version 2.0. See the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.
|
|
237
|
+
|
|
238
|
+
<br>
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
<a name="-português"></a>
|
|
243
|
+
## 🇧🇷 Português
|
|
244
|
+
|
|
245
|
+
**Sanice** é um wrapper Python fluido projetado para acelerar fluxos de trabalho de Data Science. Ele abstrai a complexidade do Pandas, Scikit-Learn e FastAPI em uma interface de encadeamento de métodos (method-chaining), permitindo que você foque na lógica de negócios em vez da sintaxe.
|
|
246
|
+
|
|
247
|
+
### Instalação
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
pip install sanice
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Início Rápido
|
|
254
|
+
|
|
255
|
+
**Como transformar um CSV sujo em um modelo de IA em produção em minutos.**
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from sanice import Sanice
|
|
259
|
+
|
|
260
|
+
(Sanice("raw_data.csv")
|
|
261
|
+
.corrigir_colunas() # Padroniza nomes para snake_case
|
|
262
|
+
.transformar("price", "dinheiro") # Limpa formato monetário ("R$ 1.000,00" -> 1000.0)
|
|
263
|
+
.remover_nulos() # Remove linhas vazias
|
|
264
|
+
.criar_coluna("total", "price * qty")
|
|
265
|
+
.tratar_outliers("total") # Remove anomalias estatísticas (IQR)
|
|
266
|
+
.auto_ml( # Treina Random Forest & salva modelo
|
|
267
|
+
alvo="sold",
|
|
268
|
+
tipo="classificacao",
|
|
269
|
+
salvar_modelo="my_model.pkl"
|
|
270
|
+
)
|
|
271
|
+
.servir_api() # Sobe uma API REST em localhost:8000
|
|
272
|
+
)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Snippets e Referência de Comandos
|
|
276
|
+
|
|
277
|
+
Aqui está a lista completa de métodos disponíveis organizados por categoria.
|
|
278
|
+
|
|
279
|
+
#### 1. Limpeza e ETL
|
|
280
|
+
| Comando | Descrição |
|
|
281
|
+
| :--- | :--- |
|
|
282
|
+
| `app.corrigir_colunas()` | Converte todos os nomes de colunas para `snake_case`. |
|
|
283
|
+
| `app.transformar(col, rule)` | Aplica lógica: `'dinheiro'`, `'numeros'`, `'email'`, `'upper'`, `'lower'`. |
|
|
284
|
+
| `app.remover_nulos(strategy, val)` | Estratégia: `'apagar'` (drop) ou `'preencher'` (fill). |
|
|
285
|
+
| `app.limpar_texto([cols])` | Remove espaços extras e converte texto para Title Case. |
|
|
286
|
+
| `app.converter_data(col, fmt)` | Converte uma coluna de string para objetos datetime. |
|
|
287
|
+
|
|
288
|
+
> **Casos de Uso:**
|
|
289
|
+
> * Padronização de dados extraídos de sistemas legados ou planilhas Excel desformatadas.
|
|
290
|
+
> * Conversão rápida de colunas de moeda brasileira (R$) para float antes de cálculos.
|
|
291
|
+
> * Preparação de dados de formulários web onde usuários inserem datas em formatos variados.
|
|
292
|
+
|
|
293
|
+
**Exemplo de Aplicação:**
|
|
294
|
+
```python
|
|
295
|
+
# Limpeza de uma base de RH desorganizada
|
|
296
|
+
(Sanice("funcionarios_bruto.csv")
|
|
297
|
+
.corrigir_colunas() # "Nome Func" -> "nome_func"
|
|
298
|
+
.limpar_texto(["nome_func", "setor"])
|
|
299
|
+
.transformar("salario", "dinheiro") # "R$ 2.500,00" -> 2500.0
|
|
300
|
+
.converter_data("data_admissao") # String -> Datetime
|
|
301
|
+
)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### 2. Manipulação de Dados
|
|
305
|
+
| Comando | Descrição |
|
|
306
|
+
| :--- | :--- |
|
|
307
|
+
| `app.criar_coluna(name, logic)` | Cria uma coluna usando expressão string ou lambda. |
|
|
308
|
+
| `app.filtrar(query)` | Filtra linhas usando sintaxe estilo SQL (ex: `"age > 18"`). |
|
|
309
|
+
| `app.ordenar(col, ascending)` | Ordena o dataset por uma coluna específica. |
|
|
310
|
+
| `app.unir(other_df, keys, how)` | Une dois datasets (Left, Right, Inner, Outer). |
|
|
311
|
+
| `app.agrupar([cols], val, op)` | Agrupa dados e calcula soma, média ou contagem. |
|
|
312
|
+
| `app.tabela_dinamica(idx, col, val)` | Cria uma Tabela Dinâmica a partir dos dados. |
|
|
313
|
+
|
|
314
|
+
> **Casos de Uso:**
|
|
315
|
+
> * Criação de Features (Feature Engineering) como "ticket médio" ou "dias desde a última compra".
|
|
316
|
+
> * Unificação de tabelas de "Vendas" e "Clientes" para enriquecer o dataset (VLOOKUP/JOIN).
|
|
317
|
+
> * Segmentação de base de clientes para campanhas de marketing específicas.
|
|
318
|
+
|
|
319
|
+
**Exemplo de Aplicação:**
|
|
320
|
+
```python
|
|
321
|
+
# Análise de Vendas Totais por Região
|
|
322
|
+
(Sanice("vendas.csv")
|
|
323
|
+
.filtrar("status == 'Concluido'")
|
|
324
|
+
.criar_coluna("faturamento", "preco * quantidade")
|
|
325
|
+
.agrupar(
|
|
326
|
+
cols=["regiao", "categoria"],
|
|
327
|
+
value_col="faturamento",
|
|
328
|
+
operacao="soma"
|
|
329
|
+
)
|
|
330
|
+
.ordenar("faturamento", ascendente=False)
|
|
331
|
+
)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### 3. Análise e Visualização
|
|
335
|
+
| Comando | Descrição |
|
|
336
|
+
| :--- | :--- |
|
|
337
|
+
| `app.resumo_estatistico()` | Exibe média, desvio padrão, min, max e percentis. |
|
|
338
|
+
| `app.matriz_correlacao()` | Plota um mapa de calor das correlações entre vars numéricas. |
|
|
339
|
+
| `app.tratar_outliers([cols])` | Remove outliers automaticamente usando o método IQR. |
|
|
340
|
+
| `app.plotar(type, x, y, hue)` | Plota gráficos: `'bar'`, `'line'`, `'scatter'`, `'hist'`, `'box'`. |
|
|
341
|
+
|
|
342
|
+
> **Casos de Uso:**
|
|
343
|
+
> * Análise Exploratória de Dados (EDA) para entender o perfil dos dados antes da modelagem.
|
|
344
|
+
> * Identificação visual de variáveis que influenciam o resultado desejado (correlação).
|
|
345
|
+
> * Detecção e remoção de anomalias (ex: idades negativas ou preços exorbitantes).
|
|
346
|
+
|
|
347
|
+
**Exemplo de Aplicação:**
|
|
348
|
+
```python
|
|
349
|
+
# Diagnóstico rápido de dataset
|
|
350
|
+
(Sanice("dados_biologicos.csv")
|
|
351
|
+
.resumo_estatistico()
|
|
352
|
+
.tratar_outliers(["idade", "glicose"]) # Remove anomalias
|
|
353
|
+
.matriz_correlacao() # Mostra o que influencia o que
|
|
354
|
+
.plotar("scatter", x="idade", y="glicose", hue="diagnostico")
|
|
355
|
+
)
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
#### 4. IA e Machine Learning
|
|
359
|
+
| Comando | Descrição |
|
|
360
|
+
| :--- | :--- |
|
|
361
|
+
| `app.escalonar(method)` | Normaliza dados usando escalonador `'minmax'` ou `'standard'`. |
|
|
362
|
+
| `app.auto_ml(target, type, path)` | Pipeline AutoML: encode, split, treino e salvamento do modelo. |
|
|
363
|
+
| `app.carregar_ia(path)` | Carrega um modelo `.pkl` pré-treinado na memória. |
|
|
364
|
+
| `app.prever(output_col)` | Gera previsões usando o modelo carregado. |
|
|
365
|
+
|
|
366
|
+
> **Casos de Uso:**
|
|
367
|
+
> * Criação rápida de *baselines* (modelos de referência) para validar hipóteses.
|
|
368
|
+
> * Previsão de Churn (clientes que vão cancelar) ou Score de Crédito.
|
|
369
|
+
> * Previsão de demanda de estoque baseada em histórico de vendas.
|
|
370
|
+
|
|
371
|
+
**Exemplo de Aplicação:**
|
|
372
|
+
```python
|
|
373
|
+
# Treinando e usando um modelo de previsão de Churn
|
|
374
|
+
(Sanice("telecom_churn.csv")
|
|
375
|
+
.escalonar("minmax")
|
|
376
|
+
.auto_ml(alvo="churn", tipo="classificacao", salvar_modelo="meu_ia.pkl")
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
# ... Em outro script, carregando e prevendo:
|
|
380
|
+
(Sanice("novos_clientes.csv")
|
|
381
|
+
.carregar_ia("meu_ia.pkl")
|
|
382
|
+
.prever(output_col="probabilidade_churn")
|
|
383
|
+
)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### 5. Exportação e Deploy
|
|
387
|
+
| Comando | Descrição |
|
|
388
|
+
| :--- | :--- |
|
|
389
|
+
| `app.salvar(path)` | Exporta dados para `.csv`, `.xlsx` ou `.parquet`. |
|
|
390
|
+
| `app.exportar_sql(url, table)` | Envia o dataframe para um banco de dados SQL. |
|
|
391
|
+
| `app.servir_api()` | Inicia um servidor FastAPI para servir previsões. |
|
|
392
|
+
|
|
393
|
+
> **Casos de Uso:**
|
|
394
|
+
> * Exportação de dados tratados para ferramentas de BI como Power BI.
|
|
395
|
+
> * Criação instantânea de microserviços de IA para integração com Apps.
|
|
396
|
+
> * Persistência de dados limpos em bancos relacionais (PostgreSQL/MySQL).
|
|
397
|
+
|
|
398
|
+
**Exemplo de Aplicação:**
|
|
399
|
+
```python
|
|
400
|
+
# Pipeline final: Limpa -> Salva Parquet -> Vira API
|
|
401
|
+
(Sanice("dados_brutos.csv")
|
|
402
|
+
.corrigir_colunas()
|
|
403
|
+
.auto_ml("target", "regressao", "modelo.pkl")
|
|
404
|
+
.salvar("dados_limpos.parquet") # Backup dos dados
|
|
405
|
+
.servir_api() # API Online em http://localhost:8000
|
|
406
|
+
)
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
<a name="-Multilanguage"></a>
|
|
411
|
+
### Multi-language Support / Suporte Multilíngue
|
|
412
|
+
|
|
413
|
+
Sanice is designed for global people. You can call methods in English, Portuguese, Chinese, or Hindi. <br>
|
|
414
|
+
*O Sanice foi projetado para equipes globais. Você pode chamar métodos em Inglês, Português, Chinês ou Hindi.*
|
|
415
|
+
|
|
416
|
+
<details>
|
|
417
|
+
<summary><b>CLICK HERE to see the full Command Translation Table / CLIQUE AQUI para ver a Tabela de Tradução</b></summary>
|
|
418
|
+
<br>
|
|
419
|
+
|
|
420
|
+
| 🇧🇷 PT-BR (Original) | 🇺🇸 English | 🇨🇳 Chinese (中文) | 🇮🇳 Hindi (Hinglish) |
|
|
421
|
+
| :--- | :--- | :--- | :--- |
|
|
422
|
+
| `corrigir_colunas` | `fix_columns` | `修正列名` | `column_sudhare` |
|
|
423
|
+
| `limpar_texto` | `clean_text` | `清洗文本` | `text_safai` |
|
|
424
|
+
| `remover_nulos` | `remove_nulls` | `移除空值` | `null_hataye` |
|
|
425
|
+
| `converter_data` | `convert_date` | `转换日期` | `date_badlo` |
|
|
426
|
+
| `criar_coluna` | `create_column` | `创建列` | `column_banaye` |
|
|
427
|
+
| `filtrar` | `filter_data` | `过滤数据` | `filter_kare` |
|
|
428
|
+
| `ordenar` | `sort_data` | `排序数据` | `sort_kare` |
|
|
429
|
+
| `unir` | `join_data` | `合并数据` | `jode` |
|
|
430
|
+
| `plotar` | `plot_chart` | `绘制图表` | `graph_banaye` |
|
|
431
|
+
| `resumo_estatistico` | `stats_summary` | `统计摘要` | `stats_dekhe` |
|
|
432
|
+
| `salvar` | `save_file` | `保存文件` | `save_kare` |
|
|
433
|
+
| `auto_ml` | `train_automl` | `自动训练` | `automl_kare` |
|
|
434
|
+
| `carregar_ia` | `load_ai` | `加载模型` | `ai_load_kare` |
|
|
435
|
+
| `prever` | `predict` | `预测` | `bhavishya_bataye` |
|
|
436
|
+
| `ver` | `view` | `查看` | `dekhe` |
|
|
437
|
+
| `ajuda` | `help` | `帮助` | `madad` |
|
|
438
|
+
| `agrupar` | `group_by` | `分组` | `samuh_banaye` |
|
|
439
|
+
| `tabela_dinamica` | `pivot_table` | `透视表` | `pivot_table` |
|
|
440
|
+
| `exportar_sql` | `export_sql` | `导出SQL` | `sql_export` |
|
|
441
|
+
| `matriz_correlacao` | `correlation_matrix` | `相关矩阵` | `sambandh_matrix` |
|
|
442
|
+
| `tratar_outliers` | `handle_outliers` | `处理异常值` | `outliers_hataye` |
|
|
443
|
+
| `escalonar` | `scale_data` | `数据缩放` | `scale_kare` |
|
|
444
|
+
| `servir_api` | `serve_api` | `启动API` | `api_chalu_kare` |
|
|
445
|
+
| `transformar` | `transform` | `数据转换` | `badlav_kare` |
|
|
446
|
+
|
|
447
|
+
</details>
|
|
448
|
+
|
|
449
|
+
### Licença
|
|
450
|
+
|
|
451
|
+
Este projeto está licenciado sob a Apache License, Version 2.0. Consulte a [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) para obter detalhes.
|
|
452
|
+
|
|
453
|
+
<div align="right">
|
|
454
|
+
<a href="#sanice">⬆️ Back to Top</a>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
Desenvolvido por **wSanice**.
|