<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 如何用 Scikit-Learn 調整算法參數 > 原文: [https://machinelearningmastery.com/how-to-tune-algorithm-parameters-with-scikit-learn/](https://machinelearningmastery.com/how-to-tune-algorithm-parameters-with-scikit-learn/) 機器學習模型被參數化,以便可以針對給定問題調整它們的行為。 模型可以有許多參數,找到最佳參數組合可以視為搜索問題。 在這篇文章中,您將了解如何使用 [scikit-learn 庫](http://machinelearningmastery.com/a-gentle-introduction-to-scikit-learn-a-python-machine-learning-library/ "A Gentle Introduction to Scikit-Learn: A Python Machine Learning Library")在 Python 中調整機器學習算法的參數。 * **2017 年 1 月更新**:已更新,以反映版本 0.18 中 scikit-learn API 的更改。 [![fine tuning](https://img.kancloud.cn/b5/97/b5970937446592156a814100829cdc35_640x425.jpg)](https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2014/07/fine-tuning.jpg) 調整像 [Katie Fricker](https://www.flickr.com/photos/frickfrack/6261857231) 調整鋼琴 照片的算法,保留一些權利 ## 機器學習算法參數 [算法調整](http://machinelearningmastery.com/how-to-improve-machine-learning-results/ "How to Improve Machine Learning Results")是在呈現結果之前應用機器學習過程的最后一步。 它有時被稱為[超參數優化](http://en.wikipedia.org/wiki/Hyperparameter_optimization),其中算法參數被稱為超參數,而機器學習算法本身找到的系數被稱為參數。優化表明了問題的搜索性質。 作為搜索問題,您可以使用不同的搜索策略來查找針對給定問題的算法的良好且穩健的參數或參數集。 兩種簡單易用的搜索策略是網格搜索和隨機搜索。 Scikit-learn 為算法參數調整提供了這兩種方法,下面提供了每種方法的示例。 ## 網格搜索參數調整 網格搜索是一種參數調整方法,它將為網格中指定的每個算法參數組合有條不紊地構建和評估模型。 下面的秘籍評估標準糖尿病數據集上的嶺回歸算法的不同 alpha 值。這是一維網格搜索。 Grid Search for Algorithm Tuning Python ``` # Grid Search for Algorithm Tuning import numpy as np from sklearn import datasets from sklearn.linear_model import Ridge from sklearn.model_selection import GridSearchCV # load the diabetes datasets dataset = datasets.load_diabetes() # prepare a range of alpha values to test alphas = np.array([1,0.1,0.01,0.001,0.0001,0]) # create and fit a ridge regression model, testing each alpha model = Ridge() grid = GridSearchCV(estimator=model, param_grid=dict(alpha=alphas)) grid.fit(dataset.data, dataset.target) print(grid) # summarize the results of the grid search print(grid.best_score_) print(grid.best_estimator_.alpha) ``` 有關更多信息,請參閱用戶指南中 GridSearchCV 和[窮舉網格搜索](http://scikit-learn.org/stable/modules/grid_search.html#exhaustive-grid-search)部分的 [API。](http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html) ## 隨機搜索參數調整 隨機搜索是一種參數調整方法,它將從隨機分布(即均勻)中對算法參數進行采樣,進行固定次數的迭代。為所選擇的每個參數組合構建和評估模型。 下面的秘籍評估標準糖尿病數據集上的嶺回歸算法的 0 到 1 之間的不同 alpha 隨機值。 Randomized Search for Algorithm Tuning Python ``` # Randomized Search for Algorithm Tuning import numpy as np from scipy.stats import uniform as sp_rand from sklearn import datasets from sklearn.linear_model import Ridge from sklearn.model_selection import RandomizedSearchCV # load the diabetes datasets dataset = datasets.load_diabetes() # prepare a uniform distribution to sample for the alpha parameter param_grid = {'alpha': sp_rand()} # create and fit a ridge regression model, testing random alpha values model = Ridge() rsearch = RandomizedSearchCV(estimator=model, param_distributions=param_grid, n_iter=100) rsearch.fit(dataset.data, dataset.target) print(rsearch) # summarize the results of the random parameter search print(rsearch.best_score_) print(rsearch.best_estimator_.alpha) ``` 有關更多信息,請參閱用戶指南中的 [API for RandomizedSearchCV](http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.RandomizedSearchCV.html#sklearn.grid_search.RandomizedSearchCV) 和[隨機參數優化](http://scikit-learn.org/stable/modules/grid_search.html#randomized-parameter-optimization)部分。 ## 摘要 算法參數調整是在呈現結果或準備生產系統之前提高算法表現的重要步驟。 在這篇文章中,您發現了算法參數調優和兩種方法,您現在可以在 Python 和 scikit-learn 庫中使用它們來改進算法結果。特別是網格搜索和隨機搜索。
                  <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>

                              哎呀哎呀视频在线观看