lecrapaud 0.1.0__py3-none-any.whl → 0.2.0__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.

Potentially problematic release.


This version of lecrapaud might be problematic. Click here for more details.

lecrapaud/config.py CHANGED
@@ -22,4 +22,5 @@ DB_PASSWORD = (
22
22
  DB_HOST = os.getenv("TEST_DB_HOST") if PYTHON_ENV == "Test" else os.getenv("DB_HOST")
23
23
  DB_PORT = os.getenv("TEST_DB_PORT") if PYTHON_ENV == "Test" else os.getenv("DB_PORT")
24
24
  DB_NAME = os.getenv("TEST_DB_NAME") if PYTHON_ENV == "Test" else os.getenv("DB_NAME")
25
+ DB_URI = os.getenv("DB_URI", None)
25
26
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
lecrapaud/db/session.py CHANGED
@@ -3,20 +3,30 @@
3
3
  from contextlib import contextmanager
4
4
  from sqlalchemy import create_engine, text
5
5
  from sqlalchemy.orm import sessionmaker
6
- from lecrapaud.config import DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME
6
+ from urllib.parse import urlparse
7
+
8
+ from lecrapaud.config import DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, DB_URI
7
9
 
8
10
  _engine = None
9
11
  _SessionLocal = None
10
- DATABASE_URL = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
12
+ DATABASE_URL = (
13
+ f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" or DB_URI
14
+ )
11
15
 
12
16
 
13
17
  def init_db(uri: str = None):
14
18
  global _engine, _SessionLocal
15
19
 
20
+ uri = uri if uri else DATABASE_URL
21
+ # Extract DB name from URI to connect without it
22
+ parsed = urlparse(uri)
23
+ db_name = parsed.path.lstrip("/") # remove leading slash
24
+
25
+ # Build root engine (no database in URI)
26
+ root_uri = uri.replace(f"/{db_name}", "/")
27
+
16
28
  # Step 1: Connect to MySQL without a database
17
- root_engine = create_engine(
18
- uri if uri else f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/"
19
- )
29
+ root_engine = create_engine(root_uri)
20
30
 
21
31
  # Step 2: Create database if it doesn't exist
22
32
  with root_engine.connect() as conn:
@@ -24,7 +34,7 @@ def init_db(uri: str = None):
24
34
  conn.commit()
25
35
 
26
36
  # Step 3: Connect to the newly created database
27
- _engine = create_engine(DATABASE_URL, echo=False)
37
+ _engine = create_engine(uri, echo=False)
28
38
 
29
39
  # Step 4: Create session factory
30
40
  _SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=_engine)
@@ -589,7 +589,6 @@ class PreprocessFeature:
589
589
 
590
590
  if transformer:
591
591
  transformed = transformer.transform(X)
592
- print(len(transformed), len(transformed[0]))
593
592
  else:
