My input:
test_set, like:
[['4.5', '6', 'U1'], ['5', '5', 'U1'], ['5', '7', 'U1'], ['7', '6.5', 'U1'], ['5.5', '5.5', 'U2'], ['5.5', '7.5', 'U2']]
After this I made a lot of calculation with this data, and my "final" result is array of test_set_final
test_set_final=array([[ 1.6488378 ],
[ 2.61782463],
[ 0.62126043],
[ 1.00322042],
[ 2.08938831],
[ 0.09282412]])
Now what I want to do is for test_set_fina开发者_JAVA百科l
, add class name which is "stored" in last place of test_set, so that result will look, for example for test_set_final:
test_set_final=[['1.6488378' , 'U1'],['2.61782463' , 'U1'],['0.62126043' , 'U1'],['1.00322042' , 'U1'],['2.08938831' , 'U2'],,['0.09282412' , 'U2']]
This "test_set" data is random data and have random name of "classes", but always on last place after comma....
This should do it (had it prepared from the last version of your question):
test_set_final = [[r, c[-1]] for [r], c in zip (test_set_final, test_set)]
Edit: Added unpacking for r
- the example looked different before.
精彩评论