Regression ===================== .. automodule:: remote_sensing_processor.regression :members: generate_tiles, train, test, generate_map, band_importance :show-inheritance: List of available NN models --------------------------- .. list-table:: Supported ML Models :widths: 25 50 25 :header-rows: 1 * - Model Name - Backbone - Reference * - BEiT - Not available - `Huggingface Transformers `_ * - Data2Vec - Not available - `Huggingface Transformers `_ * - DPT - Not available - `Huggingface Transformers `_ * - MobileNetV2 - Not available - `Huggingface Transformers `_ * - MobileViT - Not available - `Huggingface Transformers `_ * - MobileViTV2 - Not available - `Huggingface Transformers `_ * - SegFormer - Not available - `Huggingface Transformers `_ * - UperNet - See Transformers backbones - `Huggingface Transformers `_ * - DeepLabV3 - "MobileNet_V3_Large", "ResNet50", "ResNet101" - `Torchvision `_ * - FCN - "ResNet50", "ResNet101" - `Torchvision `_ * - LRASPP - Not available - `Torchvision `_ * - UNet - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - UNet++ - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - FPN - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - PSPNet - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - DeepLabV3_smp - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - DeepLabV3+ - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - Linknet - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - MAnet - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - PAN - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - UperNet_smp - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - SegFormer_smp - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - DPT_smp - `SMP `_ and `TIMM `_ - `Segmentation Models Pytorch `_ * - FarSeg - "resnet18", "resnet34", "resnet50", "resnet101" - `TorchGeo `_ Transformers backbones are: - BEiT - BiT - ConvNeXT - ConvNeXTV2 - DiNAT - DINOV2 - DINOV2WithRegisters - DINOV3ViT - DINOV3ConvNeXT - FocalNet - HGNet-V2 - Hiera - LW-DETR - MaskFormer-Swin - Pixio - PVTV2 - ResNet - RT-DETR-ResNet - Swin - SwinV2 - ViTDet - Any TIMM backbone (experimental support) You can fine-tune pre-trained model by defining ``weights``. For models from Transformers you can get available weights from `Huggingface Hub `_, for Torchvision models you just set ``weights = True``. ``rsp.segmentation.train`` also saves CSV and Tensorboard logs in directory where checkpoint file is saved. DiNAT backbone require ``natten`` library, that is not available on Windows and Mac and not available via Conda. RSP supports DiNAT backbone, but you need to install ``natten`` in your python env manually. List of available Scikit-learn models ------------------------------------- .. list-table:: Supported Scikit-Learn Models :widths: 20 40 20 20 :header-rows: 1 * - Model Name - Kernel/solver - Warm start - Reference * - Linear Regression - Not available - Not supported - `Scikit-learn `_ * - Ridge - Not available - Not supported - `Scikit-learn `_ * - Bayesian Ridge - Not available - Not supported - `Scikit-learn `_ * - Lasso - Not available - Supported - `Scikit-learn `_ * - Multitask Lasso - Not available - Supported - `Scikit-learn `_ * - Lars - Not available - Not supported - `Scikit-learn `_ * - LassoLars - Not available - Not supported - `Scikit-learn `_ * - LassoLarsIC - Not available - Not supported - `Scikit-learn `_ * - ElasticNet - Not available - Not supported - `Scikit-learn `_ * - Multitask ElasticNet - Not available - Supported - `Scikit-learn `_ * - Orthogonal Matching Pursuit - Not available - Not supported - `Scikit-learn `_ * - ARD - Not available - Not supported - `Scikit-learn `_ * - Huber - Not available - Supported - `Scikit-learn `_ * - RANSAC - Not available - Not supported - `Scikit-learn `_ * - Theil-Sen - Not available - Not supported - `Scikit-learn `_ * - Gamma - "lbfgs", "newton-cholesky" - Supported - `Scikit-learn `_ * - Poisson - "lbfgs", "newton-cholesky" - Supported - `Scikit-learn `_ * - Tweedie - "lbfgs", "newton-cholesky" - Supported - `Scikit-learn `_ * - SGD - "squared_error", "huber", "epsilon_insensitive", "squared_epsilon_insensitive" - Supported - `Scikit-learn `_ * - Nearest Neighbors - Not available - Not supported - `Scikit-learn `_ * - Radius Neighbors - Not available - Not supported - `Scikit-learn `_ * - SVM - "rbf", "linear", "poly", "sigmoid" - Not supported - `Scikit-learn `_ * - Gaussian Process - Not available - Not supported - `Scikit-learn `_ * - Decision Tree - Not available - Not supported - `Scikit-learn `_ * - Extra Tree - Not available - Not supported - `Scikit-learn `_ * - Random Forest - Not available - Supported - `Scikit-learn `_ * - Extra Trees - Not available - Supported - `Scikit-learn `_ * - AdaBoost - Not available - Not supported - `Scikit-learn `_ * - Gradient Boosting - Not available - Supported - `Scikit-learn `_ * - Multilayer Perceptron - "adam", "sgd", "lbfgs" - Supported - `Scikit-learn `_ * - XGBoost - Not available - Not supported - `XGBoost `_ * - XGB Random Forest - Not available - Not supported - `XGBoost `_ Model kernel or solver is defined with ``backbone`` argument. Models that support warm start can be fine-tuned using pre-trained models with ``checkpoint`` argument. Some models can have issues while saving, especially when trained on big datasets. Some models (like SVM) can train for a very long time or (like Gaussian process) can have memory issues with big datasets. So we recommend using Scikit-learn models only for small datasets. For Random Forest and Extra Trees models ``max_depth`` is by default set to 6, because it is unlimited by default and the training could be very slow. To train with unlimited tree depth ``set max_depth = None``. List of available losses ------------------------ .. list-table:: Supported loss functions :widths: 50 50 :header-rows: 1 * - Loss - Reference * - mse - `Torch `_ * - mae - `Torch `_ You can also use your custom loss. It can be useful if you want to initialize a loss with custom parameters. You also can pass any custom function as a loss. The only limit - it must inherit ``torch.nn.modules.loss._Loss``. .. code-block:: python # Here we just use one of the default losses loss = "mae" # Here we initialize a loss that is already supported, but set the custom parameters loss = torch.nn.MSELoss(reduction="sum") # And here we use the loss that is not supported by default loss = torch.nn.modules.loss.SmoothL1Loss() # And here we create our own custom loss function class XTanhLoss(_Loss): def __init__(self): super().__init__() def forward(self, y_t, y_prime_t): ey_t = y_t - y_prime_t return torch.mean(ey_t * torch.tanh(ey_t)) loss = XTanhLoss() List of available metrics ------------------------- .. list-table:: Supported metrics :widths: 40 30 30 :header-rows: 1 * - Metric - Additional parameters - Reference * - concordance_correlation_coefficient - None - `Torchmetrics `_ * - cosine_similarity - None - `Torchmetrics `_ * - critical_success_index - threshold=0.5 - `Torchmetrics `_ * - explained_variance - None - `Torchmetrics `_ * - kendall_rank_correlation_coefficient_a - variant="a" - `Torchmetrics `_ * - kendall_rank_correlation_coefficient_b - variant="b" - `Torchmetrics `_ * - kendall_rank_correlation_coefficient_c - variant="c" - `Torchmetrics `_ * - kl_divergence - None - `Torchmetrics `_ * - log_cosh_error - None - `Torchmetrics `_ * - mae - None - `Torchmetrics `_ * - mape - None - `Torchmetrics `_ * - mse - squared=True - `Torchmetrics `_ * - msle - None - `Torchmetrics `_ * - manhattan_distance - p=1 - `Torchmetrics `_ * - euclidean_distance - p=2 - `Torchmetrics `_ * - minkowski_distance_3 - p=1 - `Torchmetrics `_ * - minkowski_distance_10 - p=10 - `Torchmetrics `_ * - minkowski_distance_100 - p=100 - `Torchmetrics `_ * - nrmse - None - `Torchmetrics `_ * - pearson_correlation_coefficient - None - `Torchmetrics `_ * - r2 - None - `Torchmetrics `_ * - rse - squared=True - `Torchmetrics `_ * - rmse - squared=False - `Torchmetrics `_ * - rrse - squared=False - `Torchmetrics `_ * - spearman_correlation_coefficient - None - `Torchmetrics `_ * - smape - None - `Torchmetrics `_ * - tweedie_deviance_score - None - `Torchmetrics `_ * - weighted_mape - None - `Torchmetrics `_ You also can use any custom metric for evaluation. The only limit - it must inherit ``torchmetrics.metric.Metric``. .. code-block:: python # A custom metric (top-2 accuracy) - a supported metric, but with custom parameter - ``top-k=2`` # Don't forget to set task, num_classes and ignore_index distance4 = torchmetrics.MinkowskiDistance(4) metrics=[ {"name": "r2", "log": "verbose"}, # Supported metric, logged on each step and printed in the progress bar {"name": "rmse", "log": "step"}, # Supported metric, logged each step and saved to logs {"name": "kendall_rank_correlation_coefficient_a", "log": "epoch"}, # Supported metric, logged each epoch and saved to logs {"name": "minkowski_distance_4", "metric": distance4, "log": "verbose"}, # A custom metric ] Supported augmentations ----------------------- .. list-table:: Supported augmentations :widths: 40 30 30 :header-rows: 1 * - Augmentation - Additional parameters - Reference * - ScaleJitter - None - `Torchvision `_ * - RandomResizedCrop - antialias=True - `Torchvision `_ * - RandomHorizontalFlip - p=0.5 - `Torchvision `_ * - RandomVerticalFlip - p=0.5 - `Torchvision `_ * - RandomZoomOut - None - `Torchvision `_ * - RandomRotation - degrees=90 - `Torchvision `_ * - RandomAffine - degrees=90, translate=(0.5, 0.5), shear=0.5 - `Torchvision `_ * - RandomPerspective - None - `Torchvision `_ * - ElasticTransform - None - `Torchvision `_ * - GaussianBlur - kernel_size=(5, 9) - `Torchvision `_ If you just pass ``augment=True``, RSP will use a default sequence of augmentations: ("RandomResizedCrop", "RandomHorizontalFlip"). You can pass your own sequence of augmentations, they will be applied to data in the given order. You can use both supported augmentation names or custom augmentations. You can use any custom augmentations, but they must inherit ``torchvision.transforms.v2.Transform``. .. code-block:: python augment = ( "RandomResizedCrop", # Supported augmentation name v2.ScaleJitter(target_size=(128, 128), scale_range=(0.5, 1.5)) # Custom augmentation - a supported one with custom parameter v2.RandomRotation(45, fill={tv_tensors.Image: 0, tv_tensors.Mask: 0}) # Custom augmentation - a supported one with custom parameter v2.RandomSolarize(), # Custom augmentation - not supported by default, works only with 3-channel images )