594
593
  transformer = ColumnTransformer(
595
594
  transformers=[
@@ -811,12 +811,10 @@ class PreprocessModel:
811
811
  if duplicates:
812
812
  raise ValueError(f"Doublons détectés dans columns_to_keep: {duplicates}")
813
813
 
814
- logger.info(self.all_features)
815
-
816
814
  self.train = train[columns_to_keep]
817
- if val:
815
+ if isinstance(val, pd.DataFrame):
818
816
  self.val = val[columns_to_keep]
819
- if test:
817
+ if isinstance(test, pd.DataFrame):
820
818
  self.test = test[columns_to_keep]
821
819
 
822
820
  def run(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lecrapaud
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Framework for machine and deep learning, with regression, classification and time series analysis
5
5
  License: Apache License
6
6
  Author: Pierre H. Gallet
@@ -47,13 +47,30 @@ Requires-Dist: yahoo-fin (>=0.8.9.1)
47
47
  Requires-Dist: yfinance (>=0.2.55)
48
48
  Description-Content-Type: text/markdown
49
49
 
50
- # Stock
50
+ <div align="center">
51
51
 
52
- ## Overview
52
+ # 🐸
53
53
 
54
- ## Project description
54
+ ## Welcome to LeCrapaud
55
55
 
56
- ## Quick Start
56
+ **An all-in-one machine learning framework**
57
+
58
+ </div>
59
+
60
+ ## 🚀 Introduction
61
+
62
+ LeCrapaud is a high-level Python library for end-to-end machine learning workflows on tabular data, with a focus on financial and stock datasets. It provides a simple API to handle feature engineering, model selection, training, and prediction, all in a reproducible and modular way.
63
+
64
+ ## ✨ Key Features
65
+
66
+ - 🧩 Modular pipeline: Feature engineering, preprocessing, selection, and modeling as independent steps
67
+ - 🤖 Automated model selection and hyperparameter optimization
68
+ - 📊 Easy integration with pandas DataFrames
69
+ - 🔬 Supports both regression and classification tasks
70
+ - 🛠️ Simple API for both full pipeline and step-by-step usage
71
+ - 📦 Ready for production and research workflows
72
+
73
+ ## ⚡ Quick Start
57
74
 
58
75
  1. Create environment
59
76
 
@@ -66,8 +83,7 @@ $ source .venv/bin/activate
66
83
  2. Install dependencies
67
84
 
68
85
  ```sh
69
- $ pip install -r requirements.txt
70
- $ pip freeze > requirements.txt
86
+ $ make install
71
87
  ```
72
88
 
73
89
  3. Deactivate virtualenv (if needed)
@@ -76,7 +92,51 @@ $ pip freeze > requirements.txt
76
92
  $ deactivate
77
93
  ```
78
94
 
79
- ## Reminders for Github usage
95
+ ## 🛠️ How it works
96
+
97
+ This package provides a high-level API to manage experiments for feature engineering, model selection, and prediction on tabular data (e.g. stock data).
98
+
99
+ ### Typical workflow
100
+
101
+ ```python
102
+ from lecrapaud.api import LeCrapaud
103
+
104
+ # 1. Create the main app
105
+ app = LeCrapaud()
106
+
107
+ # 2. Define your experiment context (see your notebook or api.py for all options)
108
+ context = {
109
+ "data": your_dataframe,
110
+ "columns_drop": [...],
111
+ "columns_date": [...],
112
+ # ... other config options
113
+ }
114
+
115
+ # 3. Create an experiment
116
+ experiment = app.create_experiment(**context)
117
+
118
+ # 4. Run the full training pipeline
119
+ experiment.train(your_dataframe)
120
+
121
+ # 5. Make predictions on new data
122
+ predictions = experiment.predict(new_data)
123
+ ```
124
+
125
+ ### Modular usage
126
+
127
+ You can also use each step independently:
128
+
129
+ ```python
130
+ data_eng = experiment.feature_engineering(data)
131
+ train, val, test = experiment.preprocess_feature(data_eng)
132
+ features = experiment.feature_selection(train)
133
+ std_data, reshaped_data = experiment.preprocess_model(train, val, test)
134
+ experiment.model_selection(std_data, reshaped_data)
135
+ ```
136
+
137
+ ## 🤝 Contributing
138
+
139
+ ### Reminders for Github usage
80
140
 
81
141
  1. Creating Github repository
82
142
 
@@ -96,10 +156,9 @@ $ git remote add origin <YOUR_REPO_URL>
96
156
  $ git push -u origin master
97
157
  ```
98
158
 
99
- 3. use conventional commits
159
+ 3. Use conventional commits
100
160
  https://www.conventionalcommits.org/en/v1.0.0/#summary
101
161
 
102
-
103
- ***
162
+ ---
104
163
 
105
164
  Pierre Gallet © 2024
@@ -1,6 +1,6 @@
1
1
  lecrapaud/__init__.py,sha256=oCxbtw_nk8rlOXbXbWo0RRMlsh6w-hTiZ6e5PRG_wp0,28
2
2
  lecrapaud/api.py,sha256=VpVj6zRanLzHo2bwbkar-HcOKsJPEDghWhxbrqDOxp4,9749
3
- lecrapaud/config.py,sha256=NMHQw98wqnva9uVaheJH1Peq6QmssvGkFECwi0tYb90,992
3
+ lecrapaud/config.py,sha256=Jf7kknumJ9NudVoLugOxqLqB7zTSl67IVV2VVWA0Pv4,1027
4
4
  lecrapaud/db/__init__.py,sha256=82o9fMfaqKXPh2_rt44EzNRVZV1R4LScEnQYvj_TjK0,34
5
5
  lecrapaud/db/alembic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
6
6
  lecrapaud/db/alembic/env.py,sha256=OwO56oeL7o3XQe2pnhMxK9C3Yeoz-ZCnGUSnXkNU-rg,2164
@@ -32,11 +32,11 @@ lecrapaud/db/models/model_selection.py,sha256=Lj2WZBWvaVpJeDjdiAs8wvkoI-XrWv2IIj
32
32
  lecrapaud/db/models/model_training.py,sha256=2xv9SOh8IUV1ROSsKlooAGanl9G8nBdmr7vaV4GAWtw,1618
33
33
  lecrapaud/db/models/score.py,sha256=I6kA55ZQhReo9dA_JEgeRSqDoFKmYyL3l-zCffwsofs,1719
34
34
  lecrapaud/db/models/target.py,sha256=scEtXVO3oysEvg9uwm_ncsS3-4o2A6z6XiDVGrg5WHE,1644
35
- lecrapaud/db/session.py,sha256=lk_H-oCWgvK8HKahyk96HBgWp0SLw7PCeaOgCgg8aPc,1387
35
+ lecrapaud/db/session.py,sha256=eD3zNodgC_ZEiNrSnhooMsaMiyccK9xgeReABWrbAuk,1629
36
36
  lecrapaud/directory_management.py,sha256=wrHmAJ-cBKb0GhJifxrb_RoLhZJX8xdkeirrWs7jQHk,791
37
37
  lecrapaud/experiment.py,sha256=8Y7HX5MGifrcquOML1lYXG-q40Wn4WBBRqLfPs1tLuk,1994
38
- lecrapaud/feature_engineering.py,sha256=jlqqUeRj4SnCpklZdnXkEpwFGaz3S-fy8frAuDOFcpc,30384
39
- lecrapaud/feature_selection.py,sha256=N8yRhx544hk__rJV-MFq28IetVwhev4iKHruBalYpjU,43011
38
+ lecrapaud/feature_engineering.py,sha256=zia2qxe_KLBUZV2KYVPqGd2K55AjHiyeeCm_GhobJHE,30327
39
+ lecrapaud/feature_selection.py,sha256=2h3S_c0hYZM-EKenpVRYTFFqT4T7fg2lJ5pY2gUDalk,43023
40
40
  lecrapaud/integrations/openai_integration.py,sha256=hHLF3fk5Bps8KNbNrEL3NUFa945jwClE6LrLpuMZOd4,7459
41
41
  lecrapaud/jobs/__init__.py,sha256=ZkrsyTOR21c_wN7RY8jPhm8jCrL1oCEtTsf3VFIlQiE,292
42
42
  lecrapaud/jobs/config.py,sha256=AmO0j3RFjx8H66dfKw_7vnshaOJb9Ox5BAZ9cwwLFMY,377
@@ -57,7 +57,7 @@ lecrapaud/speed_tests/tests.ipynb,sha256=RjI7LDHSsbadUkea_hT14sD7ivljtIQk4NB5McX
57
57
  lecrapaud/speed_tests/trash.py,sha256=E4zrrRyVqeNEumWg8rYKquR9VTIULN52eCRqjmv_s58,1647
58
58
  lecrapaud/training.py,sha256=a-p-06-h-oRj5A728-xwekHZ7mxTnrPnKjAjoZhNZME,8071
59
59
  lecrapaud/utils.py,sha256=J2lMRo8J1CoZ1AYIPcdbFWXg-PxtQTs8qmeINioXWfk,8107
60
- lecrapaud-0.1.0.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
61
- lecrapaud-0.1.0.dist-info/METADATA,sha256=k3hj1_rsu1xXKg5wQIWtgpIVEzvxOQ3lnJRkvS08fOw,2519
62
- lecrapaud-0.1.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
63
- lecrapaud-0.1.0.dist-info/RECORD,,
60
+ lecrapaud-0.2.0.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
61
+ lecrapaud-0.2.0.dist-info/METADATA,sha256=kmWU9zMyEcj-hChq1bDmBJF6oVq3V0yKm8-sZiPJpuc,4363
62
+ lecrapaud-0.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
63
+ lecrapaud-0.2.0.dist-info/RECORD,,