oraclesai.pipeline
- class SpatialColumnTransformer(transformers, *, remainder='drop', sparse_threshold=0.3, n_jobs=None, transformer_weights=None, verbose=False, verbose_feature_names_out=True, force_int_remainder_cols=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
fitmethod 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
transformmethod 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, verbose_feature_names_out=True)
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),
Xparameter 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
Xis a spatial type.crs: A string or PyProj CRS. This information can be extracted from
Xwhen 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
fitmethod 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,
Xis expected to be a DataFrame.
- Returns:
The output from the
fitmethod 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_predictof 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
predictmethod 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,
Xis expected to be a DataFrame.
- Returns:
The output from the
transformmethod of the final estimator.
- property named_estimators
Returns all the steps in the pipeline
- predict(X, y=None, **predict_params)
Calls the
transformmethod of each transformer in the pipeline. Then it calls thepredictmethod 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
predictmethod of the final estimator.
- score(X, y, sample_weight=None, **score_params)
Calls the
transformmethod of each transformer in the pipeline. Then it calls thescoremethod 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
scoremethod 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,
Xis expected to be a DataFrame.
- Returns:
The output from the
transformmethod of the final estimator.