outdatedLabs 0.1.0__py3-none-any.whl → 0.1.1__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.
@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
23
23
  class SecureModel:
24
24
  """Secure Model Training Class"""
25
25
 
26
- def __init__(self, server_url: str = "http://localhost:8000"):
26
+ def __init__(self, server_url: str = "http://localhost:3000"):
27
27
  """
28
28
  Initialize the SecureModel.
29
29
 
@@ -35,6 +35,18 @@ class SecureModel:
35
35
  self.model = None
36
36
  self.metrics = None
37
37
 
38
+ # Test server connection
39
+ try:
40
+ response = requests.get(f"{self.server_url}/health")
41
+ response.raise_for_status()
42
+ logger.info(f"Successfully connected to server at {self.server_url}")
43
+ except requests.exceptions.ConnectionError:
44
+ logger.error(f"Could not connect to server at {self.server_url}. Please ensure the server is running.")
45
+ raise
46
+ except requests.exceptions.RequestException as e:
47
+ logger.error(f"Error connecting to server: {str(e)}")
48
+ raise
49
+
38
50
  def set_server_url(self, server_url: str) -> 'SecureModel':
39
51
  """
40
52
  Set the training server URL.
@@ -47,10 +59,23 @@ class SecureModel:
47
59
  """
48
60
  self.server_url = server_url.rstrip('/')
49
61
  logger.info(f"Server URL set to: {self.server_url}")
62
+
63
+ # Test new server connection
64
+ try:
65
+ response = requests.get(f"{self.server_url}/health")
66
+ response.raise_for_status()
67
+ logger.info(f"Successfully connected to new server at {self.server_url}")
68
+ except requests.exceptions.ConnectionError:
69
+ logger.error(f"Could not connect to server at {self.server_url}. Please ensure the server is running.")
70
+ raise
71
+ except requests.exceptions.RequestException as e:
72
+ logger.error(f"Error connecting to server: {str(e)}")
73
+ raise
74
+
50
75
  return self
51
76
 
52
77
  @classmethod
53
- def linearRegression(cls, server_url: str = "http://localhost:8000") -> 'SecureModel':
78
+ def linearRegression(cls, server_url: str = "http://localhost:3000") -> 'SecureModel':
54
79
  """
55
80
  Create a Linear Regression model.
56
81
 
@@ -124,20 +149,29 @@ class SecureModel:
124
149
  """Wait for the training job to complete."""
125
150
  with tqdm(desc="Training", unit="s") as pbar:
126
151
  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)
152
+ try:
153
+ response = requests.get(f"{self.server_url}/train/{self.job_id}/status")
154
+ response.raise_for_status()
155
+ status = response.json()
156
+
157
+ # Convert status to uppercase for case-insensitive comparison
158
+ current_status = status["status"].upper()
159
+
160
+ if current_status == "COMPLETE":
161
+ logger.info("Training completed successfully")
162
+ self.metrics = requests.get(f"{self.server_url}/train/{self.job_id}/metrics").json()
163
+ pbar.close()
164
+ return
165
+ elif current_status == "FAILED":
166
+ error = status.get("error", "Unknown error")
167
+ pbar.close()
168
+ raise Exception(f"Training failed: {error}")
169
+
170
+ time.sleep(check_interval)
171
+ pbar.update(check_interval)
172
+ except Exception as e:
173
+ pbar.close()
174
+ raise Exception(f"Error checking training status: {str(e)}")
141
175
 
142
176
  def _download_model(self) -> None:
