🤖 AIによる機械翻訳(非公式) — これは OpenCV 4.13.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
Package org.opencv.ml
Class SVM
- java.lang.Object
-
- org.opencv.core.Algorithm
-
- org.opencv.ml.StatModel
-
- org.opencv.ml.SVM
public class SVM extends StatModel
サポートベクターマシン。参照: REF: ml_intro_svm
-
-
フィールドの要約
フィールド Modifier and Type Field Description static intCstatic intC_SVCstatic intCHI2static intCOEFstatic intCUSTOMstatic intDEGREEstatic intEPS_SVRstatic intGAMMAstatic intINTERstatic intLINEARstatic intNUstatic intNU_SVCstatic intNU_SVRstatic intONE_CLASSstatic intPstatic intPOLYstatic intRBFstatic intSIGMOID-
クラス org.opencv.ml.StatModel から継承されたフィールド
COMPRESSED_INPUT, PREPROCESSED_INPUT, RAW_OUTPUT, UPDATE_MODEL
-
-
コンストラクタの要約
コンストラクタ Modifier Constructor Description protectedSVM​(long addr)
-
メソッドの要約
すべてのメソッド 静的メソッド インスタンスメソッド 具象メソッド Modifier and Type Method Description static SVM__fromPtr__​(long addr)static SVMcreate()Creates empty model.doublegetC()SEE: setCMatgetClassWeights()SEE: setClassWeightsdoublegetCoef0()SEE: setCoef0doublegetDecisionFunction​(int i, Mat alpha, Mat svidx)Retrieves the decision functionstatic ParamGridgetDefaultGridPtr​(int param_id)Generates a grid for %SVM parameters.doublegetDegree()SEE: setDegreedoublegetGamma()SEE: setGammaintgetKernelType()Type of a %SVM kernel.doublegetNu()SEE: setNudoublegetP()SEE: setPMatgetSupportVectors()Retrieves all the support vectors The method returns all the support vectors as a floating-point matrix, where support vectors are stored as matrix rows.TermCriteriagetTermCriteria()SEE: setTermCriteriaintgetType()SEE: setTypeMatgetUncompressedSupportVectors()Retrieves all the uncompressed support vectors of a linear %SVM The method returns all the uncompressed support vectors of a linear %SVM that the compressed support vector, used for prediction, was derived from.static SVMload​(java.lang.String filepath)Loads and creates a serialized svm from a file Use SVM::save to serialize and store an SVM to disk.voidsetC​(double val)getC SEE: getCvoidsetClassWeights​(Mat val)getClassWeights SEE: getClassWeightsvoidsetCoef0​(double val)getCoef0 SEE: getCoef0voidsetDegree​(double val)getDegree SEE: getDegreevoidsetGamma​(double val)getGamma SEE: getGammavoidsetKernel​(int kernelType)Initialize with one of predefined kernels.voidsetNu​(double val)getNu SEE: getNuvoidsetP​(double val)getP SEE: getPvoidsetTermCriteria​(TermCriteria val)getTermCriteria SEE: getTermCriteriavoidsetType​(int val)getType SEE: getTypebooleantrainAuto​(Mat samples, int layout, Mat responses)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid)Trains an %SVM with optimal parametersbooleantrainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid, boolean balanced)Trains an %SVM with optimal parameters-
クラス org.opencv.ml.StatModel から継承されたメソッド
calcError, empty, getVarCount, isClassifier, isTrained, predict, predict, predict, train, train, train
-
クラス org.opencv.core.Algorithm から継承されたメソッド
clear, getDefaultName, getNativeObjAddr, save
-
-
-
-
フィールドの詳細
-
CUSTOM
public static final int CUSTOM
- 関連項目:
- 定数フィールド値
-
LINEAR
public static final int LINEAR
- 関連項目:
- 定数フィールド値
-
POLY
public static final int POLY
- 関連項目:
- 定数フィールド値
-
RBF
public static final int RBF
- 関連項目:
- 定数フィールド値
-
SIGMOID
public static final int SIGMOID
- 関連項目:
- 定数フィールド値
-
CHI2
public static final int CHI2
- 関連項目:
- 定数フィールド値
-
INTER
public static final int INTER
- 関連項目:
- 定数フィールド値
-
C
public static final int C
- 関連項目:
- 定数フィールド値
-
GAMMA
public static final int GAMMA
- 関連項目:
- 定数フィールド値
-
P
public static final int P
- 関連項目:
- 定数フィールド値
-
NU
public static final int NU
- 関連項目:
- 定数フィールド値
-
COEF
public static final int COEF
- 関連項目:
- 定数フィールド値
-
DEGREE
public static final int DEGREE
- 関連項目:
- 定数フィールド値
-
C_SVC
public static final int C_SVC
- 関連項目:
- 定数フィールド値
-
NU_SVC
public static final int NU_SVC
- 関連項目:
- 定数フィールド値
-
ONE_CLASS
public static final int ONE_CLASS
- 関連項目:
- 定数フィールド値
-
EPS_SVR
public static final int EPS_SVR
- 関連項目:
- 定数フィールド値
-
NU_SVR
public static final int NU_SVR
- 関連項目:
- 定数フィールド値
-
-
メソッドの詳細
-
__fromPtr__
public static SVM __fromPtr__​(long addr)
-
getType
public int getType()
SEE: setType- 戻り値:
- 自動生成
-
setType
public void setType​(int val)
getType SEE: getType- 引数:
val- 自動生成
-
getGamma
public double getGamma()
SEE: setGamma- 戻り値:
- 自動生成
-
setGamma
public void setGamma​(double val)
getGamma SEE: getGamma- 引数:
val- 自動生成
-
getCoef0
public double getCoef0()
SEE: setCoef0- 戻り値:
- 自動生成
-
setCoef0
public void setCoef0​(double val)
getCoef0 SEE: getCoef0- 引数:
val- 自動生成
-
getDegree
public double getDegree()
SEE: setDegree- 戻り値:
- 自動生成
-
setDegree
public void setDegree​(double val)
getDegree SEE: getDegree- 引数:
val- 自動生成
-
getC
public double getC()
SEE: setC- 戻り値:
- 自動生成
-
setC
public void setC​(double val)
getC SEE: getC- 引数:
val- 自動生成
-
getNu
public double getNu()
SEE: setNu- 戻り値:
- 自動生成
-
setNu
public void setNu​(double val)
getNu SEE: getNu- 引数:
val- 自動生成
-
getP
public double getP()
SEE: setP- 戻り値:
- 自動生成
-
setP
public void setP​(double val)
getP SEE: getP- 引数:
val- 自動生成
-
getClassWeights
public Mat getClassWeights()
SEE: setClassWeights- 戻り値:
- 自動生成
-
setClassWeights
public void setClassWeights​(Mat val)
getClassWeights SEE: getClassWeights- 引数:
val- 自動生成
-
getTermCriteria
public TermCriteria getTermCriteria()
SEE: setTermCriteria- 戻り値:
- 自動生成
-
setTermCriteria
public void setTermCriteria​(TermCriteria val)
getTermCriteria SEE: getTermCriteria- 引数:
val- 自動生成
-
getKernelType
public int getKernelType()
Type of a %SVM kernel. See SVM::KernelTypes. Default value is SVM::RBF.- 戻り値:
- 自動生成
-
setKernel
public void setKernel​(int kernelType)
Initialize with one of predefined kernels. See SVM::KernelTypes.- 引数:
kernelType- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid, boolean balanced)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッドpGrid- p 用のグリッドnuGrid- nu 用のグリッドcoeffGrid- coeff 用のグリッドdegreeGrid- degree 用のグリッドbalanced- true でかつ問題が2クラス分類の場合、本メソッドはよりバランスの取れた交差検証サブセットを作成する。すなわちサブセット内のクラス間の比率が訓練データセット全体における比率に近くなる。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッドpGrid- p 用のグリッドnuGrid- nu 用のグリッドcoeffGrid- coeff 用のグリッドdegreeGrid- degree 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッドpGrid- p 用のグリッドnuGrid- nu 用のグリッドcoeffGrid- coeff 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッドpGrid- p 用のグリッドnuGrid- nu 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッドpGrid- p 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッドgammaGrid- gamma 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムはCgrid- C 用のグリッド。サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses, int kFold)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。kFold- 交差検証のパラメータ。訓練セットは kFold 個のサブセットに分割される。1つのサブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムは、サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
trainAuto
public boolean trainAuto​(Mat samples, int layout, Mat responses)
Trains an %SVM with optimal parameters- 引数:
samples- 訓練サンプルlayout- ml::SampleTypes を参照。responses- 訓練サンプルに対応する応答のベクトル。サブセットがモデルのテストに用いられ、残りが訓練セットを構成する。すなわち %SVM アルゴリズムは、サブセット内のクラス間の比率が訓練データセット全体における比率に近くなるバランスの取れた交差検証サブセット。本メソッドは最適なパラメータ C, gamma, p, nu, coef0, degree を選択することで %SVM モデルを自動的に訓練する。テストセット誤差の交差検証推定値が最小となるとき、パラメータは最適とみなされる。この関数はパラメータ最適化に SVM::getDefaultGrid のみを使用するため、初歩的なパラメータオプションしか提供しない。この関数は分類 (SVM::C_SVC または SVM::NU_SVC) でも回帰 (SVM::EPS_SVR または SVM::NU_SVR) でも動作する。SVM::ONE_CLASS の場合は最適化は行われず、params で指定されたパラメータを持つ通常の %SVM が実行される。- 戻り値:
- 自動生成
-
getSupportVectors
public Mat getSupportVectors()
Retrieves all the support vectors The method returns all the support vectors as a floating-point matrix, where support vectors are stored as matrix rows.- 戻り値:
- 自動生成
-
getUncompressedSupportVectors
public Mat getUncompressedSupportVectors()
Retrieves all the uncompressed support vectors of a linear %SVM The method returns all the uncompressed support vectors of a linear %SVM that the compressed support vector, used for prediction, was derived from. They are returned in a floating-point matrix, where the support vectors are stored as matrix rows.- 戻り値:
- 自動生成
-
getDecisionFunction
public double getDecisionFunction​(int i, Mat alpha, Mat svidx)Retrieves the decision function- 引数:
i- 決定関数のインデックス。解く問題が回帰、1クラス、または2クラス分類の場合、決定関数は1つだけになるため、インデックスは常に 0 であるべきである。それ以外の N クラス分類の場合、決定関数は \(N(N-1)/2\) 個になる。alpha- 重み用の省略可能な出力ベクトルで、それぞれ異なるサポートベクトルに対応する。線形 %SVM の場合、すべての alpha は 1 になる。svidx- サポートベクトル行列内におけるサポートベクトルのインデックスの省略可能な出力ベクトル(行列は SVM::getSupportVectors で取得できる)。線形 %SVM の場合、各決定関数は単一の「圧縮された」サポートベクトルで構成される。本メソッドは決定関数の rho パラメータ、すなわちカーネル応答の重み付き和から差し引かれるスカラー値を返す。- 戻り値:
- 自動生成
-
getDefaultGridPtr
public static ParamGrid getDefaultGridPtr​(int param_id)
Generates a grid for %SVM parameters.- 引数:
param_id- %SVM パラメータの ID で、SVM::ParamTypes のいずれかでなければならない。この ID を持つパラメータに対してグリッドが生成される。本関数は %SVM アルゴリズムの指定したパラメータに対するグリッドポインタを生成する。このグリッドは SVM::trainAuto 関数に渡すことができる。- 戻り値:
- 自動生成
-
create
public static SVM create()
Creates empty model. Use StatModel::train to train the model. Since %SVM has several parameters, you may want to find the best parameters for your problem, it can be done with SVM::trainAuto.- 戻り値:
- 自動生成
-
load
public static SVM load​(java.lang.String filepath)
Loads and creates a serialized svm from a file Use SVM::save to serialize and store an SVM to disk. Load the SVM from this file again, by calling this function with the path to the file.- 引数:
filepath- シリアライズされた svm へのパス- 戻り値:
- 自動生成
-
-