<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之旅 廣告
                # 使用 Scikit-Learn 在 Python 中進行特征選擇 > 原文: [https://machinelearningmastery.com/feature-selection-in-python-with-scikit-learn/](https://machinelearningmastery.com/feature-selection-in-python-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 中功能選擇的最新教程,請參閱帖子: * [Python 機器學習的特征選擇](http://machinelearningmastery.com/feature-selection-machine-learning-python/) [![feature selection](https://img.kancloud.cn/ec/00/ec006f77020210953c6901d7c06d2b1c_300x201.jpg)](https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2014/07/feature-selection.jpg) 通過功能選擇減少您的選項 照片由 [Josh Friedman](https://www.flickr.com/photos/joshfriedmantravel/4935712614) ,保留一些權利 ## 選擇功能 特征選擇是一個過程,您可以自動選擇數據中對您感興趣的預測變量或輸出貢獻最大的那些特征。 在數據中包含太多不相關的功能會降低模型的準確性。在建模數據之前執行特征選擇的三個好處是: * **減少過度擬合**:冗余數據越少意味著根據噪聲做出決策的機會就越少。 * **提高準確度**:誤導性較差的數據意味著建模精度提高。 * **減少訓練**時間:數據越少意味著算法訓練越快。 scikit-learn Python 庫提供的兩種不同的特征選擇方法是遞歸特征消除和特征重要性排序。 ## 遞歸特征消除 遞歸特征消除(RFE)方法是特征選擇方法。它的工作原理是遞歸刪除屬性并在剩余的屬性上構建模型。它使用模型精度來識別哪些屬性(和屬性組合)對預測目標屬性的貢獻最大。 此秘籍顯示在 Iris floweres 數據集上使用 RFE 以選擇 3 個屬性。 Recursive Feature Elimination Python ``` # Recursive Feature Elimination from sklearn import datasets from sklearn.feature_selection import RFE from sklearn.linear_model import LogisticRegression # load the iris datasets dataset = datasets.load_iris() # create a base classifier used to evaluate a subset of attributes model = LogisticRegression() # create the RFE model and select 3 attributes rfe = RFE(model, 3) rfe = rfe.fit(dataset.data, dataset.target) # summarize the selection of the attributes print(rfe.support_) print(rfe.ranking_) ``` 有關更多信息,請參閱 API 文檔中的 [RFE 方法](http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.RFE.html#sklearn.feature_selection.RFE)。 ## 功能重要性 使用決策樹集合(如隨機森林或額外樹)的方法也可以計算每個屬性的相對重要性。這些重要性值可用于通知特征選擇過程。 此秘籍顯示了虹膜花數據集的額外樹組合的構造以及相對特征重要性的顯示。 Feature Importance with datasets.load_iris() # fit an Extra Python ``` # Feature Importance from sklearn import datasets from sklearn import metrics from sklearn.ensemble import ExtraTreesClassifier # load the iris datasets dataset = datasets.load_iris() # fit an Extra Trees model to the data model = ExtraTreesClassifier() model.fit(dataset.data, dataset.target) # display the relative importance of each attribute print(model.feature_importances_) ``` 有關更多信息,請參閱 API 文檔中的 [ExtraTreesClassifier 方法](http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html#sklearn.ensemble.ExtraTreesClassifier)。 ## 摘要 特征選擇方法可以為您提供有關特定問題的特征的相對重要性或相關性的有用信息。您可以使用此信息創建數據集的過濾版本,并提高模型的準確性。 在這篇文章中,您發現了兩個可以使用 scikit-learn 庫在 Python 中應用的特征選擇方法。
                  <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>

                              哎呀哎呀视频在线观看