mloda 0.4.1__py3-none-any.whl → 0.4.2__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.
- mloda/core/abstract_plugins/components/{feature_group_version.py → base_feature_group_version.py} +1 -1
- mloda/core/abstract_plugins/compute_framework.py +1 -1
- mloda/core/abstract_plugins/feature_group.py +3 -3
- mloda/core/api/feature_config/__init__.py +15 -0
- {mloda_plugins/config/feature → mloda/core/api/feature_config}/loader.py +19 -62
- {mloda_plugins/config/feature → mloda/core/api/feature_config}/models.py +2 -2
- {mloda_plugins/config/feature → mloda/core/api/feature_config}/parser.py +1 -1
- mloda/core/api/request.py +6 -1
- mloda/provider/__init__.py +2 -2
- mloda/user/__init__.py +10 -2
- mloda-0.4.2.dist-info/METADATA +314 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/RECORD +79 -81
- mloda_plugins/compute_framework/base_implementations/duckdb/duckdb_framework.py +1 -1
- mloda_plugins/compute_framework/base_implementations/iceberg/iceberg_framework.py +1 -1
- mloda_plugins/compute_framework/base_implementations/pandas/dataframe.py +1 -1
- mloda_plugins/compute_framework/base_implementations/polars/dataframe.py +1 -1
- mloda_plugins/compute_framework/base_implementations/pyarrow/table.py +1 -1
- mloda_plugins/compute_framework/base_implementations/python_dict/python_dict_framework.py +1 -1
- mloda_plugins/compute_framework/base_implementations/spark/spark_framework.py +1 -1
- mloda_plugins/feature_group/experimental/aggregated_feature_group/base.py +2 -2
- mloda_plugins/feature_group/experimental/aggregated_feature_group/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/aggregated_feature_group/polars_lazy.py +1 -1
- mloda_plugins/feature_group/experimental/aggregated_feature_group/pyarrow.py +1 -1
- mloda_plugins/feature_group/experimental/clustering/base.py +2 -2
- mloda_plugins/feature_group/experimental/clustering/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/data_quality/missing_value/base.py +5 -5
- mloda_plugins/feature_group/experimental/data_quality/missing_value/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/data_quality/missing_value/pyarrow.py +1 -1
- mloda_plugins/feature_group/experimental/data_quality/missing_value/python_dict.py +1 -1
- mloda_plugins/feature_group/experimental/dimensionality_reduction/base.py +3 -3
- mloda_plugins/feature_group/experimental/dimensionality_reduction/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/dynamic_feature_group_factory/dynamic_feature_group_factory.py +4 -4
- mloda_plugins/feature_group/experimental/forecasting/base.py +3 -3
- mloda_plugins/feature_group/experimental/forecasting/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/geo_distance/base.py +3 -3
- mloda_plugins/feature_group/experimental/geo_distance/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/llm/cli.py +1 -1
- mloda_plugins/feature_group/experimental/llm/cli_features/refactor_git_cached.py +4 -4
- mloda_plugins/feature_group/experimental/llm/installed_packages_feature_group.py +5 -5
- mloda_plugins/feature_group/experimental/llm/list_directory_feature_group.py +2 -2
- mloda_plugins/feature_group/experimental/llm/llm_api/claude.py +11 -11
- mloda_plugins/feature_group/experimental/llm/llm_api/gemini.py +10 -10
- mloda_plugins/feature_group/experimental/llm/llm_api/llm_base_request.py +2 -2
- mloda_plugins/feature_group/experimental/llm/llm_api/openai.py +11 -11
- mloda_plugins/feature_group/experimental/llm/llm_api/request_loop.py +2 -2
- mloda_plugins/feature_group/experimental/llm/llm_file_selector.py +9 -9
- mloda_plugins/feature_group/experimental/node_centrality/base.py +2 -2
- mloda_plugins/feature_group/experimental/node_centrality/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/sklearn/encoding/base.py +8 -8
- mloda_plugins/feature_group/experimental/sklearn/encoding/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/sklearn/pipeline/base.py +3 -3
- mloda_plugins/feature_group/experimental/sklearn/pipeline/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/sklearn/scaling/base.py +2 -2
- mloda_plugins/feature_group/experimental/sklearn/scaling/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/source_input_feature.py +3 -3
- mloda_plugins/feature_group/experimental/text_cleaning/base.py +2 -2
- mloda_plugins/feature_group/experimental/text_cleaning/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/text_cleaning/python_dict.py +1 -1
- mloda_plugins/feature_group/experimental/time_window/base.py +3 -3
- mloda_plugins/feature_group/experimental/time_window/pandas.py +1 -1
- mloda_plugins/feature_group/experimental/time_window/pyarrow.py +1 -1
- mloda_plugins/feature_group/input_data/api_data/api_data.py +27 -27
- mloda_plugins/feature_group/input_data/read_context_files.py +3 -3
- mloda_plugins/feature_group/input_data/read_db.py +1 -1
- mloda_plugins/feature_group/input_data/read_db_feature.py +1 -1
- mloda_plugins/feature_group/input_data/read_dbs/sqlite.py +4 -4
- mloda_plugins/feature_group/input_data/read_file.py +1 -1
- mloda_plugins/feature_group/input_data/read_file_feature.py +1 -1
- mloda_plugins/feature_group/input_data/read_files/csv.py +4 -4
- mloda_plugins/feature_group/input_data/read_files/feather.py +4 -4
- mloda_plugins/feature_group/input_data/read_files/json.py +4 -4
- mloda_plugins/feature_group/input_data/read_files/orc.py +4 -4
- mloda_plugins/feature_group/input_data/read_files/parquet.py +4 -4
- mloda_plugins/feature_group/input_data/read_files/text_file_reader.py +4 -4
- mloda/__init__.py +0 -17
- mloda-0.4.1.dist-info/METADATA +0 -384
- mloda_plugins/config/__init__.py +0 -1
- mloda_plugins/config/feature/__init__.py +0 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/WHEEL +0 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/entry_points.txt +0 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/licenses/LICENSE.TXT +0 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/licenses/NOTICE.md +0 -0
- {mloda-0.4.1.dist-info → mloda-0.4.2.dist-info}/top_level.txt +0 -0
mloda-0.4.1.dist-info/METADATA
DELETED
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mloda
|
|
3
|
-
Version: 0.4.1
|
|
4
|
-
Summary: Make data, feature and context engineering shareable
|
|
5
|
-
Author-email: Tom Kaltofen <info@mloda.ai>
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Project-URL: Bug Tracker, https://github.com/mloda-ai/mloda/issues
|
|
8
|
-
Project-URL: Documentation, https://mloda-ai.github.io/mloda/
|
|
9
|
-
Project-URL: Source Code, https://github.com/mloda-ai/mloda
|
|
10
|
-
Project-URL: PyPI, https://pypi.org/project/mloda/
|
|
11
|
-
Project-URL: Homepage, https://mloda.ai
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Requires-Python: <3.14,>=3.8
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE.TXT
|
|
16
|
-
License-File: NOTICE.md
|
|
17
|
-
Requires-Dist: pyarrow
|
|
18
|
-
Dynamic: license-file
|
|
19
|
-
|
|
20
|
-
# mloda: Make data, feature and context engineering shareable
|
|
21
|
-
|
|
22
|
-
[](https://mloda.ai)
|
|
23
|
-
[](https://mloda-ai.github.io/mloda/)
|
|
24
|
-
[](https://badge.fury.io/py/mloda)
|
|
25
|
-
[](https://github.com/mloda-ai/mloda/blob/main/LICENSE.TXT)
|
|
26
|
-
[](https://tox.readthedocs.io/)
|
|
27
|
-
[](http://mypy-lang.org/)
|
|
28
|
-
[](https://github.com/astral-sh/ruff)
|
|
29
|
-
|
|
30
|
-
> **⚠️ Early Version Notice**: mloda is in active development. Some features described below are still being implemented. We're actively seeking feedback to shape the future of the framework. [Share your thoughts!](https://github.com/mloda-ai/mloda/issues/)
|
|
31
|
-
|
|
32
|
-
## 🍳 Think of mloda Like Cooking Recipes
|
|
33
|
-
|
|
34
|
-
**Traditional Data Pipelines** = Making everything from scratch
|
|
35
|
-
- Want pasta? Make noodles, sauce, cheese from raw ingredients
|
|
36
|
-
- Want pizza? Start over - make dough, sauce, cheese again
|
|
37
|
-
- Want lasagna? Repeat everything once more
|
|
38
|
-
- Can't share recipes easily - they're mixed with your kitchen setup
|
|
39
|
-
|
|
40
|
-
**mloda** = Using recipe components
|
|
41
|
-
- Create reusable recipes: "tomato sauce", "pasta dough", "cheese blend"
|
|
42
|
-
- Use same "tomato sauce" for pasta, pizza, lasagna
|
|
43
|
-
- Switch kitchens (home → restaurant → food truck) - same recipes work
|
|
44
|
-
- Share your "tomato sauce" recipe with friends - they don't need your whole kitchen
|
|
45
|
-
|
|
46
|
-
**Result**: Instead of rebuilding the same thing 10 times, build once and reuse everywhere!
|
|
47
|
-
|
|
48
|
-
### Installation
|
|
49
|
-
```bash
|
|
50
|
-
pip install mloda
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 1. The Core API Call - Your Starting Point
|
|
54
|
-
|
|
55
|
-
**Complete Working Example with DataCreator**
|
|
56
|
-
|
|
57
|
-
```python
|
|
58
|
-
# Step 1: Create a sample data source using DataCreator
|
|
59
|
-
from mloda.provider import FeatureGroup, DataCreator, FeatureSet, BaseInputData
|
|
60
|
-
from typing import Any, Optional
|
|
61
|
-
import pandas as pd
|
|
62
|
-
|
|
63
|
-
class SampleData(FeatureGroup):
|
|
64
|
-
@classmethod
|
|
65
|
-
def input_data(cls) -> Optional[BaseInputData]:
|
|
66
|
-
return DataCreator({"customer_id", "age", "income"})
|
|
67
|
-
|
|
68
|
-
@classmethod
|
|
69
|
-
def calculate_feature(cls, data: Any, features: FeatureSet) -> Any:
|
|
70
|
-
return pd.DataFrame({
|
|
71
|
-
'customer_id': ['C001', 'C002', 'C003', 'C004', 'C005'],
|
|
72
|
-
'age': [25, 30, 35, None, 45],
|
|
73
|
-
'income': [50000, 75000, None, 60000, 85000]
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
# Step 2: Load mloda plugins and run pipeline
|
|
77
|
-
from mloda.user import PluginLoader
|
|
78
|
-
import mloda
|
|
79
|
-
|
|
80
|
-
PluginLoader.all()
|
|
81
|
-
|
|
82
|
-
result = mloda.run_all(
|
|
83
|
-
features=[
|
|
84
|
-
"customer_id", # Original column
|
|
85
|
-
"age", # Original column
|
|
86
|
-
"income__standard_scaled" # Transform: scale income to mean=0, std=1
|
|
87
|
-
],
|
|
88
|
-
compute_frameworks=["PandasDataFrame"]
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
# Step 3: Get your processed data
|
|
92
|
-
data = result[0]
|
|
93
|
-
print(data.head())
|
|
94
|
-
# Output: DataFrame with customer_id, age, and scaled income
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**What just happened?**
|
|
98
|
-
1. **SampleData class** - Created a data source using DataCreator (generates data in-memory)
|
|
99
|
-
2. **PluginLoader.all()** - Loaded all available transformations (scaling, encoding, imputation, etc.)
|
|
100
|
-
3. **mloda.run_all()** - Executed the feature pipeline:
|
|
101
|
-
- Got data from `SampleData`
|
|
102
|
-
- Extracted `customer_id` and `age` as-is
|
|
103
|
-
- Applied StandardScaler to `income` → `income__standard_scaled`
|
|
104
|
-
4. **result[0]** - Retrieved the processed pandas DataFrame
|
|
105
|
-
|
|
106
|
-
> **Key Insight**: The syntax `income__standard_scaled` is mloda's **feature chaining**. Behind the scenes, mloda creates a chain of **feature group** objects (`SourceFeatureGroup` → `StandardScalingFeatureGroup`), automatically resolving dependencies. See [Section 2](#2-understanding-feature-chaining-transformations) for full explanation of chaining syntax and [Section 4](#4-advanced-feature-objects-for-complex-configurations) to learn about the underlying feature group architecture.
|
|
107
|
-
|
|
108
|
-
### 2. Understanding Feature Chaining (Transformations)
|
|
109
|
-
|
|
110
|
-
**The Power of Double Underscore `__` Syntax**
|
|
111
|
-
|
|
112
|
-
As mentioned in Section 1, feature chaining (like `income__standard_scaled`) is syntactic sugar that mloda converts into a chain of **feature group objects**. Each transformation (`standard_scaled`, `mean_imputed`, etc.) corresponds to a specific feature group class.
|
|
113
|
-
|
|
114
|
-
mloda's chaining syntax lets you compose transformations using `__` as a separator:
|
|
115
|
-
|
|
116
|
-
```python
|
|
117
|
-
# Pattern examples (these show the syntax):
|
|
118
|
-
# "income__standard_scaled" # Scale income column
|
|
119
|
-
# "age__mean_imputed" # Fill missing age values with mean
|
|
120
|
-
# "category__onehot_encoded" # One-hot encode category column
|
|
121
|
-
#
|
|
122
|
-
# You can chain transformations!
|
|
123
|
-
# Pattern: {source}__{transform1}__{transform2}
|
|
124
|
-
# "income__mean_imputed__standard_scaled" # First impute, then scale
|
|
125
|
-
|
|
126
|
-
# Real working example:
|
|
127
|
-
_ = ["income__standard_scaled", "age__mean_imputed"] # Valid feature names
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**Available Transformations:**
|
|
131
|
-
|
|
132
|
-
| Transformation | Purpose | Example |
|
|
133
|
-
|---------------|---------|---------|
|
|
134
|
-
| `__standard_scaled` | StandardScaler (mean=0, std=1) | `income__standard_scaled` |
|
|
135
|
-
| `__minmax_scaled` | MinMaxScaler (range [0,1]) | `age__minmax_scaled` |
|
|
136
|
-
| `__robust_scaled` | RobustScaler (median-based, handles outliers) | `price__robust_scaled` |
|
|
137
|
-
| `__mean_imputed` | Fill missing values with mean | `salary__mean_imputed` |
|
|
138
|
-
| `__median_imputed` | Fill missing values with median | `age__median_imputed` |
|
|
139
|
-
| `__mode_imputed` | Fill missing values with mode | `category__mode_imputed` |
|
|
140
|
-
| `__onehot_encoded` | One-hot encoding | `state__onehot_encoded` |
|
|
141
|
-
| `__label_encoded` | Label encoding | `priority__label_encoded` |
|
|
142
|
-
|
|
143
|
-
> **Key Insight**: Transformations are read left-to-right. `income__mean_imputed__standard_scaled` means: take `income` → apply mean imputation → apply standard scaling.
|
|
144
|
-
|
|
145
|
-
**When You Need More Control**
|
|
146
|
-
|
|
147
|
-
Most of the time, simple string syntax is enough:
|
|
148
|
-
```python
|
|
149
|
-
# Example feature list (simple strings)
|
|
150
|
-
example_features = ["customer_id", "income__standard_scaled", "region__onehot_encoded"]
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
But for advanced configurations, you can explicitly create `Feature` objects with custom options (covered in Section 3).
|
|
154
|
-
|
|
155
|
-
### 3. Advanced: Feature Objects for Complex Configurations
|
|
156
|
-
|
|
157
|
-
**Understanding the Feature Group Architecture**
|
|
158
|
-
|
|
159
|
-
Behind the scenes, chaining like `income__standard_scaled` creates feature group objects:
|
|
160
|
-
|
|
161
|
-
```python
|
|
162
|
-
# When you write this string:
|
|
163
|
-
"income__standard_scaled"
|
|
164
|
-
|
|
165
|
-
# mloda creates this chain of feature groups:
|
|
166
|
-
# StandardScalingFeatureGroup (reads from) → IncomeSourceFeatureGroup
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
**Explicit Feature Objects**
|
|
170
|
-
|
|
171
|
-
For truly custom configurations, you can use `Feature` objects:
|
|
172
|
-
|
|
173
|
-
```python
|
|
174
|
-
# Example (for custom feature configurations):
|
|
175
|
-
# from mloda import Feature, Options
|
|
176
|
-
#
|
|
177
|
-
# features = [
|
|
178
|
-
# "customer_id", # Simple string
|
|
179
|
-
# Feature(
|
|
180
|
-
# "custom_feature",
|
|
181
|
-
# options=Options({
|
|
182
|
-
# "custom_param": "value",
|
|
183
|
-
# "in_features": "source_column",
|
|
184
|
-
# })
|
|
185
|
-
# ),
|
|
186
|
-
# ]
|
|
187
|
-
#
|
|
188
|
-
# result = mloda.run_all(
|
|
189
|
-
# features=features,
|
|
190
|
-
# compute_frameworks=["PandasDataFrame"]
|
|
191
|
-
# )
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
> **Deep Dive**: Each transformation type (`standard_scaled__`, `mean_imputed__`, etc.) maps to a feature group class in `mloda_plugins/feature_group/`. For example, `standard_scaled__` uses `ScalingFeatureGroup`. When you chain transformations, mloda builds a dependency graph of these feature groups and executes them in the correct order. This architecture makes mloda extensible - you can create custom feature groups for your own transformations!
|
|
195
|
-
|
|
196
|
-
### 4. Data Access - Where Your Data Comes From
|
|
197
|
-
|
|
198
|
-
**Three Ways to Provide Data**
|
|
199
|
-
|
|
200
|
-
mloda supports multiple data access patterns depending on your use case:
|
|
201
|
-
|
|
202
|
-
**1. DataCreator** - For testing and demos (used in our examples)
|
|
203
|
-
```python
|
|
204
|
-
# Perfect for creating sample/test data in-memory
|
|
205
|
-
# See Section 1 for the SampleData class definition using DataCreator:
|
|
206
|
-
#
|
|
207
|
-
# class SampleData(FeatureGroup):
|
|
208
|
-
# @classmethod
|
|
209
|
-
# def input_data(cls) -> Optional[BaseInputData]:
|
|
210
|
-
# return DataCreator({"customer_id", "age", "income"})
|
|
211
|
-
#
|
|
212
|
-
# @classmethod
|
|
213
|
-
# def calculate_feature(cls, data: Any, features: FeatureSet) -> Any:
|
|
214
|
-
# return pd.DataFrame({
|
|
215
|
-
# 'customer_id': ['C001', 'C002'],
|
|
216
|
-
# 'age': [25, 30],
|
|
217
|
-
# 'income': [50000, 75000]
|
|
218
|
-
# })
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**2. DataAccessCollection** - For production file/database access
|
|
222
|
-
```python
|
|
223
|
-
# Example (requires actual files/databases):
|
|
224
|
-
# from mloda.user import DataAccessCollection
|
|
225
|
-
#
|
|
226
|
-
# # Read from files, folders, or databases
|
|
227
|
-
# data_access = DataAccessCollection(
|
|
228
|
-
# files={"customers.csv", "orders.parquet"}, # CSV/Parquet/JSON files
|
|
229
|
-
# folders={"data/raw/"}, # Entire directories
|
|
230
|
-
# credential_dicts={"host": "db.example.com"} # Database credentials
|
|
231
|
-
# )
|
|
232
|
-
#
|
|
233
|
-
# result = mloda.run_all(
|
|
234
|
-
# features=["customer_id", "income__standard_scaled"],
|
|
235
|
-
# compute_frameworks=["PandasDataFrame"],
|
|
236
|
-
# data_access_collection=data_access
|
|
237
|
-
# )
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
**3. ApiData** - For runtime data injection (web requests, real-time predictions)
|
|
241
|
-
```python
|
|
242
|
-
# Example (for API endpoints and real-time predictions):
|
|
243
|
-
# from mloda.provider import ApiDataCollection
|
|
244
|
-
#
|
|
245
|
-
# api_input_data_collection = ApiDataCollection()
|
|
246
|
-
# api_data = api_input_data_collection.setup_key_api_data(
|
|
247
|
-
# key_name="PredictionData",
|
|
248
|
-
# api_input_data={"customer_id": ["C001", "C002"], "age": [25, 30]}
|
|
249
|
-
# )
|
|
250
|
-
#
|
|
251
|
-
# result = mloda.run_all(
|
|
252
|
-
# features=["customer_id", "age__standard_scaled"],
|
|
253
|
-
# compute_frameworks=["PandasDataFrame"],
|
|
254
|
-
# api_input_data_collection=api_input_data_collection,
|
|
255
|
-
# api_data=api_data
|
|
256
|
-
# )
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
> **Key Insight**: Use **DataCreator** for demos, **DataAccessCollection** for batch processing from files/databases, and **ApiData** for real-time predictions and web services.
|
|
260
|
-
|
|
261
|
-
### 5. Compute Frameworks - Choose Your Processing Engine
|
|
262
|
-
|
|
263
|
-
**Using Different Data Processing Libraries**
|
|
264
|
-
|
|
265
|
-
mloda supports multiple compute frameworks (pandas, polars, pyarrow, etc.). Most users start with pandas:
|
|
266
|
-
|
|
267
|
-
```python
|
|
268
|
-
# Using the SampleData class from Section 1
|
|
269
|
-
# Default: Everything processes with pandas
|
|
270
|
-
result = mloda.run_all(
|
|
271
|
-
features=["customer_id", "income__standard_scaled"],
|
|
272
|
-
compute_frameworks=["PandasDataFrame"] # Use pandas for all features
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
data = result[0] # Returns pandas DataFrame
|
|
276
|
-
print(type(data)) # <class 'pandas.core.frame.DataFrame'>
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
**Why Compute Frameworks Matter:**
|
|
280
|
-
- **Pandas**: Best for small-to-medium datasets, rich ecosystem, familiar API
|
|
281
|
-
- **Polars**: High performance for larger datasets
|
|
282
|
-
- **PyArrow**: Memory-efficient, great for columnar data
|
|
283
|
-
- **Spark**: Distributed processing for big data
|
|
284
|
-
|
|
285
|
-
### 6. Putting It All Together - Complete ML Pipeline
|
|
286
|
-
|
|
287
|
-
**Real-World Example: Customer Churn Prediction**
|
|
288
|
-
|
|
289
|
-
Let's build a complete machine learning pipeline with mloda:
|
|
290
|
-
|
|
291
|
-
```python
|
|
292
|
-
# Step 1: Extend SampleData with more features for ML
|
|
293
|
-
# (Reuse the same class to avoid conflicts)
|
|
294
|
-
SampleData._original_calculate = SampleData.calculate_feature
|
|
295
|
-
|
|
296
|
-
@classmethod
|
|
297
|
-
def _extended_calculate(cls, data: Any, features: FeatureSet) -> Any:
|
|
298
|
-
import numpy as np
|
|
299
|
-
np.random.seed(42)
|
|
300
|
-
n = 100
|
|
301
|
-
return pd.DataFrame({
|
|
302
|
-
'customer_id': [f'C{i:03d}' for i in range(n)],
|
|
303
|
-
'age': np.random.randint(18, 70, n),
|
|
304
|
-
'income': np.random.randint(30000, 120000, n),
|
|
305
|
-
'account_balance': np.random.randint(0, 10000, n),
|
|
306
|
-
'subscription_tier': np.random.choice(['Basic', 'Premium', 'Enterprise'], n),
|
|
307
|
-
'region': np.random.choice(['North', 'South', 'East', 'West'], n),
|
|
308
|
-
'customer_segment': np.random.choice(['New', 'Regular', 'VIP'], n),
|
|
309
|
-
'churned': np.random.choice([0, 1], n)
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
SampleData.calculate_feature = _extended_calculate
|
|
313
|
-
SampleData._input_data_original = SampleData.input_data()
|
|
314
|
-
|
|
315
|
-
@classmethod
|
|
316
|
-
def _extended_input_data(cls) -> Optional[BaseInputData]:
|
|
317
|
-
return DataCreator({"customer_id", "age", "income", "account_balance",
|
|
318
|
-
"subscription_tier", "region", "customer_segment", "churned"})
|
|
319
|
-
|
|
320
|
-
SampleData.input_data = _extended_input_data
|
|
321
|
-
|
|
322
|
-
# Step 2: Run feature engineering pipeline
|
|
323
|
-
from sklearn.model_selection import train_test_split
|
|
324
|
-
from sklearn.ensemble import RandomForestClassifier
|
|
325
|
-
from sklearn.metrics import accuracy_score
|
|
326
|
-
|
|
327
|
-
result = mloda.run_all(
|
|
328
|
-
features=[
|
|
329
|
-
"customer_id",
|
|
330
|
-
"age__standard_scaled",
|
|
331
|
-
"income__standard_scaled",
|
|
332
|
-
"account_balance__robust_scaled",
|
|
333
|
-
"subscription_tier__label_encoded",
|
|
334
|
-
"region__label_encoded",
|
|
335
|
-
"customer_segment__label_encoded",
|
|
336
|
-
"churned"
|
|
337
|
-
],
|
|
338
|
-
compute_frameworks=["PandasDataFrame"]
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
# Step 3: Prepare for ML
|
|
342
|
-
processed_data = result[0]
|
|
343
|
-
if len(processed_data.columns) > 2: # Check we have features besides customer_id and churned
|
|
344
|
-
X = processed_data.drop(['customer_id', 'churned'], axis=1)
|
|
345
|
-
y = processed_data['churned']
|
|
346
|
-
|
|
347
|
-
# Step 4: Train and evaluate
|
|
348
|
-
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
349
|
-
model = RandomForestClassifier(n_estimators=100, random_state=42)
|
|
350
|
-
model.fit(X_train, y_train)
|
|
351
|
-
accuracy = accuracy_score(y_test, model.predict(X_test))
|
|
352
|
-
print(f"🎯 Model Accuracy: {accuracy:.2%}")
|
|
353
|
-
else:
|
|
354
|
-
print("⚠️ Skipping ML - extend SampleData first with more features!")
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
**What mloda Did For You:**
|
|
358
|
-
1. ✅ Generated sample data with DataCreator
|
|
359
|
-
2. ✅ Scaled numeric features (StandardScaler & RobustScaler)
|
|
360
|
-
3. ✅ Encoded categorical features (Label encoding)
|
|
361
|
-
4. ✅ Returned clean DataFrame ready for sklearn
|
|
362
|
-
|
|
363
|
-
> **🎉 You now understand mloda's complete workflow!** The same transformations work across pandas, polars, pyarrow, and other frameworks - just change `compute_frameworks`.
|
|
364
|
-
|
|
365
|
-
## 📖 Documentation
|
|
366
|
-
|
|
367
|
-
- **[Getting Started](https://mloda-ai.github.io/mloda/chapter1/installation/)** - Installation and first steps
|
|
368
|
-
- **[sklearn Integration](https://mloda-ai.github.io/mloda/examples/sklearn_integration_basic/)** - Complete tutorial
|
|
369
|
-
- **[Feature Groups](https://mloda-ai.github.io/mloda/chapter1/feature-groups/)** - Core concepts
|
|
370
|
-
- **[Compute Frameworks](https://mloda-ai.github.io/mloda/chapter1/compute-frameworks/)** - Technology integration
|
|
371
|
-
- **[API Reference](https://mloda-ai.github.io/mloda/in_depth/mloda-api/)** - Complete API documentation
|
|
372
|
-
|
|
373
|
-
## 🤝 Contributing
|
|
374
|
-
|
|
375
|
-
We welcome contributions! Whether you're building plugins, adding features, or improving documentation, your input is invaluable.
|
|
376
|
-
|
|
377
|
-
- **[Development Guide](https://mloda-ai.github.io/mloda/development/)** - How to contribute
|
|
378
|
-
- **[GitHub Issues](https://github.com/mloda-ai/mloda/issues/)** - Report bugs or request features
|
|
379
|
-
- **[Email](mailto:info@mloda.ai)** - Direct contact
|
|
380
|
-
|
|
381
|
-
## 📄 License
|
|
382
|
-
|
|
383
|
-
This project is licensed under the [Apache License, Version 2.0](https://github.com/mloda-ai/mloda/blob/main/LICENSE.TXT).
|
|
384
|
-
---
|
mloda_plugins/config/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Configuration plugins for mloda
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|