この辞書を取る:
{'local': {'count': 7,
'dining-and-nightlife': {'count': 1,
'bar-clubs': {'count': 1}
},
'activities-events': {'count': 6,
'outdoor-adventures': {'count': 4},
'life-skill-classes': {'count': 2}
}
}}
(30%の余裕の範囲内で)最も関連性の高い一致を判断するにはどうすればよいですか?たとえば、アクティビティイベントのカウントは6であるため、6/7 = 85%であり、その子のアウトドアアドベンチャーのカウントは6のうち4(66%)です。したがって、これから最も関連性の高いカテゴリはアウトドアアドベンチャーです。
この例では:
{'local': {'count': 11,
'dining-and-nightlife': {'count': 4,
'bar-clubs': {'count': 4}
},
'activities-events': {'count': 6,
'outdoor-adventures': {'count': 4},
'life-skill-classes': {'count': 2}
}
}}
バークラブ(100%)での食事とナイトライフ(33%)と、アウトドアアベンチャー(66%)でのアクティビティイベント(54%)の両方を利用してください。
私はパーセンテージカットオフがによって決定されることを望んでいました
cutoff = 0.3
ここでの考え方は、より小さな結果(30%未満)の一致を削除して、どのカテゴリが最も関連性があるかを判断することです。
@FJは以下の質問に答えましたが、ツリーのカウントを更新したいと思います。
初期出力:
{'local': {'activities-events': {'count': 6,
'life-skill-classes': {'count': 2},
'outdoor-adventures': {'count': 4}},
'count': 11,
'dining-and-nightlife': {'bar-clubs': {'count': 4}, 'count': 4}}}
ポスト出力:
{'local': {'activities-events': {'count': 6,
'life-skill-classes': {'count': 2},
'outdoor-adventures': {'count': 4}},
'count': 10,
'dining-and-nightlife': {'bar-clubs': {'count': 4}, 'count': 4}}}