<a id="skfolio-descriptor-earningstoprice"></a>

# skfolio.descriptor.EarningsToPrice

<a id="skfolio.descriptor.EarningsToPrice"></a>

### *class* skfolio.descriptor.EarningsToPrice

Earnings-to-price ratio descriptor.

Computes the ratio of trailing twelve-month net income to market capitalization:

$$
\text{earnings\_to\_price}(t) =
\frac{\text{net\_income\_ttm}(t)}{\text{market\_cap}(t)}
$$

This is the inverse of the price-to-earnings (P/E) ratio and measures how much
profit a firm generates per unit of market value. A high ratio identifies firms with
strong current profitability relative to their price [[1]](#r8379f77a43fa-1). Unlike [`BookToPrice`](https://skfolio.org/generated/skfolio.descriptor.BookToPrice.html.md#skfolio.descriptor.BookToPrice),
which is based on the balance sheet, this descriptor is based on the income
statement, capturing a distinct dimension of value.

This descriptor can be negative for loss-making firms, which is economically
meaningful (unlike P/E, which becomes uninterpretable for negative earnings).

`net_income_ttm` should represent net income available to common shareholders when
the data source distinguishes common and preferred claims. This is consistent with
`market_cap`, which reflects common equity.

This descriptor uses aggregate quantities (total net income divided by total market
capitalization) rather than per-share quantities (earnings per share divided by
price). The two are mathematically equivalent when EPS and price use the same
split-adjustment basis:

$$
\frac{\text{net\_income\_ttm}}{\text{market\_cap}}
= \frac{\text{eps\_ttm}}{\text{price}}
$$

The aggregate form is preferred because it avoids subtle split-adjustment mismatches
between numerator and denominator. Aggregate fundamentals are the primary form from
data providers. Per-share quantities are derived from them.

* **Parameters:**
  **None**
* **Attributes:**
  **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.descriptor.EarningsToPrice.fit_transform)(X[, y])         | Compute trailing earnings-to-price ratios.     |
|--------------------------------------------------------------------------------|------------------------------------------------|
| [`get_metadata_routing`](#skfolio.descriptor.EarningsToPrice.get_metadata_routing)()        | Get metadata routing of this object.           |
| [`get_params`](#skfolio.descriptor.EarningsToPrice.get_params)([deep])            | Get parameters for this estimator.             |
| [`partial_fit_transform`](#skfolio.descriptor.EarningsToPrice.partial_fit_transform)(X[, y]) | Stateless class delegation to `fit_transform`. |
| [`set_params`](#skfolio.descriptor.EarningsToPrice.set_params)(\*\*params)        | Set the parameters of this estimator.          |

### References

* <a id='r8379f77a43fa-1'>**[1]**</a> “Investment performance of common stocks in relation to their price-earnings ratios: A test of the efficient market hypothesis” The Journal of Finance. Basu, S. (1977).

### Examples

```pycon
>>> from skfolio.datasets import make_synthetic_characteristics
>>> from skfolio.descriptor import EarningsToPrice
>>>
>>> X = make_synthetic_characteristics()
>>>
>>> descriptor = EarningsToPrice()
>>> earnings_to_price = descriptor.fit_transform(X)
```

<a id="skfolio.descriptor.EarningsToPrice.fit_transform"></a>

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

Compute trailing earnings-to-price ratios.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing `net_income_ttm` and `market_cap`.

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

  **\*\*fit_params** *dict*
  : Additional fit parameters. Ignored.
* **Returns:**
  **earnings_to_price** *ndarray of shape (n_observations, n_assets)*
  : Earnings-to-price ratio for each observation and asset.

<a id="skfolio.descriptor.EarningsToPrice.get_metadata_routing"></a>

#### get_metadata_routing()

Get metadata routing of this object.

Please check [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

* **Returns:**
  **routing** *MetadataRequest*
  : A `MetadataRequest` encapsulating
    routing information.

<a id="skfolio.descriptor.EarningsToPrice.get_params"></a>

#### get_params(deep=True)

Get parameters for this estimator.

* **Parameters:**
  **deep** *bool, default=True*
  : If True, will return the parameters for this estimator and
    contained subobjects that are estimators.
* **Returns:**
  **params** *dict*
  : Parameter names mapped to their values.

<a id="skfolio.descriptor.EarningsToPrice.partial_fit_transform"></a>

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

Stateless class delegation to `fit_transform`.

<a id="skfolio.descriptor.EarningsToPrice.set_params"></a>

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

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects
(such as `Pipeline`). The latter have
parameters of the form `<component>__<parameter>` so that it’s
possible to update each component of a nested object.

* **Parameters:**
  **\*\*params** *dict*
  : Estimator parameters.
* **Returns:**
  **self** *estimator instance*
  : Estimator instance.

