LGMFidelityTrainer
QuICT.qcda.utility.fidelity_estimator.lgm_fidelity_trainer.LGMFidelityTrainer ¶
A trainer for training LGMFidelityEstimator. All cached data are saved in self.temp. Args: vqm(VirtualQuantumMachine): desired vqm to estimate step(int): step of path in estimator
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
clear_cache ¶
estimate_cached_test ¶
Estimate the cached test and return the predictions, together with true labels. Returns: (ndarray, ndarray): (predictions, true labels)
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
fit ¶
fit(data=None, save=False, file_path=None, file_prefix=None, cross_validate=False, fold=5, best_score=0.0, mapping: List[int] = None, criterion=mean_squared_error, **kwargs)
To fit estimator with given data, or cached data if input data is None. You can specify the criterion and best score of this criterion. Args: data(List): data for fitting. Please set None if using preprocessed. save(bool): save the model or not. file_path(str): path of files to save. Default as ./models file_prefix(str): prefix of files to save. cross_validate(bool): use cross validate or not. fold(int): fold in cross validate. best_score(float): best score of the criterion. You can set None, but should consist of labels. criterion(func): the criterion of test data. mapping(List[int]): mapping of qubits **kwargs: args in LightGBM, optional to tune. Returns: criterion(test_labels, prediction) if there are test data or None otherwise.
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
load_cached_data ¶
Load temp files from given path and prefix. Args: file_path(str): path of files file_prefix(str): prefix of files
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
load_estimator ¶
Load a fidelity estimator from given path and prefix. Args: file_path(str): path of files file_prefix(str): prefix of files
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
preprocess_data ¶
Preprocess the data and save into memories to avoid computing features repeatedly Args: data(List): data for preprocessing, should consist of labels mapping(List[int]): mapping of qubits is_train(bool): is the data for train or test
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
save_cached_data ¶
Save temp files to given path and prefix. Args: file_path(str): path of files file_prefix(str): prefix of files
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
save_estimator ¶
Save a fidelity estimator to given path and prefix. Args: file_path(str): path of files file_prefix(str): prefix of files
Source code in QuICT/qcda/utility/fidelity_estimator/lgm_fidelity_trainer.py
shuffle_data ¶
Shuffle the preprocessed data Args: mixed(bool): mix the test data and train data or not. The sizes are maintained. If not test data, this is automatically set as False.