<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 中的機器學習算法秘籍 > 原文: [https://machinelearningmastery.com/get-your-hands-dirty-with-scikit-learn-now/](https://machinelearningmastery.com/get-your-hands-dirty-with-scikit-learn-now/) 你必須弄臟你的手。 您可以閱讀所有博客文章并觀看世界上的所有視頻,但在您開始練習之前,您實際上并不會真正開始學習機器。 [scikit-learn Python 庫](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")很容易啟動和運行。盡管如此,我看到很多初學者猶豫不決。在這篇博文中,我想給出一些使用 scikit-learn 進行一些監督分類算法的非常簡單的例子。 [![mean-shift clustering algorithm](https://img.kancloud.cn/99/93/9993d6f5446cca229bc863e615f8af39_800x600.jpg)](https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2014/04/plot_mean_shift_1.png) ## Scikit-Learn Recipes 您不需要了解并使用 scikit-learn 中的所有算法,至少在開始時,選擇一個或兩個(或少數)并僅使用這些算法。 在這篇文章中,您將看到 5 個監督分類算法的秘籍應用于 scikit-learn 庫提供的小標準數據集。 秘籍是有原則的。每個例子是: * **Standalone** :每個代碼示例都是一個獨立,完整且可執行的秘籍。 * **Just Code** :每個秘籍的重點都放在代碼上,對機器學習理論的闡述很少。 * **簡單**:秘籍提供了常見的用例,這可能是你想要做的。 * **一致**:所有代碼示例都是一致的,并遵循相同的代碼模式和樣式約定。 秘籍不會探索給定算法的參數。它們提供了一個框架,您可以將其復制并粘貼到文件,項目或 python REPL 中并立即開始播放。 這些秘籍向您展示了您現在可以開始練習 scikit-learn。別推遲了。 ## Logistic 回歸 Logistic 回歸將邏輯模型與數據擬合,并對事件的概率(0 到 1 之間)進行預測。 該秘籍顯示了邏輯回歸模型與虹膜數據集的擬合。因為這是一個多類分類問題,邏輯回歸使得預測在 0 和 1 之間,所以使用了一對一方案(每個類一個模型)。 Logistic Regression Python ``` # Logistic Regression from sklearn import datasets from sklearn import metrics from sklearn.linear_model import LogisticRegression # load the iris datasets dataset = datasets.load_iris() # fit a logistic regression model to the data model = LogisticRegression() model.fit(dataset.data, dataset.target) print(model) # make predictions expected = dataset.target predicted = model.predict(dataset.data) # summarize the fit of the model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted)) ``` 有關更多信息,請參閱 Logistic 回歸的 [API 參考,以獲取有關配置算法參數的詳細信息。另請參閱用戶指南](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression)的 [Logistic 回歸部分。](http://scikit-learn.org/stable/modules/linear_model.html#logistic-regression) ## 樸素貝葉斯 樸素貝葉斯使用貝葉斯定理來模擬每個屬性與類變量的條件關系。 該秘籍顯示了樸素貝葉斯模型與虹膜數據集的擬合。 Gaussian Naive Bayes Python ``` # Gaussian Naive Bayes from sklearn import datasets from sklearn import metrics from sklearn.naive_bayes import GaussianNB # load the iris datasets dataset = datasets.load_iris() # fit a Naive Bayes model to the data model = GaussianNB() model.fit(dataset.data, dataset.target) print(model) # make predictions expected = dataset.target predicted = model.predict(dataset.data) # summarize the fit of the model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted)) ``` 有關配置算法參數的詳細信息,請參閱高斯樸素貝葉斯的 [API 參考。另請參閱用戶指南](http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html#sklearn.naive_bayes.GaussianNB)的 [Naive Bayes 部分。](http://scikit-learn.org/stable/modules/naive_bayes.html#naive-bayes) ## k-最近鄰 k-最近鄰(kNN)方法通過將類似情況定位到給定數據實例(使用相似性函數)并返回最相似數據實例的平均或大部分來進行預測。 kNN 算法可用于分類或回歸。 該秘籍顯示了使用 kNN 模型對虹膜數據集進行預測。 k-Nearest Neighbor Python ``` # k-Nearest Neighbor from sklearn import datasets from sklearn import metrics from sklearn.neighbors import KNeighborsClassifier # load iris the datasets dataset = datasets.load_iris() # fit a k-nearest neighbor model to the data model = KNeighborsClassifier() model.fit(dataset.data, dataset.target) print(model) # make predictions expected = dataset.target predicted = model.predict(dataset.data) # summarize the fit of the model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted)) ``` 有關配置算法參數的詳細信息,請參閱 k-Nearest Neighbor 的 [API 參考。另請參閱用戶指南](http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html#sklearn.neighbors.KNeighborsClassifier)的 [k-Nearest Neighbor 部分。](http://scikit-learn.org/stable/modules/neighbors.html#neighbors) ## 分類和回歸樹 分類和回歸樹(CART)是通過進行分割來構建的,這些分割可以最好地分離正在進行的類或預測的數據。 CART 算法可用于分類或回歸。 此秘籍顯示使用 CART 模型對虹膜數據集進行預測。 Decision Tree Classifier Python ``` # Decision Tree Classifier from sklearn import datasets from sklearn import metrics from sklearn.tree import DecisionTreeClassifier # load the iris datasets dataset = datasets.load_iris() # fit a CART model to the data model = DecisionTreeClassifier() model.fit(dataset.data, dataset.target) print(model) # make predictions expected = dataset.target predicted = model.predict(dataset.data) # summarize the fit of the model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted)) ``` 有關更多信息,請參閱 CART 的 [API 參考,以獲取有關配置算法參數的詳細信息。另請參閱用戶指南](http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier)的[決策樹部分。](http://scikit-learn.org/stable/modules/tree.html#tree) ## 支持向量機 支持向量機(SVM)是一種在轉換后的問題空間中使用點的方法,它最好將類分成兩組。一對一方法支持多個類的分類。 SVM 還通過使用最小允許誤差量對函數建模來支持回歸。 該秘籍顯示了使用 SVM 模型對虹膜數據集進行預測。 Support Vector Machine Python ``` # Support Vector Machine from sklearn import datasets from sklearn import metrics from sklearn.svm import SVC # load the iris datasets dataset = datasets.load_iris() # fit a SVM model to the data model = SVC() model.fit(dataset.data, dataset.target) print(model) # make predictions expected = dataset.target predicted = model.predict(dataset.data) # summarize the fit of the model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted)) ``` 有關更多信息,請參閱 SVM 的 [API 參考,以獲取有關配置算法參數的詳細信息。另請參閱用戶指南](http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC)的 [SVM 部分。](http://scikit-learn.org/stable/modules/svm.html#svm) ## 摘要 在這篇文章中,您已經看到了 5 個獨立的秘籍,展示了一些最受歡迎和最強大的監督分類問題。 每個示例都少于 20 行,您可以立即復制和粘貼并開始使用 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>

                              哎呀哎呀视频在线观看