주어진 피쳐 수와 해당 속성의 변종 수를 평가 한 다음 각 브랜치가 하나의 조합/변형을 나타내는 브랜치 트리로 조합을 그립니다.Python을 사용하여 변형 트리를 만들려면 어떻게해야합니까?
예 : 특징 : 색상, 크기, 희미 함. 각 기능마다 속성이 (색상 : 빨강, 초록, 파랑, 크기 : 크고 작음)이 다릅니다.
순열을 통해 변형 수를 찾습니다. 각 조합/변형은 내 변형 트리의 한 지점입니다. 예 : ('red', 'big', 1)은 하나의 가지이고, 'red', 'big', 2는 또 다른 것입니다.
노드와 호가있는이 분기를 끌어낼 수있는 libary가 있습니까? 순열에 대한
코드 :
colors = ['red', 'green', 'blue']
size = ['big','small']
dim = [1,2,3]
from itertools import product
x =list (product(colors,size,dim))
print (x)
print ("Number of variants:",len(x))
[('red', 'big', 1), ('red', 'big', 2), ('red', 'big', 3),
('red', 'small', 1), ('red', 'small', 2), ('red', 'small', 3),
('green', 'big', 1), ('green', 'big', 2), ('green', 'big', 3),
('green', 'small', 1), ('green', 'small', 2), ('green', 'small', 3),
('blue', 'big', 1), ('blue', 'big', 2), ('blue', 'big', 3),
('blue', 'small', 1), ('blue', 'small', 2), ('blue', 'small', 3)]
dim 이미지가 예제 이미지에서 red/big 브랜치에만 표시되는 이유는 무엇입니까? – ikkuh
plotly ...... https : //plot.ly/python/tree-plots/ –
dim은 한 가지 예에 대해서만 설명되었지만 다른 색상/크기 조합에도 나타납니다. – BjoernBorkenkaefer