助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
## 支持向量回归 > 基于libsvm实现Epsilon-Support向量回归的类。 ### 构造函数参数 `$kernel(int) `- 算法中使用的内核类型(默认内核:: RBF) `$degree(int)` - `Kernel :: POLYNOMIAL`函数的度数(默认为3) `$ epsilon(float) `- epsilon-epsR的损失函数中的epsilon(默认值为0.1) `$ cost(float)` - C-SVC的参数C(默认值为1.0) `$ gamma(float)` - 'Kernel :: RBF',`Kernel :: POLYNOMIAL'和'Kernel :: SIGMOID`的内核系数。如果gamma为'null',则将使用1 / features。 `$ coef0(float)` - 内核函数中的独立项。它仅在`Kernel :: POLYNOMIAL'和'Kernel :: SIGMOID`中有效(默认为0.0) `$tolerance(float) `- 终止标准的容差(默认值为0.001) `$cacheSize(int)` - 以MB为单位的缓存内存大小(默认为100 `$shrinking(bool)` - 是否使用收缩启发式(默认为true) ``` $regression = new SVR(Kernel::LINEAR); $regression = new SVR(Kernel::LINEAR, $degree = 3, $epsilon=10.0); ``` ***** ## 训练 训练模型只需提供训练样本和目标值(作为`array`)。例: ``` use Phpml\Regression\SVR; use Phpml\SupportVectorMachine\Kernel; $samples = [[60], [61], [62], [63], [65]]; $targets = [3.1, 3.6, 3.8, 4, 4.1]; $regression = new SVR(Kernel::LINEAR); $regression->train($samples, $targets); ``` 您可以使用多个`predict`集训练模型,预测将基于所有训练数据。 ***** ### 预测 要预测样本目标值,请使用`predict`方法。您可以提供一个样本或样本数组: ``` $regression->predict([64]) // return 4.03 ```