Main Content

describe

生成された特徴量の説明

R2021a 以降

    説明

    describe(Transformer) は、Transformer で生成された特徴量の説明を出力します。関数 gencfeatures または genrfeatures を使用して FeatureTransformer オブジェクト Transformer を作成します。

    describe(Transformer,Index) は、Index で識別される特徴量の説明を出力します。

    Info = describe(___) は、特徴量の説明を table で返します。Info の行の名前は特徴量の名前に対応します。

    すべて折りたたむ

    gencfeatures を使用して予測子データの table から特徴量を生成します。生成された特徴量をオブジェクト関数 describe を使用して調べます。

    停電のデータをワークスペースに table として読み込みます。欠損値がある観測値を削除し、table の最初の数行を表示します。

    outages = readtable("outages.csv");
    Tbl = rmmissing(outages);
    head(Tbl)
           Region             OutageTime          Loss     Customers       RestorationTime              Cause       
        _____________    ____________________    ______    __________    ____________________    ___________________
    
        {'SouthWest'}    01-Feb-2002 12:18:00    458.98    1.8202e+06    07-Feb-2002 16:50:00    {'winter storm'   }
        {'SouthEast'}    07-Feb-2003 21:15:00     289.4    1.4294e+05    17-Feb-2003 08:14:00    {'winter storm'   }
        {'West'     }    06-Apr-2004 05:44:00    434.81    3.4037e+05    06-Apr-2004 06:10:00    {'equipment fault'}
        {'MidWest'  }    16-Mar-2002 06:18:00    186.44    2.1275e+05    18-Mar-2002 23:23:00    {'severe storm'   }
        {'West'     }    18-Jun-2003 02:49:00         0             0    18-Jun-2003 10:54:00    {'attack'         }
        {'NorthEast'}    16-Jul-2003 16:23:00    239.93         49434    17-Jul-2003 01:12:00    {'fire'           }
        {'MidWest'  }    27-Sep-2004 11:09:00    286.72         66104    27-Sep-2004 16:37:00    {'equipment fault'}
        {'SouthEast'}    05-Sep-2004 17:48:00    73.387         36073    05-Sep-2004 20:46:00    {'equipment fault'}
    

    変数の中には、OutageTimeRestorationTime など、分類器の fitcensemble のような学習関数でサポートされないデータ型の変数も含まれています。

    Tbl 内の予測子から、バギング アンサンブルの学習に使用できる特徴量を 25 個生成します。table 変数 Region を応答として指定します。

    Transformer = gencfeatures(Tbl,"Region",25,TargetLearner="bag")
    Transformer = 
      FeatureTransformer with properties:
    
                         Type: 'classification'
                TargetLearner: 'bag'
        NumEngineeredFeatures: 22
          NumOriginalFeatures: 3
             TotalNumFeatures: 25
    
    

    Transformer オブジェクトに、生成された特徴量とそれらの作成に使用された変換に関する情報が格納されます。

    生成された特徴量について詳しく確認するには、オブジェクト関数 describe を使用します。

    Info = describe(Transformer)
    Info=25×4 table
                                         Type        IsOriginal          InputVariables                                                            Transformations                                                 
                                      ___________    __________    ___________________________    _________________________________________________________________________________________________________________
    
        Loss                          Numeric          true        Loss                           ""                                                                                                               
        Customers                     Numeric          true        Customers                      ""                                                                                                               
        c(Cause)                      Categorical      true        Cause                          "Variable of type categorical converted from a cell data type"                                                   
        RestorationTime-OutageTime    Numeric          false       OutageTime, RestorationTime    "Elapsed time in seconds between OutageTime and RestorationTime"                                                 
        sdn(OutageTime)               Numeric          false       OutageTime                     "Serial date number from 01-Feb-2002 12:18:00"                                                                   
        woe3(c(Cause))                Numeric          false       Cause                          "Variable of type categorical converted from a cell data type -> Weight of Evidence (positive class = SouthEast)"
        doy(OutageTime)               Numeric          false       OutageTime                     "Day of the year"                                                                                                
        year(OutageTime)              Numeric          false       OutageTime                     "Year"                                                                                                           
        kmd1                          Numeric          false       Loss, Customers                "Euclidean distance to centroid 1 (kmeans clustering with k = 10)"                                               
        kmd5                          Numeric          false       Loss, Customers                "Euclidean distance to centroid 5 (kmeans clustering with k = 10)"                                               
        quarter(OutageTime)           Numeric          false       OutageTime                     "Quarter of the year"                                                                                            
        woe2(c(Cause))                Numeric          false       Cause                          "Variable of type categorical converted from a cell data type -> Weight of Evidence (positive class = NorthEast)"
        year(RestorationTime)         Numeric          false       RestorationTime                "Year"                                                                                                           
        month(OutageTime)             Numeric          false       OutageTime                     "Month of the year"                                                                                              
        Loss.*Customers               Numeric          false       Loss, Customers                "Loss .* Customers"                                                                                              
        tods(OutageTime)              Numeric          false       OutageTime                     "Time of the day in seconds"                                                                                     
          ⋮
    
    

    table Info から次のことがわかります。

    • 生成された最初の 3 つの特徴量は Tbl が元になっています。このうち、c(Cause) は、元の変数 Cause がカテゴリカル変数に変換されたものです。

    • 変数 OutageTimeRestorationTimedatetime 変数であり、バギング アンサンブル モデルの学習には使用できないため、生成された特徴量には含まれていません。ただし、生成された特徴量の中には、4 番目の RestorationTime-OutageTime のように、それらの変数から派生した特徴量が多数含まれています。

    • 一部の生成された特徴量については複数の変換が組み合わされています。たとえば、6 番目の特徴量 woe3(c(Cause)) は、変数 Cause をカテゴリカル変数に変換してから、その変数の証拠の重みの値を計算して生成されたものです。

    genrfeatures を使用して予測子データの table から特徴量を生成します。生成された特徴量をオブジェクト関数 describe を使用して調べます。

    停電のデータをワークスペースに table として読み込みます。欠損値がある観測値を削除し、table の最初の数行を表示します。

    outages = readtable("outages.csv");
    Tbl = rmmissing(outages);
    head(Tbl)
           Region             OutageTime          Loss     Customers       RestorationTime              Cause       
        _____________    ____________________    ______    __________    ____________________    ___________________
    
        {'SouthWest'}    01-Feb-2002 12:18:00    458.98    1.8202e+06    07-Feb-2002 16:50:00    {'winter storm'   }
        {'SouthEast'}    07-Feb-2003 21:15:00     289.4    1.4294e+05    17-Feb-2003 08:14:00    {'winter storm'   }
        {'West'     }    06-Apr-2004 05:44:00    434.81    3.4037e+05    06-Apr-2004 06:10:00    {'equipment fault'}
        {'MidWest'  }    16-Mar-2002 06:18:00    186.44    2.1275e+05    18-Mar-2002 23:23:00    {'severe storm'   }
        {'West'     }    18-Jun-2003 02:49:00         0             0    18-Jun-2003 10:54:00    {'attack'         }
        {'NorthEast'}    16-Jul-2003 16:23:00    239.93         49434    17-Jul-2003 01:12:00    {'fire'           }
        {'MidWest'  }    27-Sep-2004 11:09:00    286.72         66104    27-Sep-2004 16:37:00    {'equipment fault'}
        {'SouthEast'}    05-Sep-2004 17:48:00    73.387         36073    05-Sep-2004 20:46:00    {'equipment fault'}
    

    変数の中には、OutageTimeRestorationTime など、fitrensemble のような回帰モデル学習関数でサポートされないデータ型の変数も含まれています。

    Tbl 内の予測子から、バギング アンサンブルの学習に使用できる特徴量を 25 個生成します。table 変数 Loss を応答として指定します。

    rng("default") % For reproducibility
    Transformer = genrfeatures(Tbl,"Loss",25,TargetLearner="bag")
    Transformer = 
      FeatureTransformer with properties:
    
                         Type: 'regression'
                TargetLearner: 'bag'
        NumEngineeredFeatures: 22
          NumOriginalFeatures: 3
             TotalNumFeatures: 25
    
    

    Transformer オブジェクトに、生成された特徴量とそれらの作成に使用された変換に関する情報が格納されます。

    生成された特徴量について詳しく確認するには、オブジェクト関数 describe を使用します。

    Info = describe(Transformer)
    Info=25×4 table
                                         Type        IsOriginal          InputVariables                                     Transformations                          
                                      ___________    __________    ___________________________    ___________________________________________________________________
    
        c(Region)                     Categorical      true        Region                         "Variable of type categorical converted from a cell data type"     
        Customers                     Numeric          true        Customers                      ""                                                                 
        c(Cause)                      Categorical      true        Cause                          "Variable of type categorical converted from a cell data type"     
        kmd2                          Numeric          false       Customers                      "Euclidean distance to centroid 2 (kmeans clustering with k = 10)" 
        kmd1                          Numeric          false       Customers                      "Euclidean distance to centroid 1 (kmeans clustering with k = 10)" 
        kmd4                          Numeric          false       Customers                      "Euclidean distance to centroid 4 (kmeans clustering with k = 10)" 
        kmd5                          Numeric          false       Customers                      "Euclidean distance to centroid 5 (kmeans clustering with k = 10)" 
        kmd9                          Numeric          false       Customers                      "Euclidean distance to centroid 9 (kmeans clustering with k = 10)" 
        cos(Customers)                Numeric          false       Customers                      "cos( )"                                                           
        RestorationTime-OutageTime    Numeric          false       OutageTime, RestorationTime    "Elapsed time in seconds between OutageTime and RestorationTime"   
        kmd6                          Numeric          false       Customers                      "Euclidean distance to centroid 6 (kmeans clustering with k = 10)" 
        kmi                           Categorical      false       Customers                      "Cluster index encoding (kmeans clustering with k = 10)"           
        kmd7                          Numeric          false       Customers                      "Euclidean distance to centroid 7 (kmeans clustering with k = 10)" 
        kmd3                          Numeric          false       Customers                      "Euclidean distance to centroid 3 (kmeans clustering with k = 10)" 
        kmd10                         Numeric          false       Customers                      "Euclidean distance to centroid 10 (kmeans clustering with k = 10)"
        hour(RestorationTime)         Numeric          false       RestorationTime                "Hour of the day"                                                  
          ⋮
    
    

    生成された最初の 3 つの特徴量は Tbl が元になっています。このうち、変数 categorical は、元の変数 Region および Cause が変換されたものです。

    Info(1:3,:) % describe(Transformer,1:3)
    ans=3×4 table
                        Type        IsOriginal    InputVariables                           Transformations                        
                     ___________    __________    ______________    ______________________________________________________________
    
        c(Region)    Categorical      true          Region          "Variable of type categorical converted from a cell data type"
        Customers    Numeric          true          Customers       ""                                                            
        c(Cause)     Categorical      true          Cause           "Variable of type categorical converted from a cell data type"
    
    

    変数 OutageTimeRestorationTimedatetime 変数であり、バギング アンサンブル モデルの学習には使用できないため、生成された特徴量には含まれていません。ただし、生成された特徴量の中には、10 番目の特徴量 RestorationTime-OutageTime のように、それらの変数から派生した特徴量が一部含まれています。

    Info(10,:) % describe(Transformer,10)
    ans=1×4 table
                                       Type      IsOriginal          InputVariables                                   Transformations                         
                                      _______    __________    ___________________________    ________________________________________________________________
    
        RestorationTime-OutageTime    Numeric      false       OutageTime, RestorationTime    "Elapsed time in seconds between OutageTime and RestorationTime"
    
    

    一部の生成された特徴量については複数の変換が組み合わされています。たとえば、19 番目の特徴量 fenc(c(Cause)) は、変数 Cause を 10 のカテゴリでカテゴリカル変数に変換してから、そのカテゴリの頻度を計算して生成されたものです。

    Info(19,:) % describe(Transformer,19)
    ans=1×4 table
                           Type      IsOriginal    InputVariables                                                  Transformations                                               
                          _______    __________    ______________    ____________________________________________________________________________________________________________
    
        fenc(c(Cause))    Numeric      false           Cause         "Variable of type categorical converted from a cell data type -> Frequency encoding (number of levels = 10)"
    
    

    入力引数

    すべて折りたたむ

    特徴量変換器。FeatureTransformer オブジェクトとして指定します。

    説明対象の特徴量。特徴量の位置を示す数値ベクトルまたは logical ベクトルとして、あるいは、特徴量の名前を示す文字ベクトルの string 配列または cell 配列として指定します。

    例: 1:12

    データ型: single | double | logical | string | cell

    出力引数

    すべて折りたたむ

    特徴量の説明。table として返されます。各行が生成された特徴量に対応し、各列で次の情報が提供されます。

    列名説明
    Type特徴量のデータ型 (numeric または categorical) を示します。
    IsOriginal特徴量が元の特徴量 (true) と設計された特徴量 (false) のどちらであるかを示します。
    InputVariables特徴量の生成に使用された元の特徴量を示します。
    Transformations特徴量の生成に使用された変換の説明を適用された順序で示します。詳細については、特徴変換を参照してください。

    アルゴリズム

    すべて折りたたむ

    特徴変換

    Info.Transformations に記述されるいくつかの複雑な特徴変換の説明について、次の表に追加情報を示します。

    特徴量の名前の例Info に記述される変換の説明の例追加情報
    eb4(Variable)Equal-width binning (number of bins = 4)Variable の値が 4 個の同じ幅のビンに分割されます。結果の特徴量はカテゴリカル変数です。
    fenc(Variable)Frequency encoding (number of levels = 10)Variable10 個のカテゴリ (または水準) の周波数が計算されます。結果の特徴量の各カテゴリカル値が対応するカテゴリの周波数に置き換えられ、数値変数が作成されます。
    kmc1Centroid encoding (component #1) (kmeans clustering with k = 10)k-means クラスタリングを使用して、各観測値が 10 個のクラスターのいずれかに割り当てられます。結果の特徴量の各行は観測値に対応し、その観測値に関連するクラスター重心の 1 番目の成分になります。結果の特徴量は数値変数です。
    kmd4Euclidean distance to centroid 4 (kmeans clustering with k = 10)k-means クラスタリングを使用して、各観測値が 10 個のクラスターのいずれかに割り当てられます。結果の特徴量の各行は、対応する観測値から 4 番目のクラスターの重心までのユークリッド距離になります。結果の特徴量は数値変数です。
    kmiCluster index encoding (kmeans clustering with k = 10)k-means クラスタリングを使用して、各観測値が 10 個のクラスターのいずれかに割り当てられます。結果の特徴量の各行は、対応する観測値のクラスター インデックスになります。結果の特徴量はカテゴリカル変数です。
    q50(Variable)Equiprobable binning (number of bins = 50)Variable の値が 50 個の同じ確率のビンに分割されます。結果の特徴量はカテゴリカル変数です。
    woe5(Variable)Weight of Evidence (positive class = Class5)

    この変換は分類問題にのみ使用できます。

    次の手順を実行して結果の特徴量が作成されます。

    • 応答が Class5 である観測値の総数 (a) とそれ以外の応答をもつ観測値の総数 (b) を計算します。

    • Variable がノミナル カテゴリカル変数であると仮定します。すると、Variable のそれぞれのカテゴリについて、そのカテゴリ内で応答が Class5 である観測値の数 (c) とそれ以外の応答をもつ観測値の数 (d) を計算します。

      代わりに Variable が順序カテゴリカル変数であると仮定します。すると、Variable のそれぞれのカテゴリについて、そのカテゴリ内またはより小さなカテゴリ内のすべての観測値を求め、これらの観測値の中で応答が Class5 である観測値の数 (c) とそれ以外の応答をもつ観測値の数 (d) を計算します。

    • それぞれのカテゴリについて、証拠の重み (WoE) を次のように計算します。

      ln((c+0.5)/a(d+0.5)/b).

    • 各カテゴリカル値を対応する WoE に置き換えて、数値変数を作成します。

    バージョン履歴

    R2021a で導入