pymks/mks_homogenization_model.py
def predict(self, X, periodic_axes=None, confidence_index=None):
        """Predicts macroscopic property for the microstructures `X`.

        Args:
            X (ND array): The microstructure, an `(n_samples, n_x, ...)`
                shaped array where `n_samples` is the number of samples and
                `n_x` is the spatial discretization.
            periodic_axes (list, optional): axes that are periodic. (0, 2)
                would indicate that axes x and z are periodic in a 3D
                microstrucure.
            confidence_index (ND array, optional): array with same shape as X
                used to assign a confidence value for each data point.

        Returns:
            The predicted macroscopic property for `X`.

        Example

        >>> from sklearn.manifold import LocallyLinearEmbedding
        >>> from sklearn.linear_model import BayesianRidge
        >>> from pymks.bases import PrimitiveBasis
        >>> np.random.seed(99)
        >>> X = np.random.randint(2, size=(50, 100))
        >>> y = np.random.random(50)
        >>> reducer = LocallyLinearEmbedding()
        >>> linker = BayesianRidge()
        >>> prim_basis = PrimitiveBasis(2, domain=[0, 1])
        >>> model = MKSHomogenizationModel(prim_basis, n_components=2,
        ...                                dimension_reducer=reducer,
        ...                                property_linker=linker)
        >>> model.fit(X, y)
        >>> X_test = np.random.randint(2, size=(1, 100))

        Predict with microstructures

        >>> y_pred = model.predict(X_test)

        Predict with spatial correlations

        >>> from pymks.stats import correlate
        >>> model.compute_correlations = False
        >>> X_ = prim_basis.discretize(X_test)
        >>> X_corr = correlate(X_, correlations=[(0, 0), (0, 1)])
        >>> y_pred_stats = model.predict(X_corr)
        >>> assert y_pred_stats == y_pred

        """
        if not self._fit:
            raise RuntimeError('fit() method must be run before predict().')
        if self.compute_correlations is True:
            if periodic_axes is None:
                periodic_axes = []
            X = self._correlate(X, periodic_axes, confidence_index)
        X_reshape = self._reduce_shape(X)
        X_reduced = self.dimension_reducer.transform(X_reshape)
        self.reduced_predict_data = X_reduced
        return self._linker.predict(X_reduced)
Predicts macroscopic property for the microstructures `X`.

        Args:
            X (ND array): The microstructure, an `(n_samples, n_x, ...)`
                shaped array where `n_samples` is the number of samples and
                `n_x` is the spatial discretization.
            periodic_axes (list, optional): axes that are periodic. (0, 2)
                would indicate that axes x and z are periodic in a 3D
                microstrucure.
            confidence_index (ND array, optional): array with same shape as X
                used to assign a confidence value for each data point.

        Returns:
            The predicted macroscopic property for `X`.

        Example

        >>> from sklearn.manifold import LocallyLinearEmbedding
        >>> from sklearn.linear_model import BayesianRidge
        >>> from pymks.bases import PrimitiveBasis
        >>> np.random.seed(99)
        >>> X = np.random.randint(2, size=(50, 100))
        >>> y = np.random.random(50)
        >>> reducer = LocallyLinearEmbedding()
        >>> linker = BayesianRidge()
        >>> prim_basis = PrimitiveBasis(2, domain=[0, 1])
        >>> model = MKSHomogenizationModel(prim_basis, n_components=2,
        ...                                dimension_reducer=reducer,
        ...                                property_linker=linker)
        >>> model.fit(X, y)
        >>> X_test = np.random.randint(2, size=(1, 100))

        Predict with microstructures

        >>> y_pred = model.predict(X_test)

        Predict with spatial correlations

        >>> from pymks.stats import correlate
        >>> model.compute_correlations = False
        >>> X_ = prim_basis.discretize(X_test)
        >>> X_corr = correlate(X_, correlations=[(0, 0), (0, 1)])
        >>> y_pred_stats = model.predict(X_corr)
        >>> assert y_pred_stats == y_pred

        
Predicts macroscopic property for the microstructures `X`.
Predicts macroscopic property for the microstructures ` X ` .
def predict(self, X, periodic_axes=None, confidence_index=None):
        if not self._fit:
            raise RuntimeError('fit() method must be run before predict().')
        if self.compute_correlations is True:
            if periodic_axes is None:
                periodic_axes = []
            X = self._correlate(X, periodic_axes, confidence_index)
        X_reshape = self._reduce_shape(X)
        X_reduced = self.dimension_reducer.transform(X_reshape)
        self.reduced_predict_data = X_reduced
        return self._linker.predict(X_reduced)
def predict ( self , X , periodic_axes = None , confidence_index = None ) : if not self . _fit : raise RuntimeError ( 'fit() method must be run before predict().' ) if self . compute_correlations is True : if periodic_axes is None : periodic_axes = [ ] X = self . _correlate ( X , periodic_axes , confidence_index ) X_reshape = self . _reduce_shape ( X ) X_reduced = self . dimension_reducer . transform ( X_reshape ) self . reduced_predict_data = X_reduced return self . _linker . predict ( X_reduced )
Predicts macroscopic property for the microstructures `X`.
Predicts macroscopic property for the microstructures ` X ` .
"""Predicts macroscopic property for the microstructures `X`.

        Args:
            X (ND array): The microstructure, an `(n_samples, n_x, ...)`
                shaped array where `n_samples` is the number of samples and
                `n_x` is the spatial discretization.
            periodic_axes (list, optional): axes that are periodic. (0, 2)
                would indicate that axes x and z are periodic in a 3D
                microstrucure.
            confidence_index (ND array, optional): array with same shape as X
                used to assign a confidence value for each data point.

        Returns:
            The predicted macroscopic property for `X`.

        Example

        >>> from sklearn.manifold import LocallyLinearEmbedding
        >>> from sklearn.linear_model import BayesianRidge
        >>> from pymks.bases import PrimitiveBasis
        >>> np.random.seed(99)
        >>> X = np.random.randint(2, size=(50, 100))
        >>> y = np.random.random(50)
        >>> reducer = LocallyLinearEmbedding()
        >>> linker = BayesianRidge()
        >>> prim_basis = PrimitiveBasis(2, domain=[0, 1])
        >>> model = MKSHomogenizationModel(prim_basis, n_components=2,
        ...                                dimension_reducer=reducer,
        ...                                property_linker=linker)
        >>> model.fit(X, y)
        >>> X_test = np.random.randint(2, size=(1, 100))

        Predict with microstructures

        >>> y_pred = model.predict(X_test)

        Predict with spatial correlations

        >>> from pymks.stats import correlate
        >>> model.compute_correlations = False
        >>> X_ = prim_basis.discretize(X_test)
        >>> X_corr = correlate(X_, correlations=[(0, 0), (0, 1)])
        >>> y_pred_stats = model.predict(X_corr)
        >>> assert y_pred_stats == y_pred

        """
The predicted macroscopic property for `X`.
The predicted macroscopic property for ` X ` .
self
X
The microstructure, an `(n_samples, n_x, ...)`
shaped array where `n_samples` is the number of samples and
`n_x` is the spatial discretization.
The microstructure an ` ( n_samples n_x ... ) ` shaped array where ` n_samples ` is the number of samples and ` n_x ` is the spatial discretization .
periodic_axes
axes that are periodic. (0, 2)
would indicate that axes x and z are periodic in a 3D
microstrucure.
axes that are periodic . ( 0 2 ) would indicate that axes x and z are periodic in a 3D microstrucure .
confidence_index
array with same shape as X
used to assign a confidence value for each data point.
array with same shape as X used to assign a confidence value for each data point .