TransWikia.com

Single image feature reduction at inference time : SVM

Data Science Asked by Sanket Kumar Mali on May 12, 2021

I am trying to train a SVM classifier using scikit-learn.. At training time I want to reduce the feature vector dimension.
I have used PCA to reduce the dimension.

pp = PCA(n_components=400).fit(features)
features = pp.transform(features)

PCA requires m x n dataset to determine the variance. but at the time of inference I have only single image and corresponding 1d feature vector.. I am wondering how to reduce feature vector at inference time in order to match the training dimension.

Or if anyone can suggest some other dimension reduction technique that can be used with single image wiil be highly appreciable.

One Answer

Just like all other Class, you have different methods i.e.fit, transform, fit_transform

fit(self, X[, y]) Fit the model with X.
fit_transform(self, X[, y]) - Fit the model with X and apply the dimensionality reduction on X.
transform(self, X) - Apply dimensionality reduction to X. X is projected on the first principal components previously extracted from a training set.

So, you fit on the data received until the current data and then use transform on the current data.

It's similar to the way we will do Scaling in online learning e.g. You fit your StandardScaler on train data and transform the new data on that.

Answered by 10xAI on May 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP