<a id="skfolio-factor-exposure-fixedweightedfactor"></a>

# skfolio.factor_exposure.FixedWeightedFactor

<a id="skfolio.factor_exposure.FixedWeightedFactor"></a>

### *class* skfolio.factor_exposure.FixedWeightedFactor(\*, descriptors, family='style', weights=None, min_coverage=0.0, outlier_transformer=None, scoring_transformer=None, transform_by_group=None, n_jobs=1)

Factor exposure as a fixed weighted combination of descriptors.

Computes descriptor values, applies cross-sectional outlier and scoring transforms
to each descriptor, then combines the resulting scores into a single factor exposure
matrix with shape `(n_observations, n_assets)`.

For descriptor $i$, let $s_{i,t,j}$ be its score for observation
$t$ and asset $j$ after the cross-sectional transforms, $w_i$ its
fixed non-negative weight and $V_{t,j}$ the set of descriptors with a finite
score. The weighted composite is:

$$
c_{t,j} = \frac{\sum_{i \in V_{t,j}} w_i \, s_{i,t,j}}
               {\sum_{i \in V_{t,j}} w_i}
$$

Weights are renormalized over available scores for each asset-observation pair.
This allows assets with structurally unavailable descriptor values (e.g., Gross
Margin for financial firms, which do not report cost of goods sold) to receive a
composite score from the remaining descriptors. When all descriptor scores are
non-finite for a pair, the composite is NaN.

The `min_coverage` parameter controls the minimum fraction of total descriptor
weight that must be valid for the composite to be computed. If the valid weight
fraction falls below this threshold, the composite is set to NaN instead. This
guards against low-quality exposures based on too few descriptors.

The default `min_coverage=0.0` uses any available descriptor (no threshold), which
maximizes coverage.  A value of `0.5` requires at least half the descriptor weight
to be valid.

When multiple descriptors are combined and `scoring_transformer` is not
`"passthrough"`, the composite is scored again cross-sectionally so assets with
different descriptor coverage are on the same scale. The final exposure is this
re-scored composite, or the weighted composite when scoring is skipped.

`weights` are fixed inputs and are not learned by this estimator. They can be set
from economic priors or selected by hyperparameter tuning.

