示例#1
0
文件: discrete.py 项目: zorrock/Ax
 def _cross_validate(
     self,
     obs_feats: List[ObservationFeatures],
     obs_data: List[ObservationData],
     cv_test_points: List[ObservationFeatures],
 ) -> List[ObservationData]:
     """Make predictions at cv_test_points using only the data in obs_feats
     and obs_data.
     """
     Xs_train, Ys_train, Yvars_train, _ = _convert_observations(
         observation_data=obs_data,
         observation_features=obs_feats,
         outcomes=self.outcomes,
         parameters=self.parameters,
     )
     X_test = [[obsf.parameters[param] for param in self.parameters]
               for obsf in cv_test_points]
     # Use the model to do the cross validation
     f_test, cov_test = self.model.cross_validate(Xs_train=Xs_train,
                                                  Ys_train=Ys_train,
                                                  Yvars_train=Yvars_train,
                                                  X_test=X_test)
     # Convert array back to ObservationData
     return array_to_observation_data(f=f_test,
                                      cov=cov_test,
                                      outcomes=self.outcomes)
示例#2
0
文件: discrete.py 项目: zorrock/Ax
 def _predict(
     self, observation_features: List[ObservationFeatures]
 ) -> List[ObservationData]:
     # Convert observations to array
     X = [[of.parameters[param] for param in self.parameters]
          for of in observation_features]
     f, cov = self.model.predict(X=X)
     # Convert arrays to observations
     return array_to_observation_data(f=f, cov=cov, outcomes=self.outcomes)