openprotein.predictor
SDK release/v0.18.0This compatibility interface is deprecated. Use session.models for model access.
Train property predictors from your datasets to enable predictions for new sequences! Use crossvalidation on the trained predictors to estimate uncertainty. Trained predictors can be used to design new sequences based on design goals for properties.
5source
Predictor API providing the interface to train and predict predictors.
sessionAPISessionmethodget_predictor(predictor_id, include_stats=False, include_calibration_curves=False)→PredictorModelsource
Get predictor by model_id.
PredictorModel allows all the usual prediction job manipulation: e.g. making POST and GET requests for this predictor specifically.
predictor_idstrThe model identifier.
include_statsbool= FalseWhether to include stats of the predictor from the latest evaluation (pearson, spearman, ece). Default is False.
include_calibration_curvesbool= FalseWhether to include calibration curves of the predictor from the latest evaluation. Default is False.
The predictor model to inspect and make predictions with.
If the GET request does not succeed.
methodlist_predictors(limit=100, offset=0, include_stats=False, include_calibration_curves=False)→list[PredictorModel]source
List predictors available.
limitint= 100Limit of the number of predictors to return in list. Default is 100.
offsetint= 0Offset to the predictors to query for paged queries. Default is 0.
include_statsbool= FalseWhether to include stats of each predictor from the latest evaluation (pearson, spearman, ece). Default is False.
include_calibration_curvesbool= FalseWhether to include calibration curves of each predictor from the latest evaluation. Default is False.
List of predictor models to inspect and make predictions with.
If the GET request does not succeed.
methodfit_gp(assay, properties, model, feature_type=None, reduction=None, name=None, description=None, kernel='rbf', period=None, alpha=None, **kwargs)→PredictorModelsource
Fit a GP on an assay with the specified feature model and hyperparameters.
assayAssayMetadata or AssayDataset or strAssay to fit GP on.
propertieslist of strProperties in the assay to fit the gp on.
modelEmbeddingModel or SVDModel or strInstance of either EmbeddingModel or SVDModel to use depending on feature type. Can also be a str specifying the model id, but then feature_type would have to be specified.
Type of features to use for encoding sequences. "SVD" or "PLM". None would require model to be EmbeddingModel or SVDModel.
Type of embedding reduction to use for computing features. E.g. "MEAN" or "SUM". Used only if using EmbeddingModel, and must be non-nil if using an EmbeddingModel. Defaults to None.
Kernel for the GP. One of "linear", "rbf", "matern12", "matern32", "matern52", "periodic", "rational_quadratic". Defaults to "rbf".
periodfloat or None= NonePeriod length, only valid for the "periodic" kernel (must be > 0).
alphafloat or None= NoneScale-mixture parameter, only valid for the "rational_quadratic" kernel (must be > 0).
kwargs= {}Additional keyword arguments to be passed to foundational models, e.g. prompt_id for PoET models.
namestr | None= Nonedescriptionstr | None= NoneThe GP model being fit.
methoddelete_predictor(predictor_id)→boolsource
Delete predictor model.
predictor_idstrThe ID of the predictor.
True: successful deletion
methodensemble(predictors)→PredictorModelsource
Ensemble predictor models together.
predictorslist[PredictorModel]List of predictors to ensemble together.
Ensembled predictor model
19source
Bases: Future
Class providing predict endpoint for fitted predictor models.
Also implements a Future that waits for train job.
sessionAPISessionjobPredictorTrainJob | PredictorEnsembleJob | None= NonemetadataPredictorMetadata | None= Nonepropertyidsource
ID of predictor.
propertynamesource
The name of the predictor.
propertydescriptionsource
The description of the predictor.
methodrename(name=None, description=None)source
Not supported: a predictor's name is set when it is trained.
namestr | None= Nonedescriptionstr | None= Nonepropertyreductionsource
The reduction of the embeddings used to train the predictor, if any.
propertysequence_lengthsource
The sequence length constraint on the predictor, if any.
propertytraining_assay:AssayDatasetsource
The assay the predictor was trained on.
propertytraining_properties:list[str]source
The list of properties the predictor was trained on.
propertymetadatasource
The predictor metadata.
methodget_model()→EmbeddingModel | SVDModel | Nonesource
Retrieve the embeddings or SVD model used to create embeddings to train on.
propertymodel:EmbeddingModel | SVDModel | Nonesource
The embeddings or SVD model used to create embeddings to train on.
methoddelete()→boolsource
Delete this predictor model.
methodget_assay()→AssayDatasetsource
Get assay used for train job.
methodcrossvalidate(n_splits=None)→CVResultFuturesource
Run a crossvalidation on the trained predictor.
n_splitsint= NoneNumber of folds.
Future for the crossvalidation job.
methodpredict(sequences)→PredictionResultFuturesource
Make predictions about the trained properties for a list of sequences.
sequenceslist[bytes] | list[str]propertykernel:TrainedKernelsource
The trained kernel of this GP predictor, in data space.
The first access, including runtime tab completion, may make a request. Failed reads are retried on subsequent access.
Its class follows the kernel type and carries only the hyperparameters that
apply to it: every kernel has an outputscale, every kernel but linear a
lengthscale, periodic a period and rational quadratic an alpha.
404 for an ensemble, or a GP trained before hyperparameters were recorded.
predictor.kernel
PeriodicKernel(outputscale=1.92, lengthscale=0.83, period=2.31)
predictor.kernel.lengthscale
0.83propertymean:float | Nonesource
Constant mean of the GP prior, in the units of the trained property.
404 for an ensemble, or a GP trained before hyperparameters were recorded.
propertynoise:float | Nonesource
Observation noise variance, in the units of the trained property squared.
404 for an ensemble, or a GP trained before hyperparameters were recorded.
methodsingle_site(sequence)→PredictionResultFuturesource
Compute the single-site mutated predictions of a base sequence.
sequencebytes | str19source
Bases: Future
Prediction results represented as a future.
sessionAPISessionjobPredictJob | PredictSingleSiteJob | PredictMultiJob | PredictMultiSingleSiteJobsequenceslist[bytes] | None= Nonepropertyidsource
The unique identifier of the job.
methodget_item(sequence)→tuple[np.ndarray, np.ndarray]source
Get prediction results for specified sequence.
sequencebytessequence to fetch results for
munp.ndarraymeans of sequence prediction
varnp.ndarrayvariances of sequence prediction
propertyargs:dict[str, Any]source
inherited from openprotein.jobs.Future
The registered job arguments.
methodcancelled()→boolsource
inherited from openprotein.jobs.Future
Check if the job has been cancelled.
True if the job is cancelled, False otherwise.
propertycreated_date:datetimesource
inherited from openprotein.jobs.Future
The creation timestamp of the job.
propertydescription:str | Nonesource
inherited from openprotein.jobs.Future
The job's description, or an empty string if the job has none.
methoddone()→boolsource
inherited from openprotein.jobs.Future
Check if the job has completed.
True if the job is done, False otherwise.
propertyend_date:datetime | Nonesource
inherited from openprotein.jobs.Future
The end timestamp of the job.
methodget(verbose=False, **kwargs)→tuple[np.ndarray, np.ndarray]source
inherited from openprotein.jobs.Future
Get prediction results for all sequences.
verbosebool= FalseUnused; present to match the Future._get signature.
munp.ndarraymeans of predictions, one per sequence
varnp.ndarrayvariances of predictions, one per sequence
propertyname:str | Nonesource
inherited from openprotein.jobs.Future
The job's name, or its job id if the job has no name.
propertyprogress_counter:intsource
inherited from openprotein.jobs.Future
The progress counter of the job.
methodrefresh()source
inherited from openprotein.jobs.Future
Refresh the job status and internal job object.
methodrename(name=None, description=None)source
inherited from openprotein.jobs.Future
Set this job's name and description.
Only the arguments given are sent, so renaming leaves the description alone. Extra fields carried on the job are preserved, as on refresh.
namestr | None= Nonedescriptionstr | None= Nonepropertystart_date:datetime | Nonesource
inherited from openprotein.jobs.Future
The start timestamp of the job.
methodwait(interval=5, timeout=None, verbose=False, **kwargs)→Vsource
inherited from openprotein.jobs.Future
Wait for the job to complete, then fetch results.
intervalint= config.POLLING_INTERVALTime in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeoutint | None= NoneMaximum time in seconds to wait. Defaults to None.
verbosebool= FalseVerbosity flag. Defaults to False.
**kwargs= {}Keyword arguments passed to get.
The results of the job.
methodwait_until_done(interval=5, timeout=None, verbose=False)→boolsource
inherited from openprotein.jobs.Future
Wait for the job to complete.
intervalfloat= config.POLLING_INTERVALTime in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeoutint= NoneMaximum time in seconds to wait. Defaults to None.
verbosebool= FalseVerbosity flag. Defaults to False.
True if the job completed successfully.
This method does not fetch the job results, unlike wait().
18source
Bases: Future
Future Job for manipulating results
sessionAPISessionjobJobpropertyidsource
The unique identifier of the job.
propertyargs:dict[str, Any]source
inherited from openprotein.jobs.Future
The registered job arguments.
methodcancelled()→boolsource
inherited from openprotein.jobs.Future
Check if the job has been cancelled.
True if the job is cancelled, False otherwise.
propertycreated_date:datetimesource
inherited from openprotein.jobs.Future
The creation timestamp of the job.
propertydescription:str | Nonesource
inherited from openprotein.jobs.Future
The job's description, or an empty string if the job has none.
methoddone()→boolsource
inherited from openprotein.jobs.Future
Check if the job has completed.
True if the job is done, False otherwise.
propertyend_date:datetime | Nonesource
inherited from openprotein.jobs.Future
The end timestamp of the job.
methodget(verbose=False, **kwargs)→tuple[np.ndarray, np.ndarray, np.ndarray]source
inherited from openprotein.jobs.Future
Get the cross-validation results for this job.
verbosebool= FalseFlag to enable verbose output, by default False.
The observed y and the cross-validated y_mu and y_var of
each evaluated row.
propertyname:str | Nonesource
inherited from openprotein.jobs.Future
The job's name, or its job id if the job has no name.
propertyprogress_counter:intsource
inherited from openprotein.jobs.Future
The progress counter of the job.
methodrefresh()source
inherited from openprotein.jobs.Future
Refresh the job status and internal job object.
methodrename(name=None, description=None)source
inherited from openprotein.jobs.Future
Set this job's name and description.
Only the arguments given are sent, so renaming leaves the description alone. Extra fields carried on the job are preserved, as on refresh.
namestr | None= Nonedescriptionstr | None= Nonepropertystart_date:datetime | Nonesource
inherited from openprotein.jobs.Future
The start timestamp of the job.
methodwait(interval=5, timeout=None, verbose=False, **kwargs)→Vsource
inherited from openprotein.jobs.Future
Wait for the job to complete, then fetch results.
intervalint= config.POLLING_INTERVALTime in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeoutint | None= NoneMaximum time in seconds to wait. Defaults to None.
verbosebool= FalseVerbosity flag. Defaults to False.
**kwargs= {}Keyword arguments passed to get.
The results of the job.
methodwait_until_done(interval=5, timeout=None, verbose=False)→boolsource
inherited from openprotein.jobs.Future
Wait for the job to complete.
intervalfloat= config.POLLING_INTERVALTime in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeoutint= NoneMaximum time in seconds to wait. Defaults to None.
verbosebool= FalseVerbosity flag. Defaults to False.
True if the job completed successfully.
This method does not fetch the job results, unlike wait().
7source
Bases: str, Enum
Kernel options for a GP predictor.
Fitted kernels
See the trained kernels documented with fitted models. Retained predictor reexports: openprotein.predictor.TrainedKernel, openprotein.predictor.LinearKernel, openprotein.predictor.RBFKernel, openprotein.predictor.Matern12Kernel, openprotein.predictor.Matern32Kernel, openprotein.predictor.Matern52Kernel, openprotein.predictor.PeriodicKernel, openprotein.predictor.RationalQuadraticKernel.