Skip to content
Snippets Groups Projects
Commit 1177f31f authored by paul.tresson_ird.fr's avatar paul.tresson_ird.fr
Browse files

add UMAP to the requirements and to the support

parent 705bf605
No related branches found
No related tags found
No related merge requests found
......@@ -12,3 +12,4 @@ pyproj >= 3.3
shapely >= 1.7.1
timm >= 0.4.12
joblib >= 1.4.0
umap-learn >= 0.5
......@@ -38,6 +38,7 @@ import torch.nn as nn
import sklearn.decomposition as decomposition
import sklearn.cluster as cluster
import sklearn.manifold as manifold
from umap import UMAP
from sklearn.base import BaseEstimator
from sklearn.preprocessing import StandardScaler
# from sklearn.metrics import silhouette_score, silhouette_samples
......@@ -87,6 +88,27 @@ def get_arguments(module, algorithm_name):
return default_kwargs
def get_umap_kwargs():
# Get the signature of the __init__ method
init_signature = inspect.signature(UMAP.__init__)
# Retrieve the parameters of the __init__ method
parameters = init_signature.parameters
default_kwargs = {}
for param_name, param in parameters.items():
# Skip 'self'
if param_name != "self":
# if param.default == None:
# required_kwargs[param_name] = None # Placeholder for the required value
# else:
default_kwargs[param_name] = param.default
# return required_kwargs, default_kwargs
return default_kwargs
def get_iter(model, fit_raster):
iter = None
if hasattr(model, "partial_fit") and hasattr(model, "max_iter"):
......@@ -448,7 +470,7 @@ class SKAlgorithm(IAMAPAlgorithm):
)
method_opt2 = get_sklearn_algorithms_with_methods(cluster, proj_methods)
method_opt3 = get_sklearn_algorithms_with_methods(manifold, mani_methods)
self.method_opt = method_opt1 + method_opt2 + method_opt3
self.method_opt = method_opt1 + method_opt2 + method_opt3 + ["UMAP"]
self.addParameter(
QgsProcessingParameterNumber(
......@@ -548,6 +570,13 @@ class SKAlgorithm(IAMAPAlgorithm):
parameters["OUTPUT_RASTER"] = self.dst_path
for sk_module in [decomposition, cluster, manifold]:
if self.method_name == "UMAP":
default_args = get_umap_kwargs()
kwargs = self.update_kwargs(default_args)
model = UMAP(**kwargs)
break
try:
default_args = get_arguments(sk_module, self.method_name)
kwargs = self.update_kwargs(default_args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment