hi i'm kinda new on python and i'm trying to create a code that compares standard deviation of different feature in order to extract the smallest one, i'm not sure about the code i've made
minstd=0;
for feature in range(13):
var = np.var(trainx[trainy==1,feature])
std = np.sqrt(var) # deviazione standard
a = std(feature)-std(feature+1)
if a>0
minstd=std(feature);
else
minstd=std(feature+1);
minstd
i also got this error
File "<ipython-input-18-44801ce3407e>", line 6
if a>0
^SyntaxError: invalid syntax
can someone explain the problem?
Sorry, but I have to say what you need is some basic python grammar.
;
at the end of the line:
behind the bracket (as well as for some control flow keywords like for, if
...;{}
in C or C++)
Your code should be like this:minstd=0
for feature in range(13):
var = np.var(trainx[trainy==1,feature])
std = np.sqrt(var) # deviazione standard
a = std(feature)-std(feature+1)
if a>0:
minstd=std(feature);
else:
minstd=std(feature+1);
minstd
``