oraclesai.pipeline

class SpatialColumnTransformer(transformers, *, remainder='drop', sparse_threshold=0.3, n_jobs=None, transformer_weights=None, verbose=False, verbose_feature_names_out=True)

A spatial version of the scikit-learn class ColumnTransformer that can contain spatial estimator steps. It applies transformations to different subsets of columns and concatenates the results.

fit(X, y=None, **fit_params)

Calls the fit method of all the transformers using the corresponding column subset.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

self. Fitted estimator.

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

Fits all the transformers using the corresponding column subset and concatenates the results.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The transformed and concatenated data.

property named_estimators

Returns a list of tuples in the form (name, Transformer)

transform(X, y=None, **transform_params)

Calls the transform method of each transformer using the corresponding column subset and concatenate the results.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The transformed and concatenated data.

class SpatialFeatureUnion(transformer_list, *, n_jobs=None, transformer_weights=None, verbose=False)

A spatial version of the scikit-learn FeatureUnion class that can take spatial estimator steps.

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

Fits all the transformers, transforms the data, and concatenates the results.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The transformed and concatenated data.

property named_estimators

Returns a list with all the transformers

transform(X, **transform_params)

Transforms X separately by each transformer and concatenates the results.

Parameters:

X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

Returns:

The transformed and concatenated data.

class SpatialPipeline(steps, memory=None, verbose=False)

A SpatialPipeline is like a scikit-learn pipeline, but it also can contain spatial estimators which accept a spatial column and may use or compute spatial information such as spatial weights objects. A SpatialPipeline and other composite spatial estimators such as SpatialFeatureUnion and SpatialColumnTransformer, can work directly with a SpatialDataFrame or GeoPandas’ GeoDataFrame and deliver the right information to its steps, that is, spatial data will be passed only to spatial estimators while it will be omitted for regular, non-spatial estimators. In practice a spatial pipeline and other composite spatial estimators look and work exactly as a regular scikit-learn pipeline, except that, for its fit, transform and predict methods (and variations of these methods), X parameter can also be of type SpatialDataFrame or GeoPandas GeoDataFrame. Additionally, it accepts a well-defined set of spatial parameters which can be passed to the appropriate spatial estimators in the pipeline.

  • geometries: A 1D array of shapely geometries. Not needed when X is a spatial type.

  • crs: A string or PyProj CRS. This information can be extracted from X when it is a spatial type.

  • spatial_weights_definition: a SpatiaWeightsDefinition object.

  • spatial_weights: A SpatialWeights object or a PySAL weights object.

  • spatial_index: A spatial index for geometries.

fit(X, y=None, **fit_params)

Fits all the transformers in the pipeline, one after the other, and finally, calls the fit method of the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The output from the fit method of the final estimator.

fit_predict(X, y=None, **fit_params)

Fits all the transformers in the pipeline, one after the other. Finally, it calls the fit_predict of the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The output of the predict method of the final estimator.

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

Fits all the transformers in the pipeline, one after the other. Then it transforms the data with the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The output from the transform method of the final estimator.

property named_estimators

Returns all the steps in the pipeline

predict(X, y=None, **predict_params)

Calls the transform method of each transformer in the pipeline. Then it calls the predict method of the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The output of the predict method of the final estimator.

score(X, y, sample_weight=None, **score_params)

Calls the transform method of each transformer in the pipeline. Then it calls the score method of the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

  • sample_weight – Weighted contribution to the score for each sample.

Returns:

The output of the score method of the final estimator.

transform(X, y=None, **transform_params)

Transforms the data by calling the transform method of each transformer in the pipeline. The result is the transformed data from the final estimator.

Parameters:
  • X – SpatialDataFrame, geopandas.GeoDataFrame, pandas.DataFrame or numpy 2D array.

  • y – (Default=None) pandas.DataFrame, numpy 1D array or string. If specified as string, X is expected to be a DataFrame.

Returns:

The output from the transform method of the final estimator.