Good morning. I have list, that consist 2 probabilities:
[[0.84285885 0.15714115]
[0.67180324 0.32819676]
[0.95325917 0.04674083]
...
[0.38825085 0.61174915]
[0.45577896 0.54422104]
[0.7975929 0.2024071 ]]
and another list, that consist ony one:
[[5.4913871e-02]
[7.6471776e-02]
[4.1644130e-04]
...
[9.6865553e-01]
[9.8211896e-01]
[3.5812762e-01]]
How to transform this list to form of first list? Apply 1-x
to each element and get a list of the same shape. Thanks.
If you have numpy array:
a = np.array(
[
[5.4913871e-02],
[7.6471776e-02],
[4.1644130e-04],
[9.6865553e-01],
[9.8211896e-01],
[3.5812762e-01],
]
)
Then:
print(np.column_stack((a[:, 0], 1 - a[:, 0])))
Prints:
[[5.49138710e-02 9.45086129e-01]
[7.64717760e-02 9.23528224e-01]
[4.16441300e-04 9.99583559e-01]
[9.68655530e-01 3.13444700e-02]
[9.82118960e-01 1.78810400e-02]
[3.58127620e-01 6.41872380e-01]]