<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 支持向量分類 > 基于`libsvm`實現支持向量機的分類器。 ### 構造函數參數 `$kernel(int)` - 算法中使用的內核類型(默認內核:: RBF) `$cost(float)` - C-SVC的參數C(默認值為1.0) `$degree(int)` - `Kernel :: POLYNOMIAL`函數的度數(默認為3) `$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) `$probabilityEstimates(bool)` - 是否啟用概率估計(默認為false) ``` $classifier = new SVC(Kernel::LINEAR, $cost = 1000); $classifier = new SVC(Kernel::RBF, $cost = 1000, $degree = 3, $gamma = 6); ``` ***** ## 訓練 訓練分類器只需提供訓練樣本(`$samples`)和標簽(`$labels`)。例: ```php use Phpml\Classification\SVC; use Phpml\SupportVectorMachine\Kernel; $samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]]; $labels = ['a', 'a', 'a', 'b', 'b', 'b']; $classifier = new SVC(Kernel::LINEAR, $cost = 1000); $classifier->train($samples, $labels); ``` 您可以使用多個數據集訓練分類器,預測將基于所有訓練數據。 ***** ## 預測 預測樣本標簽使用`predict`方法。您可以提供一個樣本或樣本數組: ``` $classifier->predict([3, 2]); // return 'b' $classifier->predict([[3, 2], [1, 5]]); // return ['b', 'a'] ``` ***** ## 概率估計 要預測概率,必須構建一個`$probabilityEstimates`設置為true的分類器。例: ``` use Phpml\Classification\SVC; use Phpml\SupportVectorMachine\Kernel; $samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]]; $labels = ['a', 'a', 'a', 'b', 'b', 'b']; $classifier = new SVC( Kernel::LINEAR, // $kernel 1.0, // $cost 3, // $degree null, // $gamma 0.0, // $coef0 0.001, // $tolerance 100, // $cacheSize true, // $shrinking true // $probabilityEstimates, set to true ); $classifier->train($samples, $labels); ``` 然后使用`predictProbability`方法代替`predict`: ``` $classifier->predictProbability([3, 2]); // return ['a' => 0.349833, 'b' => 0.650167] $classifier->predictProbability([[3, 2], [1, 5]]); // return [ // ['a' => 0.349833, 'b' => 0.650167], // ['a' => 0.922664, 'b' => 0.0773364], // ] ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看