def get_feature_stats(self):
# #get input feature
feature_input=self.feature_input.currentText()
try:
if feature_input[0]=='X':
try:
feature_index=int("".join(feature_input[1:]))
feature_index-=1
except:
QtWidgets.QMessageBox.information(self, "Wrong Format","Please enter a feature name in the format: X%d.")
return
elif "".join(feature_input[0]+feature_input[1])=='LD' or "".join(feature_input[0]+feature_input[1])=='PC':
try:
feature_index=int("".join(feature_input[2:]))
feature_index-=1
except:
QtWidgets.QMessageBox.information(self, "Wrong Format","Please enter a feature name in the format: X||LD||PC%d.")
return
else:
QtWidgets.QMessageBox.information(self, "Wrong Format","Feature names must be in the format: X%d.")
return
except:
QtWidgets.QMessageBox.information(self, "Data Not Found","Please load a dataset first.")
return
try:
max_value=self.X[:,feature_index].max()
min_value=self.X[:,feature_index].min()
mean_value=self.X[:,feature_index].mean()
std_value=self.X[:,feature_index].std()
var_value=self.X[:,feature_index].var()
skewness=stats.skew(self.X[:,feature_index])
kurtosis=stats.kurtosis(self.X[:,feature_index],fisher=True)
chi2,chi_p_val=chi2_feature_test(self.X,self.y,int(feature_index))
H_kw,kw_p_val=kw_feature_test(self.X,self.y,int(feature_index))
info_gain=information_gain(self.X,self.y,int(feature_index))
gain_rt=gain_ratio(self.X,self.y,int(feature_index))
except:
QtWidgets.QMessageBox.information(self, "Wrong Index","Feature Index Out Of Bounds.")
return
feature_stats="""Statistics:\n\nMinimum Value: """+str(min_value)\
+"""\n\nMaximum Value: """+str(max_value)\
+"""\n\nMean: """+str(mean_value)\
+"""\n\nStandard Deviation: """+str(std_value)\
+"""\n\nVariance: """+str(var_value)\
+"""\n\nSkewness: """+str(skewness)\
+"""\n\nKurtosis: """+str(kurtosis)\
+"""\n\nChi Squared Test: """+str(chi2[0])\
+"""\n\nKruskal-Wallis Test: """+str(H_kw)\
+"""\n\nInformation Gain: """+str(info_gain)\
+"""\n\nGain Ratio: """+str(gain_rt)
self.feature_stats.setText(feature_stats)
default_predictor.py 文件源码
python
阅读 40
收藏 0
点赞 0
评论 0
评论列表
文章目录