outdatedLabs 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.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: outdatedLabs
3
+ Version: 0.1.0
4
+ Summary: A secure package for training machine learning models
5
+ Home-page: https://github.com/Mouli51ch/OutDated
6
+ Author: OutDated Team
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.31.0
19
+ Requires-Dist: joblib>=1.3.0
20
+ Requires-Dist: pandas>=2.0.0
21
+ Requires-Dist: scikit-learn>=1.0.0
22
+ Requires-Dist: tqdm>=4.65.0
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ # OutDatedLabs - Secure Machine Learning Training Package
34
+
35
+ A Python package for secure machine learning model training using the ML training server.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install outdatedLabs
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ from outdatedLabs import SecureModel
47
+
48
+ # Create a linear regression model
49
+ model = SecureModel.linearRegression()
50
+
51
+ # Optionally set a custom server URL
52
+ model.set_server_url("http://your-server:8000")
53
+
54
+ # Train the model
55
+ model.fit(
56
+ dataset_hash="your_dataset_hash",
57
+ features=["feature1", "feature2"],
58
+ target="target_column"
59
+ )
60
+
61
+ # Make predictions
62
+ predictions = model.predict(X)
63
+
64
+ # Get training metrics
65
+ metrics = model.get_metrics()
66
+ print(metrics)
67
+ ```
68
+
69
+ ## Features
70
+
71
+ - Secure model training using encrypted datasets
72
+ - Support for linear regression models
73
+ - Progress tracking with tqdm
74
+ - Comprehensive error handling and logging
75
+ - Easy-to-use interface
76
+ - Configurable server URL
77
+
78
+ ## API Reference
79
+
80
+ ### SecureModel
81
+
82
+ The main class for secure model training.
83
+
84
+ #### Methods
85
+
86
+ - `linearRegression(server_url: str = "http://localhost:8000") -> SecureModel`
87
+ - Create a new linear regression model instance
88
+
89
+ - `set_server_url(server_url: str) -> SecureModel`
90
+ - Set a custom URL for the ML training server
91
+
92
+ - `fit(dataset_hash: str, features: List[str] = None, target: str = None, params: Dict[str, Any] = None) -> SecureModel`
93
+ - Train the model using the specified dataset
94
+
95
+ - `predict(X: Union[pd.DataFrame, List[List[float]]]) -> List[float]`
96
+ - Make predictions using the trained model
97
+
98
+ - `score(X: Union[pd.DataFrame, List[List[float]]], y: List[float]) -> Dict[str, float]`
99
+ - Calculate model performance metrics
100
+
101
+ - `get_metrics() -> Dict[str, Any]`
102
+ - Get training metrics
103
+
104
+ ## Requirements
105
+
106
+ - Python 3.7+
107
+ - requests
108
+ - joblib
109
+ - pandas
110
+ - scikit-learn
111
+ - tqdm
112
+
113
+ ## License
114
+
115
+ MIT License
@@ -0,0 +1,83 @@
1
+ # OutDatedLabs - Secure Machine Learning Training Package
2
+
3
+ A Python package for secure machine learning model training using the ML training server.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install outdatedLabs
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from outdatedLabs import SecureModel
15
+
16
+ # Create a linear regression model
17
+ model = SecureModel.linearRegression()
18
+
19
+ # Optionally set a custom server URL
20
+ model.set_server_url("http://your-server:8000")
21
+
22
+ # Train the model
23
+ model.fit(
24
+ dataset_hash="your_dataset_hash",
25
+ features=["feature1", "feature2"],
26
+ target="target_column"
27
+ )
28
+
29
+ # Make predictions
30
+ predictions = model.predict(X)
31
+
32
+ # Get training metrics
33
+ metrics = model.get_metrics()
34
+ print(metrics)
35
+ ```
36
+
37
+ ## Features
38
+
39
+ - Secure model training using encrypted datasets
40
+ - Support for linear regression models
41
+ - Progress tracking with tqdm
42
+ - Comprehensive error handling and logging
43
+ - Easy-to-use interface
44
+ - Configurable server URL
45
+
46
+ ## API Reference
47
+
48
+ ### SecureModel
49
+
50
+ The main class for secure model training.
51
+
52
+ #### Methods
53
+
54
+ - `linearRegression(server_url: str = "http://localhost:8000") -> SecureModel`
55
+ - Create a new linear regression model instance
56
+
57
+ - `set_server_url(server_url: str) -> SecureModel`
58
+ - Set a custom URL for the ML training server
59
+
60
+ - `fit(dataset_hash: str, features: List[str] = None, target: str = None, params: Dict[str, Any] = None) -> SecureModel`
61
+ - Train the model using the specified dataset
62
+
63
+ - `predict(X: Union[pd.DataFrame, List[List[float]]]) -> List[float]`
64
+ - Make predictions using the trained model
65
+
66
+ - `score(X: Union[pd.DataFrame, List[List[float]]], y: List[float]) -> Dict[str, float]`
67
+ - Calculate model performance metrics
68
+
69
+ - `get_metrics() -> Dict[str, Any]`
70
+ - Get training metrics
71
+
72
+ ## Requirements
73
+
74
+ - Python 3.7+
75
+ - requests
76
+ - joblib
77
+ - pandas
78
+ - scikit-learn
79
+ - tqdm
80
+
81
+ ## License
82
+
83
+ MIT License
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,32 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="outdatedLabs",
5
+ version="0.1.0",
6
+ packages=find_packages(where="src"),
7
+ package_dir={"": "src"},
8
+ install_requires=[
9
+ "requests>=2.31.0",
10
+ "joblib>=1.3.0",
11
+ "pandas>=2.0.0",
12
+ "scikit-learn>=1.0.0",
13
+ "tqdm>=4.65.0",
14
+ ],
15
+ python_requires=">=3.8",
16
+ author="OutDated Team",
17
+ author_email="your.email@example.com",
18
+ description="A secure package for training machine learning models",
19
+ long_description=open("README.md").read(),
20
+ long_description_content_type="text/markdown",
21
+ url="https://github.com/Mouli51ch/OutDated",
22
+ classifiers=[
23
+ "Development Status :: 3 - Alpha",
24
+ "Intended Audience :: Developers",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.8",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ ],
32
+ )
@@ -0,0 +1,8 @@
1
+ """
2
+ OutDated - Secure Machine Learning Training Package
3
+ """
4
+
5
+ from .secure_model import SecureModel
6
+
7
+ __version__ = "0.1.0"
8
+ __all__ = ["SecureModel"]
@@ -0,0 +1,220 @@
1
+ """
2
+ Secure Model Training Module
3
+ """
4
+ import os
5
+ import time
6
+ import logging
7
+ import requests
8
+ import joblib
9
+ from typing import Optional, List, Dict, Any, Union
10
+ from pathlib import Path
11
+ from tqdm import tqdm
12
+ import pandas as pd
13
+ from sklearn.linear_model import LinearRegression
14
+ from sklearn.metrics import mean_squared_error, r2_score
15
+
16
+ # Configure logging
17
+ logging.basicConfig(
18
+ level=logging.INFO,
19
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
20
+ )
21
+ logger = logging.getLogger(__name__)
22
+
23
+ class SecureModel:
24
+ """Secure Model Training Class"""
25
+
26
+ def __init__(self, server_url: str = "http://localhost:8000"):
27
+ """
28
+ Initialize the SecureModel.
29
+
30
+ Args:
31
+ server_url (str): URL of the ML training server
32
+ """
33
+ self.server_url = server_url.rstrip('/')
34
+ self.job_id = None
35
+ self.model = None
36
+ self.metrics = None
37
+
38
+ def set_server_url(self, server_url: str) -> 'SecureModel':
39
+ """
40
+ Set the training server URL.
41
+
42
+ Args:
43
+ server_url (str): New URL for the ML training server
44
+
45
+ Returns:
46
+ SecureModel: Self for method chaining
47
+ """
48
+ self.server_url = server_url.rstrip('/')
49
+ logger.info(f"Server URL set to: {self.server_url}")
50
+ return self
51
+
52
+ @classmethod
53
+ def linearRegression(cls, server_url: str = "http://localhost:8000") -> 'SecureModel':
54
+ """
55
+ Create a Linear Regression model.
56
+
57
+ Args:
58
+ server_url (str): URL of the ML training server
59
+
60
+ Returns:
61
+ SecureModel: A new SecureModel instance configured for linear regression
62
+ """
63
+ instance = cls(server_url)
64
+ instance.algorithm = "linear_regression"
65
+ return instance
66
+
67
+ def fit(self,
68
+ dataset_hash: str,
69
+ features: Optional[List[str]] = None,
70
+ target: Optional[str] = None,
71
+ params: Optional[Dict[str, Any]] = None) -> 'SecureModel':
72
+ """
73
+ Train the model using the specified dataset.
74
+
75
+ Args:
76
+ dataset_hash (str): The dataset hash in format "walrus://dataset_hash"
77
+ features (List[str], optional): List of feature column names
78
+ target (str, optional): Target column name
79
+ params (Dict[str, Any], optional): Model parameters
80
+
81
+ Returns:
82
+ SecureModel: Self for method chaining
83
+ """
84
+ try:
85
+ # Extract hash from walrus:// format
86
+ if dataset_hash.startswith("walrus://"):
87
+ dataset_hash = dataset_hash[9:]
88
+
89
+ # Prepare training request
90
+ request_data = {
91
+ "dataset_hash": dataset_hash,
92
+ "algorithm": self.algorithm,
93
+ "params": params or {},
94
+ "features": features,
95
+ "target": target
96
+ }
97
+
98
+ logger.info(f"Starting training with parameters: {request_data}")
99
+
100
+ # Start training job
101
+ response = requests.post(
102
+ f"{self.server_url}/train",
103
+ json=request_data
104
+ )
105
+ response.raise_for_status()
106
+
107
+ # Get job ID
108
+ self.job_id = response.json()["job_id"]
109
+ logger.info(f"Training job started with ID: {self.job_id}")
110
+
111
+ # Wait for training to complete
112
+ self._wait_for_completion()
113
+
114
+ # Download and load the model
115
+ self._download_model()
116
+
117
+ return self
118
+
119
+ except Exception as e:
120
+ logger.error(f"Training failed: {str(e)}")
121
+ raise
122
+
123
+ def _wait_for_completion(self, check_interval: int = 2) -> None:
124
+ """Wait for the training job to complete."""
125
+ with tqdm(desc="Training", unit="s") as pbar:
126
+ while True:
127
+ response = requests.get(f"{self.server_url}/train/{self.job_id}/status")
128
+ response.raise_for_status()
129
+ status = response.json()
130
+
131
+ if status["status"] == "COMPLETE":
132
+ logger.info("Training completed successfully")
133
+ self.metrics = requests.get(f"{self.server_url}/train/{self.job_id}/metrics").json()
134
+ break
135
+ elif status["status"] == "FAILED":
136
+ error = status.get("error", "Unknown error")
137
+ raise Exception(f"Training failed: {error}")
138
+
139
+ time.sleep(check_interval)
140
+ pbar.update(check_interval)
141
+
142
+ def _download_model(self) -> None:
143
+ """Download the trained model."""
144
+ try:
145
+ response = requests.get(
146
+ f"{self.server_url}/train/{self.job_id}/model",
147
+ stream=True
148
+ )
149
+ response.raise_for_status()
150
+
151
+ # Save model to temporary file
152
+ temp_path = Path(f"model_{self.job_id}.joblib")
153
+ with open(temp_path, 'wb') as f:
154
+ for chunk in response.iter_content(chunk_size=8192):
155
+ if chunk:
156
+ f.write(chunk)
157
+
158
+ # Load the model
159
+ self.model = joblib.load(temp_path)
160
+
161
+ # Clean up
162
+ temp_path.unlink()
163
+
164
+ logger.info("Model downloaded and loaded successfully")
165
+
166
+ except Exception as e:
167
+ logger.error(f"Failed to download model: {str(e)}")
168
+ raise
169
+
170
+ def predict(self, X: Union[pd.DataFrame, List[List[float]]]) -> List[float]:
171
+ """
172
+ Make predictions using the trained model.
173
+
174
+ Args:
175
+ X: Input features as DataFrame or list of lists
176
+
177
+ Returns:
178
+ List[float]: Predicted values
179
+ """
180
+ if self.model is None:
181
+ raise Exception("Model not trained. Call fit() first.")
182
+
183
+ if isinstance(X, list):
184
+ X = pd.DataFrame(X)
185
+
186
+ return self.model.predict(X).tolist()
187
+
188
+ def score(self, X: Union[pd.DataFrame, List[List[float]]], y: List[float]) -> Dict[str, float]:
189
+ """
190
+ Calculate model performance metrics.
191
+
192
+ Args:
193
+ X: Input features as DataFrame or list of lists
194
+ y: True target values
195
+
196
+ Returns:
197
+ Dict[str, float]: Dictionary of metrics
198
+ """
199
+ if self.model is None:
200
+ raise Exception("Model not trained. Call fit() first.")
201
+
202
+ if isinstance(X, list):
203
+ X = pd.DataFrame(X)
204
+
205
+ y_pred = self.model.predict(X)
206
+ return {
207
+ "mse": mean_squared_error(y, y_pred),
208
+ "r2": r2_score(y, y_pred)
209
+ }
210
+
211
+ def get_metrics(self) -> Dict[str, Any]:
212
+ """
213
+ Get training metrics.
214
+
215
+ Returns:
216
+ Dict[str, Any]: Training metrics
217
+ """
218
+ if self.metrics is None:
219
+ raise Exception("Model not trained. Call fit() first.")
220
+ return self.metrics
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: outdatedLabs
3
+ Version: 0.1.0
4
+ Summary: A secure package for training machine learning models
5
+ Home-page: https://github.com/Mouli51ch/OutDated
6
+ Author: OutDated Team
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.31.0
19
+ Requires-Dist: joblib>=1.3.0
20
+ Requires-Dist: pandas>=2.0.0
21
+ Requires-Dist: scikit-learn>=1.0.0
22
+ Requires-Dist: tqdm>=4.65.0
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ # OutDatedLabs - Secure Machine Learning Training Package
34
+
35
+ A Python package for secure machine learning model training using the ML training server.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install outdatedLabs
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ from outdatedLabs import SecureModel
47
+
48
+ # Create a linear regression model
49
+ model = SecureModel.linearRegression()
50
+
51
+ # Optionally set a custom server URL
52
+ model.set_server_url("http://your-server:8000")
53
+
54
+ # Train the model
55
+ model.fit(
56
+ dataset_hash="your_dataset_hash",
57
+ features=["feature1", "feature2"],
58
+ target="target_column"
59
+ )
60
+
61
+ # Make predictions
62
+ predictions = model.predict(X)
63
+
64
+ # Get training metrics
65
+ metrics = model.get_metrics()
66
+ print(metrics)
67
+ ```
68
+
69
+ ## Features
70
+
71
+ - Secure model training using encrypted datasets
72
+ - Support for linear regression models
73
+ - Progress tracking with tqdm
74
+ - Comprehensive error handling and logging
75
+ - Easy-to-use interface
76
+ - Configurable server URL
77
+
78
+ ## API Reference
79
+
80
+ ### SecureModel
81
+
82
+ The main class for secure model training.
83
+
84
+ #### Methods
85
+
86
+ - `linearRegression(server_url: str = "http://localhost:8000") -> SecureModel`
87
+ - Create a new linear regression model instance
88
+
89
+ - `set_server_url(server_url: str) -> SecureModel`
90
+ - Set a custom URL for the ML training server
91
+
92
+ - `fit(dataset_hash: str, features: List[str] = None, target: str = None, params: Dict[str, Any] = None) -> SecureModel`
93
+ - Train the model using the specified dataset
94
+
95
+ - `predict(X: Union[pd.DataFrame, List[List[float]]]) -> List[float]`
96
+ - Make predictions using the trained model
97
+
98
+ - `score(X: Union[pd.DataFrame, List[List[float]]], y: List[float]) -> Dict[str, float]`
99
+ - Calculate model performance metrics
100
+
101
+ - `get_metrics() -> Dict[str, Any]`
102
+ - Get training metrics
103
+
104
+ ## Requirements
105
+
106
+ - Python 3.7+
107
+ - requests
108
+ - joblib
109
+ - pandas
110
+ - scikit-learn
111
+ - tqdm
112
+
113
+ ## License
114
+
115
+ MIT License
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ src/outdatedLabs/__init__.py
5
+ src/outdatedLabs/secure_model.py
6
+ src/outdatedLabs.egg-info/PKG-INFO
7
+ src/outdatedLabs.egg-info/SOURCES.txt
8
+ src/outdatedLabs.egg-info/dependency_links.txt
9
+ src/outdatedLabs.egg-info/requires.txt
10
+ src/outdatedLabs.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ requests>=2.31.0
2
+ joblib>=1.3.0
3
+ pandas>=2.0.0
4
+ scikit-learn>=1.0.0
5
+ tqdm>=4.65.0
@@ -0,0 +1 @@
1
+ outdatedLabs