オプションの設定

ここでは、トレーニング オプション ファイルを作成する必要があります。このファイルには、モデルに関する情報と、モデルのトレーニングに適用するオプションが含まれます。このファイルは、UFT-8 エンコーディングの XML 形式で、以下に示すヘッダと必須トレーニング機能を含む必要があります。

トレーニング オプション ファイル内のヘッダ

ヘッダには、モデルの詳細情報、タイプ、テストおよび入力ファイルのパスが記述されます。

  • modelName: モデル名
  • modelType: モデルのタイプ (ここではテキスト分類を意味する TC)
  • modelDescription: モデルの説明
  • inputFilePath: モデルのトレーニングに使用する入力ファイルの場所
  • testFilePath: テスト ファイルの場所
    注:

    テスト ファイルは、モデルの有効性を評価します。さまざまなトレーニング パラメータによるカスタム モデルの動作を判定します。ベスト プラクティスとして、カスタム モデルのトレーニングまたは評価には、異なる入力およびテスト ファイルを使用することを推奨します。

    algorithm: モデルのトレーニングに使用する機械学習アルゴリズム (デフォルトは MaxEnt)

トレーニング機能

以下のトレーニング機能を使用して、新しいカテゴリを作成できます。
注: 複数の機能を使用する場合、ファイル内でのそれらの順序は任意です。
  • 言語機能: 言語プロパティを指定します。
    • Stemming: 単語を語幹部分に短縮します。例えば、"insurer"、"insured"、"insures" はすべて、語幹である "insure" に短縮できます。
      <trainingFeature>
      		<featureName>Stemming</featureName>
      </trainingFeature>
  • キーワード機能: キーワードのリストを定義します。
    • IgnoreWords: ストップワードとも呼ばれるこの機能は、"the"、"and"、"but" など、分類に影響を与えない一般的な単語を除外します。これらの単語は、空白を入れずにカンマのみで区切る必要があります。この機能では Append キーも使用できます。これを "True" に設定すると、ストップワードの既存リストに追加されます。
      <trainingFeature>
      		<featureName>IgnoreWords</featureName>
      		<featureParams>
      			<entry>
      				<key>WordList</key>
      				<value>
      					and,the,for,with,still,tri,rep,cust,keep,get,req,call
      				</value>
      			</entry>
      			<entry>
      				<key>Append</key>
      				<value>True</value>
      			</entry>
      		</featureParams>
      	</trainingFeature>
    • CategoryKeywords: 複数のカスタム リストに属するキーワードのリストのカテゴリを識別します。例えば、CategoryKeywords リストの Weekdays には、Monday、Tuesday、Wednesday、Thursday、および Friday という Keywords が含まれます。

      この機能では、マッチングで大文字と小文字を区別するかどうかも指定できます。デフォルトは true (大文字と小文字を区別) です。

      <trainingFeature>
      	<featureName>CategoryKeywords</featureName>
      	<featureParams>
      		<entry>
      			<key>Weekdays</key> 
                          <!-- List of weekdays -->
      			<value>Monday,Tuesday,Wednesday,Thursday,Friday</value>
      		</entry>
      		<entry>
      			<key>WeekendDays</key>
                          <!-- List of weekend days -->
      			<value>Saturday,Sunday</value>
      		</entry>
      		<entry>
      			<key>CaseSensitive</key>
                          <value>True</value>
      		</entry>
      	</featureParams>
      </trainingFeature>
    • KeyWords: DaysOfWeekMonth など、ユーザが指定したカスタム リストに属する単語を検索します。大文字と小文字を区別して検索するかどうかも指定できます。デフォルトは "true" (大文字と小文字を区別) です。
      <trainingFeature>
      	<featureName>KeyWords</featureName>
      	<featureParams>
      		<entry>
      			<key>KeyWordList</key>
      			<value>Monday,Tuesday</value>
      		</entry>
      		<entry>
      			<key>CaseSensitive</key>
      			<value>False</value>
      		</entry>
      	</featureParams>
      </trainingFeature>
  • 語彙機能: 語彙プロパティを指定します。
    • NGram: 長い文字列の一部を検索します。"n" は検索する単語の数を表します。例えば、"to be or not to be" というフレーズを探している場合に、"to" または "be" というユニグラム、"to be" または "or not" というバイグラム、"to be or" または "not to be" というトライグラムを検索できます。
      <trainingFeature>
      		<featureName>NGram</featureName>
      		<featureParams>
      			<entry>
      				<key>Count</key>
      				<value>3</value>
      			</entry>
      		</featureParams>
      </trainingFeature>
トレーニング オプション ファイルのサンプルを以下に示します。
<trainingOptions>
	<modelName>modelone</modelName>
	<modelType>TC</modelType>
	<modelDescription>modelOne</modelDescription>
	<inputFilePath>C:/SpectrumIE/textclassification/train_Input.csv</inputFilePath>
	<testFilePath>C:/SpectrumIE/textclassification/train_Test.txt</testFilePath>
    <algorithm>SVM</algorithm>
	
	<trainingFeatures>

	<!-- Keyword features -->	
	<trainingFeature>
		<featureName>IgnoreWords</featureName>
		<featureParams>
			<entry>
				<key>WordList</key>
				<value>
					and,the,for,with,still,tri,rep,cust,keep,get,req,call
				</value>
			</entry>
			<entry>
				<key>Append</key>
				<value>True</value>
			</entry>
		</featureParams>
	</trainingFeature>

	<trainingFeature>
		<featureName>CategoryKeywords</featureName>
		<featureParams>
			<entry>
				<key>Category1/key>
				<value>CategoryKeyword1,CategoryKeyword2</value>
			</entry>
			<entry>
				<key>Category2/key>
				<value>CategoryKeyword3,CategoryKeyword4</value>
			</entry>                                                  
             </featureParams>
	</trainingFeature>

	<trainingFeature>
            <featureName>KeyWords</featureName>
	      <featureParams>
			<entry>
				<key>KeyWordList</key>
				<value>
					jam,misfeed,install,help,mechanical,failure,jam,pc,connection
				</value>
			</entry>
		</featureParams>
	</trainingFeature>

	<!-- Linguistic feature -->
	<trainingFeature>
		<featureName>Stemming</featureName>
	</trainingFeature>
	
	<!-- Lexical feature -->
	<trainingFeature>
		<featureName>NGram</featureName>
		<featureParams>
			<entry>
				<key>Count</key>
				<value>3</value>
			</entry>
		</featureParams>
	</trainingFeature>

	</trainingFeatures>
	</trainingOptions>