143
177
  """Download the trained model."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: outdatedLabs
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A secure package for training machine learning models
5
5
  Home-page: https://github.com/Mouli51ch/OutDated
6
6
  Author: OutDated Team
@@ -30,9 +30,9 @@ Dynamic: requires-dist
30
30
  Dynamic: requires-python
31
31
  Dynamic: summary
32
32
 
33
- # OutDatedLabs - Secure Machine Learning Training Package
33
+ # OutdatedLabs - Secure Machine Learning Training Package
34
34
 
35
- A Python package for secure machine learning model training using the ML training server.
35
+ A secure and easy-to-use package for training machine learning models with remote server support.
36
36
 
37
37
  ## Installation
38
38
 
@@ -42,73 +42,65 @@ pip install outdatedLabs
42
42
 
43
43
  ## Quick Start
44
44
 
45
+ 1. Start the ML training server:
46
+ ```bash
47
+ cd mlTrainingServer
48
+ uv run main.py
49
+ ```
50
+
51
+ 2. Use the package in your code:
45
52
  ```python
46
53
  from outdatedLabs import SecureModel
47
54
 
48
55
  # Create a linear regression model
49
56
  model = SecureModel.linearRegression()
50
57
 
51
- # Optionally set a custom server URL
52
- model.set_server_url("http://your-server:8000")
53
-
54
58
  # Train the model
55
- model.fit(
59
+ model.train(
56
60
  dataset_hash="your_dataset_hash",
57
61
  features=["feature1", "feature2"],
58
62
  target="target_column"
59
63
  )
60
64
 
61
- # Make predictions
62
- predictions = model.predict(X)
63
-
64
65
  # Get training metrics
65
66
  metrics = model.get_metrics()
66
67
  print(metrics)
68
+
69
+ # Download and load the trained model
70
+ model.download_model()
71
+ loaded_model = model.load_model()
67
72
  ```
68
73
 
69
74
  ## Features
70
75
 
71
- - Secure model training using encrypted datasets
72
- - Support for linear regression models
76
+ - Secure model training with remote server support
77
+ - Automatic dataset download and cleanup
73
78
  - Progress tracking with tqdm
74
- - Comprehensive error handling and logging
75
- - Easy-to-use interface
76
- - Configurable server URL
79
+ - Comprehensive error handling
80
+ - Detailed logging
81
+ - Support for multiple algorithms (currently Linear Regression)
82
+
83
+ ## Configuration
84
+
85
+ The package connects to a local ML training server by default at `http://localhost:3000`. You can change the server URL when creating a model:
86
+
87
+ ```python
88
+ model = SecureModel.linearRegression(server_url="http://your-server:3000")
89
+ ```
77
90
 
78
91
  ## API Reference
79
92
 
80
93
  ### SecureModel
81
94
 
82
- The main class for secure model training.
95
+ The main class for model training and management.
83
96
 
84
97
  #### Methods
85
98
 
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
99
+ - `linearRegression(server_url: str = "http://localhost:3000")`: Create a Linear Regression model
100
+ - `train(dataset_hash: str, features: List[str], target: str)`: Train the model
101
+ - `get_metrics() -> Dict`: Get training metrics
102
+ - `download_model() -> str`: Download the trained model
103
+ - `load_model() -> Any`: Load the trained model
112
104
 
113
105
  ## License
114
106
 
@@ -0,0 +1,6 @@
1
+ outdatedLabs/__init__.py,sha256=WPtCdx6yrgxKlTwImcOmub-LrNhxnSmFSOVHp1wxt9A,155
2
+ outdatedLabs/secure_model.py,sha256=nY95bLdE4PLHr-niScu3ro4vHdRiJhWYvdpPsDtrn40,9077
3
+ outdatedlabs-0.1.1.dist-info/METADATA,sha256=Qrye8gdYTz8JSIUCrKvi4XeVCwrRTl_LvzHNWyXkEnk,2868
4
+ outdatedlabs-0.1.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
5
+ outdatedlabs-0.1.1.dist-info/top_level.txt,sha256=dBixB2lDCF0P_lTFturV9clqXELck_mkELZCL8bihWQ,13
6
+ outdatedlabs-0.1.1.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- outdatedLabs/__init__.py,sha256=WPtCdx6yrgxKlTwImcOmub-LrNhxnSmFSOVHp1wxt9A,155
2
- outdatedLabs/secure_model.py,sha256=V4jw2M_z6OpyZgGBegAdrJIghDJUI3mdEPwqJkoR45I,7416
3
- outdatedlabs-0.1.0.dist-info/METADATA,sha256=MelN-nsIWfwdDmZOc7i5YgJuKsWTZ6KAZBIOwOz3-q0,2978
4
- outdatedlabs-0.1.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
5
- outdatedlabs-0.1.0.dist-info/top_level.txt,sha256=dBixB2lDCF0P_lTFturV9clqXELck_mkELZCL8bihWQ,13
6
- outdatedlabs-0.1.0.dist-info/RECORD,,