# transform

Transform predictors into extracted features

## Syntax

``z = transform(Mdl,x)``

## Description

example

````z = transform(Mdl,x)` transforms the data `x` into the features `z` via the model `Mdl`.```

## Examples

collapse all

Create a feature transformation model with 100 features from the `SampleImagePatches` data.

```rng('default') % For reproducibility data = load('SampleImagePatches'); q = 100; X = data.X; Mdl = sparsefilt(X,q)```
```Warning: Solver LBFGS was not able to converge to a solution. ```
```Mdl = SparseFiltering ModelParameters: [1x1 struct] NumPredictors: 363 NumLearnedFeatures: 100 Mu: [] Sigma: [] FitInfo: [1x1 struct] TransformWeights: [363x100 double] InitialTransformWeights: [] Properties, Methods ```

`sparsefilt` issues a warning because it stopped due to reaching the iteration limit, instead of reaching a step-size limit or a gradient-size limit. You can still use the learned features in the returned object by calling the `transform` function.

Transform the first five rows of the input data `X` to the new feature space.

```y = transform(Mdl,X(1:5,:)); size(y)```
```ans = 1×2 5 100 ```

## Input Arguments

collapse all

Feature extraction model, specified as a `SparseFiltering` object or as a `ReconstructionICA` object. Create `Mdl` by using the `sparsefilt` function or the `rica` function.

Predictor data, specified as a matrix with `p` columns or as a table of numeric values with `p` columns. Here, `p` is the number of predictors in the model, which is `Mdl.NumPredictors`. Each row of the input matrix or table represents one data point to transform.

Data Types: `single` | `double` | `table`

## Output Arguments

collapse all

Transformed data, returned as an `n`-by-`q` matrix. Here, `n` is the number of rows in the input data `x`, and `q` is the number of features, which is `Mdl.NumLearnedFeatures`.

## Algorithms

`transform` converts data to predicted features by using the learned weight matrix `W` to map input predictors to output features.

• For `rica`, input data `X` maps linearly to output features `XW`. See Reconstruction ICA Algorithm.

• For `sparsefilt`, input data maps nonlinearly to output features $\stackrel{^}{F}$(`X`,`W`). See Sparse Filtering Algorithm.

Caution

The result of `transform` for sparse filtering depends on the number of data points. In particular, the result of applying `transform` to each row of a matrix separately differs from the result of applying `transform` to the entire matrix at once.