整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          守望先鋒 2-3人小隊配合推薦(二)

          守望先鋒 2-3人小隊配合推薦(二)

          文由HBT-MEGADETH原創,轉載請標明原作者~感謝

          《守望先鋒》是6V6的游戲,每個隊中都會有各種各樣的位置和相應角色,雖然個人技術很重要,但小隊配合更重要,所以尤其是在和小伙伴們開黑的時候,如果 你的隊伍不足6人,最好是選擇能達成目標最好配合的英雄,這樣才不容易被路人坑。而小編也是在此推薦一下關于如何組成3人小隊打出更好的配合。

          前篇傳送門:http://ow.replays.net/guides/201606/906.html

          第四組:定位轟殺組合

          黑百合+狂鼠,防守時克制推車,進攻時克制據點,通過黑百合的透視,狂鼠繞掩體放大,黑百合遠處騷擾外加透視大大提高了狂鼠輪胎的命中率和存活率,兩人開大滅半隊,不可小視的組合!

          缺點:兩人都是脆皮遠程,就算滅隊也要配合隊友拿下據點,如果對面也有黑百合同時放大,成功率會直線降低!上手難度簡單。

          第五組:極限瞬秒組合

          盧西奧+麥爹,這個組合其實主要是圍繞麥克雷的大來組合的,大家都是知道“午時已到”時移動速度賊慢,有時還未瞄到就變成了“午時......額啊......”,而盧西奧的瞬間加速剛好補充了麥爹移速慢的問題,一旦被對面發現還能開個大,不至于麥爹被秒死。麥克雷只需要做的就是突然繞后或是滾過大錘的盾,配合盧西奧的加速E直接開大,瞬間團滅,就這么簡單~

          缺點:首先,兩人配合比較考驗默契,最好盧西奧開E瞬間麥爹放大,其次,麥克雷開大比較靠環境,掩體過多的場景并不適合這個組合。

          你說玩OW不想用大招?也可以!

          據點深淵組合

          盧西奧+路霸,這個組合特別適合帶有地圖邊緣的據點攻堅戰,例如尼泊爾漓江塔這類圖。尤其是在伊利奧斯的深井可以讓這個組合發揮到極致,路霸的鉤子可以隔著深井勾人直接讓對方掉進深淵,而盧西奧在很多地圖都有效,右鍵重炮擊飛對手掉到地圖外,還跑得飛快,讓人措手不及!而且這兩人續航能力很不錯,在據守據點的時候還可以增加一個機動性很強外加BUFF回血的76,會有奇效哦!

          缺點:比較怕D.VA轟殺,而且很有可能路霸一個鉤子勾過來的是個開大的D.VA....殘念...上手難度中等。

          飛檐走壁組合

          源氏+半藏,這對CP兄弟不管是騷擾還是切后都是一流,倆人飛檐走壁殺人于無形,特比克制善于陣地據守的英雄。源氏有E基本就是無敵,半藏....還是那句話...哼哼~有多少人被他的大弄死過請舉手!

          缺點:這兩人本來上手難度就很高,想打出傷害必須對英雄操作數量而且還要對地圖都極為熟悉!但兩人的大招真的讓人欲罷不能,有些玩家甚至就為了半藏一個大而活著,一場開個大就死而無憾了...不過這倆人略怕大錘和路霸這種能打能抗的英雄。這組合上手難度超高。

          銅墻鐵壁組合

          溫斯頓*2,對!你沒看錯,就是倆大猩猩,不管是攻防據點,兩個溫斯頓配任意的奶絕對讓你的隊伍飛起來,不開大有護盾,近身肉搏又肉又硬,開大帶擊飛,打的對手暈頭轉向。

          缺點:特別懼怕已經在據點守好的堡壘,來幾個猩猩都沒用跳過來還沒落地估計就要掛掉了...

          小編這兩篇推薦適用于各種娛樂局,虐菜局,只是為了玩家有一些小套路,多謝各位客觀支持!

          更多守望先鋒最新最全精彩內容,請登錄銳派游戲守望先鋒專區ow.replays.net查看。

          ellowbrick使用筆記6-分類可視化

          分類模型試圖在一個離散的空間中預測一個目標,即為一個因變量實例分配一個或多個類別。

          分類分數可視化工具顯示類之間的差異以及一些特定于分類器的可視化評估。我們目前已經實施了以下分類器評估:

          ?分類報告Classification Report:視覺分類報告,將每個類別的精度,召回率和F1顯示為熱圖。?混淆矩陣Confusion Matrix:多類分類中混淆矩陣的熱圖視圖。?ROCAUC: 繪制訓練器的工作特性和曲線下面積?Precision-Recall曲線:繪制不同概率閾值的精度和召回率。?類平衡:目視檢查目標,以向最終評估者顯示每個類的支持。?類預測錯誤:混淆矩陣的另一種選擇,它顯示實際類和預測類之間的支持和差異。?辨別閾值:顯示使用辨別概率或分數的二進制分類器在所有閾值上的精確度、召回率、F1和隊列率。

          本文如果數據集下載不下來,查看下面地址,然后放入yellowbrick安裝目錄\datasets\fixtures文件夾:


          {
            "bikeshare": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/bikeshare.zip",
              "signature": "4ed07a929ccbe0171309129e6adda1c4390190385dd6001ba9eecc795a21eef2"
            },
            "hobbies": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/hobbies.zip",
              "signature": "6114e32f46baddf049a18fb05bad3efa98f4e6a0fe87066c94071541cb1e906f"
            },
            "concrete": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/concrete.zip",
              "signature": "5807af2f04e14e407f61e66a4f3daf910361a99bb5052809096b47d3cccdfc0a"
            },
            "credit": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/credit.zip",
              "signature": "2c6f5821c4039d70e901cc079d1404f6f49c3d6815871231c40348a69ae26573"
            },
            "energy": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/energy.zip",
              "signature": "174eca3cd81e888fc416c006de77dbe5f89d643b20319902a0362e2f1972a34e"
            },
            "game": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/game.zip",
              "signature": "ce799d1c55fcf1985a02def4d85672ac86c022f8f7afefbe42b20364fba47d7a"
            },
            "mushroom": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/mushroom.zip",
              "signature": "f79fdbc33b012dabd06a8f3cb3007d244b6aab22d41358b9aeda74417c91f300"
            },
            "occupancy": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/occupancy.zip",
              "signature": "0b390387584586a05f45c7da610fdaaf8922c5954834f323ae349137394e6253"
            },
            "spam": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/spam.zip",
              "signature": "000309ac2b61090a3001de3e262a5f5319708bb42791c62d15a08a2f9f7cb30a"
            },
            "walking": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/walking.zip",
              "signature": "7a36615978bc3bb74a2e9d5de216815621bd37f6a42c65d3fc28b242b4d6e040"
            },
            "nfl": {
              "url": "https://s3.amazonaws.com/ddl-data-lake/yellowbrick/v1.0/nfl.zip",
              "signature": "4989c66818ea18217ee0fe3a59932b963bd65869928c14075a5c50366cb81e1f"
            }
          }

          # 多行輸出 from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity="all"

          1 分類報告Classification Report

          分類報告可視化工具顯示模型的精度、召回率、F1和支持度得分。為了便于解釋和發現問題,該報告將數字分數與彩色編碼熱圖相結合。所有熱圖都在(0.0,1.0)范圍內,以便于不同分類報告之間的分類模型比較。



          1.1 基本使用


          from sklearn.model_selection import TimeSeriesSplit
          from sklearn.naive_bayes import GaussianNB
          
          from yellowbrick.classifier import ClassificationReport
          from yellowbrick.datasets import load_occupancy
          
          # Load the classification dataset
          X, y=load_occupancy()
          
          # Specify the target classes
          classes=["unoccupied", "occupied"]
          
          # Create the training and test data
          # 建立時序數據
          tscv=TimeSeriesSplit()
          for train_index, test_index in tscv.split(X):
              X_train, X_test=X.iloc[train_index], X.iloc[test_index]
              y_train, y_test=y.iloc[train_index], y.iloc[test_index]
          
          # Instantiate the classification model and visualizer
          # 建立分類器
          model=GaussianNB()
          # support 表示是否添加support方塊格中顯示數據。{True,False,None,'percent','count'},默認值:無
          # support-'percent'表示百分比顯示數據,'count'表示按個數顯示數據
          visualizer=ClassificationReport(model, classes=classes, support=True)
          
          visualizer.fit(X_train, y_train)        # Fit the visualizer and the model
          visualizer.score(X_test, y_test)        # Evaluate the model on the test data
          visualizer.show();                       # Finalize and show the figure

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/model_selection/_split.py:752: FutureWarning: You should specify a value for 'n_splits' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22. warnings.warn(NSPLIT_WARNING, FutureWarning) <Figure size 800x550 with 2 Axes>

          分類報告以每個類為基礎顯示主要分類指標的表示形式。這給了分類器行為比全局精度更深的直觀,這可以掩蓋多類問題的一類中的功能弱點。視覺分類報告用于比較分類模型,以選擇更“紅色”的模型,例如,具有更強的分類度量或更平衡的模型。

          度量標準根據真陽性和假陽性,真陰性和假陰性來定義。在這種情況下,正和負是二元分類問題的類的通用名稱。在上面的例子中,我們會考慮真和假被占據和真和假未被占據。因此,真正的正數是當實際類和估計類都是正數時。假陽性是指實際的類是負數,但估計的類是正數。使用這個術語,計量的定義如下:

          ?精度precision:精確度是分類器不將一個實例標記為正的能力,而實際上是負的。對于每個類,它被定義為真陽性與真陽性和假陽性之和的比率。換句話說,“對于所有被歸類為正面的例子,正確的百分比是多少?”?召回率recall:回憶是分類器找到所有正實例的能力。對于每個類,它被定義為真陽性與真陽性和假陰性之和的比率。

          換一種說法,“在所有實際是積極的情況下,正確分類的百分比是多少?”?F1分數:F1的分數是精度和召回率的加權調和平均值,最好的分數是1.0,最差的是0.0。一般來說,F1的分數低于準確性指標,因為它們在計算中嵌入了精度和召回率。作為一個經驗法則,應該使用F1的加權平均值來比較分類器模型,而不是全局精度。?support:支持是類在指定數據集中實際出現的次數。訓練數據中的不平衡支持可能表明分類器報告分數中的結構弱點,并可能表明需要分層抽樣或再平衡。模型之間的支持不會改變,而是對評估過程進行診斷。

          1.2 快速使用

          上面的相同功能可以通過關聯的快速方法來實現classification_report。此方法將ClassificationReport使用關聯的參數構建對象,將其擬合,然后(可選)立即顯示它。


          from sklearn.model_selection import TimeSeriesSplit
          from sklearn.naive_bayes import GaussianNB
          
          from yellowbrick.datasets import load_occupancy
          from yellowbrick.classifier import classification_report
          
          # Load the classification data set
          X, y=load_occupancy()
          
          # Specify the target classes
          classes=["unoccupied", "occupied"]
          
          # Create the training and test data
          tscv=TimeSeriesSplit()
          for train_index, test_index in tscv.split(X):
              X_train, X_test=X.iloc[train_index], X.iloc[test_index]
              y_train, y_test=y.iloc[train_index], y.iloc[test_index]
          
          # Instantiate the visualizer
          visualizer=classification_report(
              GaussianNB(), X_train, y_train, X_test, y_test, classes=classes, support=True
          );

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/model_selection/_split.py:752: FutureWarning: You should specify a value for 'n_splits' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22. warnings.warn(NSPLIT_WARNING, FutureWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          2 混淆矩陣Confusion Matrix

          ConfusionMatrix visualizer是一個ScoreVisualizer,它使用一個合適的scikit學習分類器和一組測試X和y值,并返回一個報告,顯示每個測試值預測類與實際類的比較情況。數據科學家使用混淆矩陣來理解哪些類最容易混淆。它們提供的信息與分類報告中提供的信息相似,但它們提供了對單個數據點分類的更深入的了解,而不是頂級分數。

          下面是一些使用ConfusionMatrix可視化工具的示例;更多信息可以通過查看scikit learn文檔來找到。



          2.1 基礎使用


          from sklearn.datasets import load_digits
          from sklearn.model_selection import train_test_split as tts
          from sklearn.linear_model import LogisticRegression
          from yellowbrick.classifier import ConfusionMatrix
          
          # We'll use the handwritten digits data set from scikit-learn.
          # Each feature of this dataset is an 8x8 pixel image of a handwritten number.
          # Digits.data converts these 64 pixels into a single array of features
          #我們將使用scikit learn中的手寫數字數據集。
          #該數據集的每個特征都是手寫數字的8x8像素圖像。
          # Digits.data 將這64個像素轉換為一個維度數組
          digits=load_digits()
          X=digits.data
          y=digits.target
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2, random_state=11)
          X_test.shape,y_test.shape
          model=LogisticRegression(multi_class="auto", solver="liblinear")
          
          # The ConfusionMatrix visualizer taxes a model
          # 混淆矩陣分類號
          cm=ConfusionMatrix(model, classes=[0,1,2,3,4,5,6,7,8,9])
          
          # Fit fits the passed model. This is unnecessary if you pass the visualizer a pre-fitted model
          cm.fit(X_train, y_train)
          
          # To create the ConfusionMatrix, we need some test data. Score runs predict() on the data
          # and then creates the confusion_matrix from scikit-learn.
          #為了創建ConfusionMatrix,我們需要一些測試數據。對數據執行Score runs predict()然后從scikit learn創建混淆矩陣。
          cm.score(X_test, y_test)
          
          # 圖中顯示的每一類的個數
          cm.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          2.2 用類名繪圖

          可以使用label_encoder參數將類名添加到ConfusionMatrix圖中。label_編碼器可以是sklearn.preprocessing.LabelEncoder(或具有執行映射的反_變換方法的任何對象)或具有編碼到字符串映射的dict,如下面的示例所示:


          from sklearn.datasets import load_iris
          from sklearn.model_selection import train_test_split as tts
          from sklearn.linear_model import LogisticRegression
          from yellowbrick.classifier import ConfusionMatrix
          
          iris=load_iris()
          X=iris.data
          y=iris.target
          classes=iris.target_names
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2)
          
          model=LogisticRegression(multi_class="auto", solver="liblinear")
          
          # percent表示顯示百分比
          iris_cm=ConfusionMatrix(
              model, classes=classes,
              label_encoder={0: 'setosa', 1: 'versicolor', 2: 'virginica'},percent=True
          )
          
          iris_cm.fit(X_train, y_train)
          iris_cm.score(X_test, y_test)
          
          iris_cm.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          2.3 快速方法

          上面的相同功能可以通過關聯的快速方法來實現confusion_matrix。此方法將ConfusionMatrix使用關聯的參數構建對象,將其擬合,然后(可選)立即顯示它。在下面的示例中,我們可以看到如何LogisticRegression有效地對信用數據集建模(提示:請Rank2D檢查多重共線性!)。


          from yellowbrick.datasets import load_credit
          from yellowbrick.classifier import confusion_matrix
          from sklearn.linear_model import LogisticRegression
          from sklearn.model_selection import train_test_split as tts
          
          #Load the classification dataset
          X, y=load_credit()
          
          #Create the train and test data
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2)
          
          # Instantiate the visualizer with the classification model
          confusion_matrix(
              LogisticRegression(),
              X_train, y_train, X_test, y_test,
              classes=['not_defaulted', 'defaulted']
          );

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/linear_model/logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning. FutureWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          3 ROCAUC

          ROCAUC(接受者操作特征/曲線下的面積)圖允許用戶可視化分類器的敏感性和特異性之間的權衡。接收器工作特性(ROC)是分類器預測質量的度量,它比較和可視化模型的靈敏度和特異度之間的權衡。繪制ROC曲線時,ROC曲線在Y軸上顯示真標簽的陽性率,在X軸上顯示假標簽的陽性率,同時顯示全局平均和每個類別的假陽性率。因此,理想點是圖的左上角:假陽性為0,真陽性為1。

          這就引出了另一個度量,曲線下面積(AUC),它是假陽性和真陽性之間關系的計算。AUC越高,模型通常越好。然而,檢查曲線的“陡度”也很重要,因為這描述了真實陽性率的最大化,同時使假陽性率最小化。

          關于ROC和AUC可以查看https://segmentfault.com/a/1190000016686335



          3.1 基本使用


          from sklearn.linear_model import LogisticRegression
          from sklearn.model_selection import train_test_split
          
          from yellowbrick.classifier import ROCAUC
          from yellowbrick.datasets import load_spam
          
          # Load the classification dataset
          X, y=load_spam()
          
          # Create the training and test data
          X_train, X_test, y_train, y_test=train_test_split(X, y, random_state=42)
          
          # Instantiate the visualizer with the classification model
          # 初始分類器
          model=LogisticRegression(multi_class="auto", solver="liblinear")
          # 繪制ROCAUC
          visualizer=ROCAUC(model, classes=["not_spam", "is_spam"])
          
          visualizer.fit(X_train, y_train)        # Fit the training data to the visualizer
          visualizer.score(X_test, y_test)        # Evaluate the model on the test data
          visualizer.show();                       # Finalize and show the figure

          添加圖片注釋,不超過 140 字(可選)

          png

          3.2 多類別ROCAUC曲線

          Yellowbrick的ROCAUC可視化工具允許繪制多類分類曲線。ROC曲線通常用于二值分類,而事實上Scikit-Learn roc_curve度量僅能對二值分類器進行度量。Yellowbrick通過對輸出進行二進制化(每個類)或使用one vs-rest(micro score)或one vs-all(macro score)分類策略來解決這個問題。關于one vs-rest(micro score)或one vs-all(macro score)解釋見https://blog.csdn.net/u010551621/article/details/46907575


          from sklearn.linear_model import RidgeClassifier
          from sklearn.model_selection import train_test_split
          from sklearn.preprocessing import OrdinalEncoder, LabelEncoder
          
          from yellowbrick.classifier import ROCAUC
          from yellowbrick.datasets import load_game
          
          # Load multi-class classification dataset
          X, y=load_game()
          
          # Encode the non-numeric columns
          X=OrdinalEncoder().fit_transform(X)
          y=LabelEncoder().fit_transform(y)
          
          # Create the train and test data
          X_train, X_test, y_train, y_test=train_test_split(X, y, random_state=42)
          
          # Instaniate the classification model and visualizer
          model=RidgeClassifier()
          # 多類
          visualizer=ROCAUC(model, classes=["win", "loss", "draw"])
          
          visualizer.fit(X_train, y_train)        # Fit the training data to the visualizer
          visualizer.score(X_test, y_test)        # Evaluate the model on the test data
          visualizer.show();            # Finalize and render the figure

          添加圖片注釋,不超過 140 字(可選)

          png

          默認情況下,在使用多類ROCAUC可視化工具時,除了每個類的微觀和宏觀平均曲線外,還繪制了每個類的曲線。這使用戶可以按類別檢查敏感性和特異性之間的權衡。請注意,對于multi-class ROCAUC,必須至少將micro,macro或per_class參數之一設置為True(默認情況下,所有參數都設置為True)。

          3.3 快速方法

          上面的相同功能可以通過關聯的快速方法來實現roc_auc。此方法將ROCAUC使用關聯的參數構建對象,將其擬合,然后(可選)立即顯示它


          from yellowbrick.classifier.rocauc import roc_auc
          from yellowbrick.datasets import load_credit
          from sklearn.linear_model import LogisticRegression
          from sklearn.model_selection import train_test_split
          
          #Load the classification dataset
          X, y=load_credit()
          
          #Create the train and test data
          X_train, X_test, y_train, y_test=train_test_split(X,y)
          
          # Instantiate the visualizer with the classification model
          model=LogisticRegression()
          roc_auc(model, X_train, y_train, X_test=X_test, y_test=y_test, classes=['not_defaulted', 'defaulted']);

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/linear_model/logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning. FutureWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          4 Precision-Recall曲線

          精確召回曲線是用來評估分類器質量的指標,特別是在分類非常不平衡的情況下。精度-召回曲線顯示了精度(衡量結果相關性)和召回率(衡量返回多少相關結果)之間的權衡。曲線下面的大區域代表高-召回率和精確度,這是分類器的最佳情況,顯示了為其選擇的大多數類別返回準確結果的模型。關于 Precision-Recall具體可以參考https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html



          4.1 二分類


          from sklearn.linear_model import RidgeClassifier
          from sklearn.model_selection import train_test_split as tts
          from yellowbrick.classifier import PrecisionRecallCurve
          from yellowbrick.datasets import load_spam
          
          # Load the dataset and split into train/test splits
          X, y=load_spam()
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2, shuffle=True)
          
          # Create the visualizer, fit, score, and show it
          viz=PrecisionRecallCurve(RidgeClassifier())
          viz.fit(X_train, y_train)
          viz.score(X_test, y_test)
          viz.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          精確召回曲線的基本情況是二進制分類情況,這種情況也是最直觀的解釋。在上圖中,我們可以看到y軸上的精度相對于x軸上的召回率。填充區域越大,分類器越強。紅線表示平均精度,它是整個圖的匯總,計算為在每個閾值處獲得的精度的加權平均值,因此權重是與前一個閾值的召回率之差。

          4.2 多標簽分類

          為了支持多標簽分類,將估計器包裝在OneVsRestClassifier中,以針對每個類生成二進制比較(例如,正例是該類,而負例是任何其他類)。然后,將Precision-Recall曲線計算為所有類別的精度和召回率的平均值:


          from sklearn.ensemble import RandomForestClassifier
          from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
          from sklearn.model_selection import train_test_split as tts
          from yellowbrick.classifier import PrecisionRecallCurve
          from yellowbrick.datasets import load_game
          
          # Load dataset and encode categorical variables
          X, y=load_game()
          X=OrdinalEncoder().fit_transform(X)
          y=LabelEncoder().fit_transform(y)
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2, shuffle=True)
          
          # Create the visualizer, fit, score, and show it
          viz=PrecisionRecallCurve(RandomForestClassifier(n_estimators=10))
          viz.fit(X_train, y_train)
          viz.score(X_test, y_test)
          viz.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          然而,可以計算出更復雜的精確召回曲線,單獨顯示每條曲線以及F1分數等參曲線(例如,顯示不同F1分數的精確度和召回率之間的關系)。


          from sklearn.naive_bayes import MultinomialNB
          from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
          from sklearn.model_selection import train_test_split as tts
          from yellowbrick.classifier import PrecisionRecallCurve
          from yellowbrick.datasets import load_game
          
          # Load dataset and encode categorical variables
          X, y=load_game()
          X=OrdinalEncoder().fit_transform(X)
          encoder=LabelEncoder()
          y=encoder.fit_transform(y)
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2, shuffle=True)
          
          # Create the visualizer, fit, score, and show it
          viz=PrecisionRecallCurve(
              MultinomialNB(), per_class=True, iso_f1_curves=True,
              fill_area=False, micro=False, classes=encoder.classes_
          )
          viz.fit(X_train, y_train)
          viz.score(X_test, y_test)
          viz.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          4.3 快速方法

          使用關聯的快速方法,可以在一行中實現與上述類似的功能precision_recall_curve。此方法將實例化PrecisionRecallCurve可視化程序并將其適合于訓練數據,然后將其在可選提供的測試數據(或未提供的訓練數據)上評分。


          from sklearn.naive_bayes import MultinomialNB
          from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
          from sklearn.model_selection import train_test_split as tts
          from yellowbrick.classifier import PrecisionRecallCurve
          from yellowbrick.datasets import load_game
          
          # Load dataset and encode categorical variables
          X, y=load_game()
          X=OrdinalEncoder().fit_transform(X)
          encoder=LabelEncoder()
          y=encoder.fit_transform(y)
          
          X_train, X_test, y_train, y_test=tts(X, y, test_size=0.2, shuffle=True)
          
          # Create the visualizer, fit, score, and show it
          viz=PrecisionRecallCurve(
              MultinomialNB(), per_class=True, iso_f1_curves=True,
              fill_area=False, micro=False, classes=encoder.classes_
          )
          viz.fit(X_train, y_train)
          viz.score(X_test, y_test)
          viz.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          5 類平衡

          分類模型面臨的最大挑戰之一是訓練數據中類的不平衡。嚴重的類別失衡可能會被相對較好的F1和準確性分數所掩蓋-分類器只是猜測多數類別,而不對代表不足的類別進行任何評估。有幾種處理類不平衡的技術,如分層抽樣、對多數類進行下采樣、加權等。但是在采取這些操作之前,了解訓練數據中的類平衡是很重要的。ClassBalance可視化工具通過創建每個類的支持條形圖(即類在數據集中的表示頻率)來支持這一點。



          5.1 基本使用


          from yellowbrick.datasets import load_game
          from yellowbrick.target import ClassBalance
          
          # Load the classification dataset
          X, y=load_game()
          
          # Instantiate the visualizer
          visualizer=ClassBalance(labels=["draw", "loss", "win"])
          
          visualizer.fit(y)        # Fit the data to the visualizer
          visualizer.show();       # Finalize and render the figure

          添加圖片注釋,不超過 140 字(可選)

          png

          由此得到的數字使我們能夠診斷平衡問題的嚴重性。在這個圖中,我們可以看到“贏”類在其他兩個類中占主導地位。一個潛在的解決方案可能是創建一個二進制分類器:“win”vs“not win”,并將“loss”和“draw”類組合成一個類。

          如果在評估過程中必須保持班級不平衡(例如,被分類的事件實際上與頻率所暗示的一樣罕見),則應使用分層抽樣來創建訓練和測試拆分。這樣可以確保測試數據的類別與培訓數據的比例大致相同。雖然scikit-learn默認在train_test_split和其他cv方法中執行此操作,但比較兩個拆分中每個類的支持可能很有用。

          ClassBalance可視化器具有“比較”模式,可以將訓練和測試數據傳遞到fit(),從而創建并排的條形圖,而不是單個條形圖,如下所示:


          from sklearn.model_selection import TimeSeriesSplit
          
          from yellowbrick.datasets import load_occupancy
          from yellowbrick.target import ClassBalance
          
          # Load the classification dataset
          X, y=load_occupancy()
          
          # Create the training and test data
          tscv=TimeSeriesSplit()
          for train_index, test_index in tscv.split(X):
              X_train, X_test=X.iloc[train_index], X.iloc[test_index]
              y_train, y_test=y.iloc[train_index], y.iloc[test_index]
          
          # Instantiate the visualizer
          visualizer=ClassBalance(labels=["unoccupied", "occupied"])
          
          visualizer.fit(y_train, y_test)        # Fit the data to the visualizer
          visualizer.show(); 

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/model_selection/_split.py:752: FutureWarning: You should specify a value for 'n_splits' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22. warnings.warn(NSPLIT_WARNING, FutureWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          該可視化使我們能夠進行快速檢查,以確保兩個拆分中每個類的比例大致相似。這種可視化應該是第一站,尤其是當評估指標在不同拆分之間變化很大時。

          5.2 快速方法

          上面的相同功能可以通過關聯的快速方法class_balance來實現。此方法將ClassBalance使用關聯的參數構建對象,將其擬合,然后(可選)立即顯示它。


          from yellowbrick.datasets import load_game
          from yellowbrick.target import class_balance
          
          # Load the dataset
          X, y=load_game()
          
          # Use the quick method and immediately show the figure
          class_balance(y);

          添加圖片注釋,不超過 140 字(可選)

          png

          6 類預測錯誤

          Yellowbrick的ClassPredictionError圖是對其他分類模型診斷工具(比如混淆矩陣和分類報告)的扭曲。與分類報告一樣,這個圖以堆疊條形圖的形式顯示了擬合分類模型中每個類的支持度(訓練樣本的數量)。每個條被分割以顯示每個類的預測比例(包括假陰性和假陽性,如混淆矩陣)。您可以使用ClassPredictionError來可視化您的分類器遇到了哪些特別困難的類,更重要的是,在每個類的基礎上它給出了哪些不正確的答案。這通常可以使您更好地理解不同模型的優缺點以及數據集特有的特殊挑戰。類預測誤差圖提供了一種快速了解分類器預測正確類的能力的方法。



          6.1 基礎使用


          from sklearn.datasets import make_classification
          from sklearn.model_selection import train_test_split
          from sklearn.ensemble import RandomForestClassifier
          from yellowbrick.classifier import ClassPredictionError
          
          
          # Create classification dataset
          X, y=make_classification(
              n_samples=1000, n_classes=5, n_informative=3, n_clusters_per_class=1,
              random_state=36,
          )
          
          classes=["apple", "kiwi", "pear", "banana", "orange"]
          
          # Perform 80/20 training/test split
          X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.20,
                                                              random_state=42)
          # Instantiate the classification model and visualizer
          visualizer=ClassPredictionError(
              RandomForestClassifier(random_state=42, n_estimators=10), classes=classes
          )
          
          # Fit the training data to the visualizer
          visualizer.fit(X_train, y_train)
          
          # Evaluate the model on the test data
          visualizer.score(X_test, y_test)
          
          # Draw visualization
          visualizer.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          在上面的例子中,雖然RandomForestClassifier似乎很擅長根據水果的特征正確地預測蘋果,但它經常錯誤地將梨標記為獼猴桃,而將獼猴桃錯誤地標記為香蕉。

          相比之下,在下面的例子中,RandomForestClassifier在正確預測默認情況下的賬戶方面做得很好,但在預測賬戶持有人是否保持了賬單的流動方面,就有點像拋硬幣一樣困難。


          from sklearn.ensemble import RandomForestClassifier
          from yellowbrick.classifier import ClassPredictionError
          from yellowbrick.datasets import load_credit
          
          X, y=load_credit()
          
          classes=['account in default', 'current with bills']
          
          # Perform 80/20 training/test split
          X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.20,
                                                              random_state=42)
          
          # Instantiate the classification model and visualizer
          visualizer=ClassPredictionError(
              RandomForestClassifier(n_estimators=10), classes=classes
          )
          
          # Fit the training data to the visualizer
          visualizer.fit(X_train, y_train)
          
          # Evaluate the model on the test data
          visualizer.score(X_test, y_test)
          
          # Draw visualization
          visualizer.show();

          添加圖片注釋,不超過 140 字(可選)

          png

          6.2 快速方法

          使用關聯的快速方法,可以在一行中實現與上述類似的功能class_prediction_error。此方法將實例化ClassPredictionError可視化程序并將其適合于訓練數據,然后將其在可選提供的測試數據(或未提供的訓練數據)上評分。


          from sklearn.svm import LinearSVC
          from sklearn.model_selection import train_test_split as tts
          from yellowbrick.classifier import class_prediction_error
          from yellowbrick.datasets import load_occupancy
          
          # Load the dataset and split into train/test splits
          X, y=load_occupancy()
          X_train, X_test, y_train, y_test=tts(
              X, y, test_size=0.2, shuffle=True
          )
          
          class_prediction_error(
              LinearSVC(random_state=42),
              X_train, y_train, X_test, y_test,
              classes=["vacant", "occupied"]
          );

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/svm/base.py:922: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. "the number of iterations.", ConvergenceWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          7 辨別閾值

          相對于二分類器的識別閾值,對精度、召回率、f1得分和隊列率進行可視化。辨別閾值是選擇正類而不是負類的概率或得分。通常,這個值設置為50%,但是可以調整閾值,以增加或減少對誤報或其他應用因素的敏感性。(該可視化工具僅適用于二進制分類。)



          7.1 判別閾值


          from sklearn.linear_model import LogisticRegression
          
          from yellowbrick.classifier import DiscriminationThreshold
          from yellowbrick.datasets import load_spam
          
          # Load a binary classification dataset
          X, y=load_spam()
          
          # Instantiate the classification model and visualizer
          model=LogisticRegression(multi_class="auto", solver="liblinear")
          visualizer=DiscriminationThreshold(model)
          
          visualizer.fit(X, y)        # Fit the data to the visualizer
          visualizer.show();           # Finalize and render the figure

          /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/svm/base.py:922: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. "the number of iterations.", ConvergenceWarning) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/svm/base.py:922: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. "the number of iterations.", ConvergenceWarning) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/sklearn/svm/base.py:922: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. "the number of iterations.", ConvergenceWarning)

          添加圖片注釋,不超過 140 字(可選)

          png

          二進制分類算法的一種常見用法是使用它們產生的分數或概率來確定需要特殊處理的案例。例如,防欺詐應用程序可能使用分類算法來確定交易是否可能是欺詐性的,是否需要詳細調查。在上圖中,我們提供了一個示例,其中二進制分類器確定電子郵件是“垃圾郵件”(肯定的情況)還是“非垃圾郵件”(否定的情況)。被檢測為垃圾郵件的電子郵件將移至隱藏文件夾,并最終被刪除。

          許多分類器使用Decision_function對陽性分類評分,或使用predict_proba函數計算陽性分類的概率。如果分數或概率大于某個判別閾值,則選擇肯定類別,否則選擇否定類別。

          一般來說,閾值在案例之間是平衡的,并設置為0.5或50%的概率。但是,這個閾值可能不是最優閾值:對于一個辨別閾值,精度和召回率之間通常存在反向關系。通過調整分類器的閾值,可以將F1得分(精度和召回率的調和平均值)調整為可能的最佳匹配,或者調整分類器以使其行為最適合特定應用程序。分類器是通過考慮以下指標來調整的:

          ?精度:精度的提高降低了誤報的數量;當特殊處理的成本很高(例如,在防止欺詐或丟失重要電子郵件上浪費時間)時,應該優化這個度量。?召回率:召回率的增加降低漏掉陽性類別的可能性;在至關重要的情況下,即使以更多的誤報為代價,也應該優化此指標。?F1得分:F1得分為precision和recall之間的調和平均值。fbeta參數確定計算此度量時精度和召回率的相對權重,默認設置為1或F1。優化此度量可以在精確度和召回率之間取得最佳平衡。?排隊率:“隊列”是垃圾郵件文件夾或欺詐調查臺的收件箱。該指標描述了必須檢查的實例的百分比。如果審核的成本很高(例如預防欺詐),則必須在業務需求方面將其降至最低;如果沒有(例如垃圾郵件過濾器),則可以對其進行優化以確保收件箱保持整潔。

          在上圖中,我們看到可視化器已調整為尋找最佳F1分數,該分數標注為閾值0.43。為了考慮模型相對于度量的變化(顯示為中值曲線周圍的填充區域),模型在多個訓練/測試拆分中多次運行。

          7.2 快速方法

          上面的相同功能可以通過關聯的快速方法來實現discrimination_threshold。此方法將DiscriminationThreshold使用關聯的參數構建對象,將其擬合,然后(可選)立即顯示它.


          from yellowbrick.classifier.threshold import discrimination_threshold
          from yellowbrick.datasets import load_occupancy
          from sklearn.neighbors import KNeighborsClassifier
          import numpy as np
          
          #Load the classification dataset
          X, y=load_occupancy()
          
          # Instantiate the visualizer with the classification model
          model=KNeighborsClassifier(3)
          
          # exclude設定不顯示的指標
          # argmax閾值評價的指標,可選'precision','recall','fscore',None,默認'f1score'
          discrimination_threshold(model, X, y,exclude='queue_rate', argmax='precision');

          添加圖片注釋,不超過 140 字(可選)

          png

          8 參考

          https://www.scikit-yb.org/en/latest/api/classifier/confusion_matrix.html

          https://www.scikit-yb.org/en/latest/api/classifier/classification_report.html

          https://www.scikit-yb.org/en/latest/api/classifier/rocauc.html

          https://www.scikit-yb.org/en/latest/api/classifier/prcurve.html

          https://www.scikit-yb.org/en/latest/api/target/class_balance.html

          https://www.scikit-yb.org/en/latest/api/classifier/class_prediction_error.html

          https://www.scikit-yb.org/en/latest/api/classifier/threshold.html


          引用鏈接

          [1] 代碼下載: https://github.com/luohenyueji/Python-Study-Notes/tree/master/Documents/Yellowbrick%E4%BD%BF%E7%94%A8%E7%AC%94%E8%AE%B0

          [2] scikit learn文檔: http://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html

          [3] https://blog.csdn.net/u010551621/article/details/46907575: https://blog.csdn.net/u010551621/article/details/469075750

          天都市報7月25日訊(記者汪亮亮 通訊員張敏 孫亞云)2018世界機器人大賽總決賽即將于7月26日-29日在武漢開發區舉行。屆時,來自以色列、俄羅斯、澳大利亞等國家的數百支青少年隊伍,將與來自全國的4000余名青少年選手共聚一堂,逐夢機器人界的“奧林匹克”。

          據本次大賽主辦方介紹,7月27日2018世界機器人大賽全球總決賽開幕,7月27日-28日將舉行資格賽,29日上午將舉行總決賽,其中來自北大的水下機器人、浙大的三對三足球賽項目,以及聯盟賽合作項目極具看點,活動期間還將有創新科研獎項頒發以及快閃等活動,精彩不容錯過。據了解,此次賽事免費對公眾開放,由于受場地限制,每天限量發放1000張入場券,感興趣的市民朋友可在大麥網預訂或到比賽現場提前索取(https://piao.damai.cn/158906.html?spm=a2oeg.search_category.0.0.7e0639c0jUbPRF)。據悉,網上訂票后成功后,您的手機會收到一個碼,不用再付快遞費領紙質票。

          本次大賽共設有BCI腦控類、共融機器人類、工業機器人類、青少年機器人設計類和無人船公開賽五大類賽事,共計30余個賽項,其中,共融機器人類、工業機器人類賽事屬首次舉辦。廣泛涉及人形機器人、協作機器人、輪式機器人以及教育機器人等領域,涵蓋了全年齡層次的參賽群體。


          主站蜘蛛池模板: 91福利国产在线观一区二区| 国产精品视频一区二区三区| 日韩人妻无码一区二区三区久久 | 69福利视频一区二区| 亚洲高清偷拍一区二区三区| 亚洲一区精彩视频| 亚洲一区无码精品色| 国产伦精品一区二区三区免.费| 亚洲国产视频一区| 无码乱人伦一区二区亚洲一| 一区二区三区无码视频免费福利 | 国产福利电影一区二区三区,亚洲国模精品一区 | 中文字幕无线码一区| 亚洲视频在线一区二区| 精品视频在线观看一区二区| 国产乱子伦一区二区三区| 国产精品无码一区二区三区在| 亚洲一区二区三区国产精华液| 无码国产精品一区二区免费 | 无码喷水一区二区浪潮AV | 久久久久人妻精品一区蜜桃| 国产精品一区12p| 夜夜嗨AV一区二区三区| 美女啪啪一区二区三区| 亚洲一区免费观看| 国产精品视频一区二区三区无码| 夜色阁亚洲一区二区三区| 国产在线视频一区二区三区| 琪琪see色原网一区二区| 中文字幕一区在线| 亚洲图片一区二区| 韩国美女vip福利一区| 麻豆精品人妻一区二区三区蜜桃| 无码少妇一区二区三区芒果| 天码av无码一区二区三区四区| 一区二区三区杨幂在线观看| 国产一区二区在线观看app| 亚洲国产精品一区二区成人片国内 | 91精品一区国产高清在线| 国产a∨精品一区二区三区不卡| 亚洲视频一区二区三区四区|