如果还算数

时间:2017-09-15 01:54:54

标签: python-3.x if-statement machine-learning

如何将此数据分类为correct_pred和wrong_pred?

后如何计算
stats_all_score.head()

class   score1  score2  score3
A       1.67    3.60    5.50
A       3.60    3.25    2.10
A       2.25    3.25    3.25
B       1.17    6.50    21.00
C       3.20    3.25    2.30
..      ..      ..      ..

    if (stats_all_score['class'] == 'A' and stats_all_score['score1'] <= 2.20) 
    or (stats_all_score['class'] == 'B' and stats_all_score['score2'] <= 2.20) 
    or (stats_all_score['class'] == 'C' and stats_all_score['score3'] <= 2.20):
        return correct_pred
    else:
        return wrong_pred

File "<ipython-input-16-ffc4cad0f64a>", line 3
    else
        ^
SyntaxError: invalid syntax

1 个答案:

答案 0 :(得分:0)

if语句检查一个条件的结果,而不是多个条件的结果。您需要使用()包装逻辑计算。

if (condition1 or condition2 or condition3):
    return something