* **Parameters:**
  **descriptors** *list of tuple (str, BaseDescriptor)*
  : List of `(name, descriptor)` pairs. Each descriptor computes values from the
    [`AssetPanel`](https://skfolio.org/generated/skfolio.containers.AssetPanel.html.md#skfolio.containers.AssetPanel).

  **family** *str, default=”style”*
  : The factor family this exposure belongs to (e.g., “market”, “style”, “industry”,
    “country”). Factor families group related factors for basket-neutral constraints,
    neutralization, attribution and reporting. The default is `"style"`.

  **weights** *array-like of shape (n_descriptors,), optional*
  : Non-negative descriptor combination weights. Must sum to 1. If `None` (default),
    equal weights are used.

  **min_coverage** *float, default=0.0*
  : Minimum fraction of total descriptor weight that must be finite for the
    composite to be computed. Values where the valid weight fraction is below this
    threshold are set to NaN. Must be in `[0, 1]`.
    - `0.0` (default): use any available descriptor. Maximizes cross-sectional coverage.
    - `0.5`: require at least half the descriptor weight to be valid.
    <br/>
    The threshold is weight-based, not count-based. If descriptor weights are
    `[0.8, 0.2]` and only the first descriptor is valid, the valid weight fraction
    is 0.8, so a `min_coverage=0.5` threshold is satisfied even though only 1 out of
    2 descriptors is present.

  **outlier_transformer** *BaseCSTransformer or “passthrough”, optional*
  : Cross-sectional transformer for outlier handling. If None, defaults to
    `CSWinsorizer()`. Use “passthrough” to skip.

  **scoring_transformer** *BaseCSTransformer or “passthrough”, optional*
  : Cross-sectional transformer for scoring applied after outlier handling.
    If None, defaults to `CSStandardScaler()`. Use “passthrough” to skip.

  **transform_by_group** *str, optional*
  : Name of a categorical characteristic in the AssetPanel to use for group-wise
    transformations. If provided, outlier and scoring transformations are applied
    within each group separately.

  **n_jobs** *int, default=1*
  : Number of parallel jobs for descriptor computation.
* **Attributes:**
  **descriptors_** *list of BaseDescriptor*
  : Fitted descriptor estimators.

  **named_descriptors_** *dict of {str: BaseDescriptor}*
  : Dictionary mapping descriptor names to fitted estimators.

  **outlier_transformer_** *BaseCSTransformer or str*
  : The fitted outlier transformer.

  **scoring_transformer_** *BaseCSTransformer or str*
  : The fitted scoring transformer.

  **n_assets_** *int*
  : Number of assets seen during fitting.

  **asset_names_** *ndarray of shape (n_assets,)*
  : Asset names seen during fitting.

### Methods

| [`fit_transform`](#skfolio.factor_exposure.FixedWeightedFactor.fit_transform)(X[, y])         | Compute factor exposure from a clean descriptor state.   |
|--------------------------------------------------------------------------------|----------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.factor_exposure.FixedWeightedFactor.get_metadata_routing)()        | Return metadata routing for descriptor estimators.       |
| [`get_params`](#skfolio.factor_exposure.FixedWeightedFactor.get_params)([deep])            | Get the parameters of an estimator from the ensemble.    |
| [`partial_fit_transform`](#skfolio.factor_exposure.FixedWeightedFactor.partial_fit_transform)(X[, y]) | Update descriptor state and compute factor exposure.     |
| [`set_params`](#skfolio.factor_exposure.FixedWeightedFactor.set_params)(\*\*params)        | Set the parameters of a factor from the ensemble.        |

<a id="skfolio.factor_exposure.FixedWeightedFactor.fit_transform"></a>

#### fit_transform(X, y=None, \*\*fit_params)

Compute factor exposure from a clean descriptor state.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing “benchmark_weights”, descriptor fields and optional
    grouping fields.

  **y** *None*
  : Ignored. Present for compatibility with scikit-learn’s API.

  **\*\*fit_params** *dict*
  : Additional fit parameters passed to descriptors through metadata routing.
* **Returns:**
  **exposure** *ndarray of shape (n_observations, n_assets)*
  : Fixed-weighted factor exposure.

<a id="skfolio.factor_exposure.FixedWeightedFactor.get_metadata_routing"></a>

#### get_metadata_routing()

Return metadata routing for descriptor estimators.

<a id="skfolio.factor_exposure.FixedWeightedFactor.get_params"></a>

#### get_params(deep=True)

Get the parameters of an estimator from the ensemble.

Returns the parameters given in the constructor as well as the
estimators contained within the `estimators` parameter.

* **Parameters:**
  **deep** *bool, default=True*
  : Setting it to True gets the various estimators and the parameters
    of the estimators as well.
* **Returns:**
  **params** *dict*
  : Parameter and estimator names mapped to their values or parameter
    names mapped to their values.

<a id="skfolio.factor_exposure.FixedWeightedFactor.named_descriptors"></a>

#### *property* named_descriptors

Dictionary to access any fitted factors by name.

* **Returns:**
  `Bunch`

<a id="skfolio.factor_exposure.FixedWeightedFactor.partial_fit_transform"></a>

#### partial_fit_transform(X, y=None, \*\*fit_params)

Update descriptor state and compute factor exposure.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing benchmark weights, descriptor fields and optional
    grouping fields.

  **y** *None*
  : Ignored. Present for compatibility with scikit-learn’s API.

  **\*\*fit_params** *dict*
  : Additional fit parameters passed to descriptors through metadata routing.
* **Returns:**
  **exposure** *ndarray of shape (n_observations, n_assets)*
  : Fixed-weighted factor exposure for the new observations.

<a id="skfolio.factor_exposure.FixedWeightedFactor.set_params"></a>

#### set_params(\*\*params)

Set the parameters of a factor from the ensemble.

Valid parameter keys can be listed with `get_params()`. Note that you
can directly set the parameters of the estimators contained in
`estimators`.

* **Parameters:**
  **\*\*params** *keyword arguments*
  : Specific parameters using e.g.
    `set_params(parameter_name=new_value)`. In addition, to setting the
    parameters of the estimator, the individual estimator of the
    estimators can also be set, or can be removed by setting them to
    ‘drop’.
* **Returns:**
  **self** *object*
  : Estimator instance.

