snowflake.ml.modeling.neighbors.NeighborhoodComponentsAnalysis

class snowflake.ml.modeling.neighbors.NeighborhoodComponentsAnalysis(*, n_components=None, init='auto', warm_start=False, max_iter=50, tol=1e-05, callback=None, verbose=0, random_state=None, input_cols: Optional[Union[str, Iterable[str]]] = None, output_cols: Optional[Union[str, Iterable[str]]] = None, label_cols: Optional[Union[str, Iterable[str]]] = None, drop_input_cols: Optional[bool] = False, sample_weight_col: Optional[str] = None)

Bases: BaseTransformer

Neighborhood Components Analysis For more details on this class, see sklearn.neighbors.NeighborhoodComponentsAnalysis

n_components: int, default=None

Preferred dimensionality of the projected space. If None it will be set to n_features.

init: {‘auto’, ‘pca’, ‘lda’, ‘identity’, ‘random’} or ndarray of shape (n_features_a, n_features_b), default=’auto’

Initialization of the linear transformation. Possible options are ‘auto’, ‘pca’, ‘lda’, ‘identity’, ‘random’, and a numpy array of shape (n_features_a, n_features_b).

  • ‘auto’

    Depending on n_components, the most reasonable initialization will be chosen. If n_components <= n_classes we use ‘lda’, as it uses labels information. If not, but n_components < min(n_features, n_samples), we use ‘pca’, as it projects data in meaningful directions (those of higher variance). Otherwise, we just use ‘identity’.

  • ‘pca’

    n_components principal components of the inputs passed to fit() will be used to initialize the transformation. (See PCA)

  • ‘lda’

    min(n_components, n_classes) most discriminative components of the inputs passed to fit() will be used to initialize the transformation. (If n_components > n_classes, the rest of the components will be zero.) (See LinearDiscriminantAnalysis)

  • ‘identity’

    If n_components is strictly smaller than the dimensionality of the inputs passed to fit(), the identity matrix will be truncated to the first n_components rows.

  • ‘random’

    The initial transformation will be a random array of shape (n_components, n_features). Each value is sampled from the standard normal distribution.

  • numpy array

    n_features_b must match the dimensionality of the inputs passed to fit() and n_features_a must be less than or equal to that. If n_components is not None, n_features_a must match it.

warm_start: bool, default=False

If True and fit() has been called before, the solution of the previous call to fit() is used as the initial linear transformation (n_components and init will be ignored).

max_iter: int, default=50

Maximum number of iterations in the optimization.

tol: float, default=1e-5

Convergence tolerance for the optimization.

callback: callable, default=None

If not None, this function is called after every iteration of the optimizer, taking as arguments the current solution (flattened transformation matrix) and the number of iterations. This might be useful in case one wants to examine or store the transformation found after each iteration.

verbose: int, default=0

If 0, no progress messages will be printed. If 1, progress messages will be printed to stdout. If > 1, progress messages will be printed and the disp parameter of scipy.optimize.minimize() will be set to verbose - 2.

random_state: int or numpy.RandomState, default=None

A pseudo random number generator object or a seed for it if int. If init=’random’, random_state is used to initialize the random transformation. If init=’pca’, random_state is passed as an argument to PCA when initializing the transformation. Pass an int for reproducible results across multiple function calls. See Glossary.

input_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that contain features. If this parameter is not specified, all columns in the input DataFrame except the columns specified by label_cols and sample-weight_col parameters are considered input columns.

label_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that contain labels. This is a required param for estimators, as there is no way to infer these columns. If this parameter is not specified, then object is fitted without labels(Like a transformer).

output_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that will store the output of predict and transform operations. The length of output_cols mus match the expected number of output columns from the specific estimator or transformer class used. If this parameter is not specified, output column names are derived by adding an OUTPUT_ prefix to the label column names. These inferred output column names work for estimator’s predict() method, but output_cols must be set explicitly for transformers.

sample_weight_col: Optional[str]

A string representing the column name containing the examples’ weights. This argument is only required when working with weighted datasets.

drop_input_cols: Optional[bool], default=False

If set, the response of predict(), transform() methods will not contain input columns.

Methods

fit(dataset)

Fit the model according to the given training data For more details on this function, see sklearn.neighbors.NeighborhoodComponentsAnalysis.fit

score(dataset)

Method not supported for this class.

set_input_cols(input_cols)

Input columns setter.

to_sklearn()

Get sklearn.neighbors.NeighborhoodComponentsAnalysis object.

transform(dataset)

Apply the learned transformation to the given data For more details on this function, see sklearn.neighbors.NeighborhoodComponentsAnalysis.transform

Attributes

model_signatures

Returns model signature of current class.