GrowingTubeModel#

class ktch.coiling.GrowingTubeModel(r0: float = 1.0, method: str = 'ode', estimator: str = 'nls_3d', n_jobs: int | None = None, verbose: int = 0)[source]#

Growing tube model.

The growing tube model [Okamoto_1988]. inverse_transform is the generative map Phi: (e_g, c_g, t_g, delta_g, gamma_g) -> form. transform estimates the parameters from measured shells ("nls_3d") or, symmetrically, from a structured surface ("surface").

Parameters:
r0float, default = 1.0

Initial tube radius (scale) used for generation.

method{“ode”, “closed”}, default = “ode”

Forward solver passed to growing_tube().

estimator{“nls_3d”, “surface”}, default = “nls_3d”

Estimation method used by transform. "nls_3d" fits the centerline and radius from a per-point (x, y, z, r) panel. "surface" fits the generative map directly to a structured surface panel (the coordinate output of inverse_transform), recovering the aperture orientation (delta_g, gamma_g) as well; it is consistent with inverse_transform (transform(inverse_transform(params)) ~= params).

n_jobsint, optional

Number of jobs for the per-specimen estimation in transform.

verboseint, default = 0

Verbosity level.

References

[Okamoto_1988]

Okamoto, T., 1988. Analysis of heteromorph ammonoids by differential geometry. Palaeontology 31, 35–52.

fit(X, y=None)[source]#

No-op (stateless). Returns self.

fit_transform(X, y=None, domain_coords=None, aperture=None)[source]#

Fit and transform in one step.

Overridden to support metadata routing of domain_coords, aperture.

get_feature_names_out(input_features=None) ndarray[source]#

Parameter names (e_g, c_g, t_g, delta_g, gamma_g).

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

inverse_transform(X_transformed, s_range=None, phi_range=None, aperture=None, as_frame=False)[source]#

Generate shell surfaces from growing tube parameters.

Parameters:
X_transformedarray-like of shape (n_samples, 5) or (5,)

Rows of (e_g, c_g, t_g, delta_g, gamma_g). A 3-column input (e_g, c_g, t_g) is also accepted, with orientation defaulted to 0. e_g is the logarithm of the original \(E\) described in [Okamoto_1988] ([Noshita_2014]).

s_range, phi_rangearray-like, optional

Sampling grids. See growing_tube().

apertureNone

Aperture shape; only the circular default is supported.

as_framebool, default = False

If True, return a long-format pandas.DataFrame.

Returns:
Xndarray of shape (n_samples, n_s, n_phi, 3) or pd.DataFrame

References

[Okamoto_1988]

Okamoto, T., 1988. Analysis of heteromorph ammonoids by differential geometry. Palaeontology 31, 35–52.

[Noshita_2014]

Noshita, K., 2014. Quantification and geometric analysis of coiling patterns in gastropod shells based on 3D and 2D image data. Journal of Theoretical Biology 363, 93–104.

set_inverse_transform_request(*, X_transformed: bool | None | str = '$UNCHANGED$', aperture: bool | None | str = '$UNCHANGED$', as_frame: bool | None | str = '$UNCHANGED$', phi_range: bool | None | str = '$UNCHANGED$', s_range: bool | None | str = '$UNCHANGED$') GrowingTubeModel#

Configure whether metadata should be requested to be passed to the inverse_transform method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to inverse_transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to inverse_transform.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
X_transformedstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for X_transformed parameter in inverse_transform.

aperturestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for aperture parameter in inverse_transform.

as_framestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for as_frame parameter in inverse_transform.

phi_rangestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for phi_range parameter in inverse_transform.

s_rangestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for s_range parameter in inverse_transform.

Returns:
selfobject

The updated object.

set_output(*, transform=None)#

Set output container.

Refer to the user guide for more details and Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

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:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

set_transform_request(*, aperture: bool | None | str = '$UNCHANGED$', domain_coords: bool | None | str = '$UNCHANGED$') GrowingTubeModel#

Configure whether metadata should be requested to be passed to the transform method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
aperturestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for aperture parameter in transform.

domain_coordsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for domain_coords parameter in transform.

Returns:
selfobject

The updated object.

transform(X, domain_coords=None, aperture=None)[source]#

Estimate growing tube parameters from measured shells.

Parameters:
Xlist of array-like, ndarray, or DataFrame

The input panel; its encoding depends on estimator. For "nls_3d", a per-specimen panel of (n_points_i, 4) centroid-and-thickness sequences (x, y, z, r) (see ktch.coiling._panel._check_panel()). For "surface", a panel of (n_s, n_phi, 3) structured surfaces (see ktch.coiling._panel._check_surface_panel()).

domain_coordslist of array-like, optional

Per-point arc length l (for example from an external arc-length refinement), used by "nls_3d" only. When omitted, a tentative cumulative chord length is used.

apertureNone

Aperture shape; only the circular default is supported.

Returns:
X_transformedndarray of shape (n_samples, 5)

Estimated (e_g, c_g, t_g, delta_g, gamma_g). The "nls_3d" estimator returns zeros for the orientation columns; the "surface" estimator recovers them.