MCPcopy Create free account
hub / github.com/ScottfreeLLC/AlphaPy / save_model

Function save_model

alphapy/model.py:1257–1331  ·  view source on GitHub ↗

r"""Save the results in the model file. Parameters ---------- model : alphapy.Model The model object to save. tag : str A unique identifier for the output files, e.g., a date stamp. partition : alphapy.Partition Reference to the dataset. Returns

(model, tag, partition)

Source from the content-addressed store, hash-verified

1255#
1256
1257def save_model(model, tag, partition):
1258 r"""Save the results in the model file.
1259
1260 Parameters
1261 ----------
1262 model : alphapy.Model
1263 The model object to save.
1264 tag : str
1265 A unique identifier for the output files, e.g., a date stamp.
1266 partition : alphapy.Partition
1267 Reference to the dataset.
1268
1269 Returns
1270 -------
1271 None : None
1272
1273 Notes
1274 -----
1275
1276 The following components are extracted from the model object
1277 and saved to disk:
1278
1279 * Model predictor (via joblib/pickle)
1280 * Predictions
1281 * Probabilities (classification only)
1282 * Rankings
1283 * Submission File (optional)
1284
1285 """
1286
1287 logger.info('='*80)
1288
1289 # Extract model parameters.
1290
1291 directory = model.specs['directory']
1292 extension = model.specs['extension']
1293 model_type = model.specs['model_type']
1294 submission_file = model.specs['submission_file']
1295 submit_probas = model.specs['submit_probas']
1296
1297 # Get date stamp to record file creation
1298
1299 d = datetime.now()
1300 f = "%Y%m%d"
1301 timestamp = d.strftime(f)
1302
1303 # Save the model predictor
1304 save_predictor(model, timestamp)
1305
1306 # Save the feature map
1307 save_feature_map(model, timestamp)
1308
1309 # Specify input and output directories
1310
1311 input_dir = SSEP.join([directory, 'input'])
1312 output_dir = SSEP.join([directory, 'output'])
1313
1314 # Save predictions

Callers 1

training_pipelineFunction · 0.90

Calls 3

save_predictorFunction · 0.85
save_feature_mapFunction · 0.85
save_predictionsFunction · 0.85

Tested by

no test coverage detected