我创建了一个复选按钮/框,具有以下调用
x=ttk.Checkbutton(tab1,state='disabled',command = lambda j=i,x=k: fCheckButton(j,x))
x.state(['selected'])
Run Code Online (Sandbox Code Playgroud)
该框看起来很好并且被选中,但是它在加载时出现,其中有一个黑框,这似乎与它的状态无关。
我一直在寻找原因,但实际上找不到任何有同样问题的人。
谢谢
所以下面是我的代码片段,一切正常。只是好奇而不是显示具有特定颜色的条,是否可以将图像应用于条,例如国家/地区国旗等(请忽略我不一致的参数传递顺序)
谢谢
l_images=["australia.png","turkey.png"] # this is desired
l_colors=["pink","blue"]
if (l_bar_dir=="vertical"):
plt.bar(xs2,ys,tick_label=xs,color=l_colors,bottom=bottoms,width=bar_width,align='center') # set plot to be a bar graph
else:
plt.barh(bottom=xs2,width=ys,tick_label=xs,align='center',color=l_colors) # set plot to be a bar graph
Run Code Online (Sandbox Code Playgroud) 我有一个用tkinter编写的GUI,并且一切正常。我想对其进行增强,以便当用户用鼠标左键单击某个选项卡时,将执行一个方法。我以为这是直截了当的,但我无法解决。我的代码是
def f_x():
print('entered this method')
tab4e = ttk.Frame(notebook2,width=C_WIDTH,height=C_TAB_HEIGHT)
tab4e.bind("<Button-1>",f_x())
Run Code Online (Sandbox Code Playgroud) 如果我通过train_test_split函数使用数据运行一个简单的dtree回归模型,我会得到很好的r2得分和较低的mse值。
training_data = pandas.read_csv('data.csv',usecols=['y','x1','x2','x3'])
y = training_data.iloc[:,0]
x = training_data.iloc[:,1:]
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.33)
regressor = DecisionTreeRegressor(random_state = 0)
# fit the regressor with X and Y data
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
Run Code Online (Sandbox Code Playgroud)
但是,如果我将数据文件手动拆分为两个文件2/3训练和1/3测试。有一个名为“人”的列,其值是1到9(即人),我使用1-6进行训练,并使用7-9进行测试
我的R2分数为负,且MSE高
training_data = pandas.read_csv("train"+".csv",usecols=['y','x1','x2','x3'])
testing_data = pandas.read_csv("test"+".csv", usecols=['y','x1','x2','x3'])
y_train = training_data.iloc[:,training_data.columns.str.contains('y')]
X_train = training_data.iloc[:,training_data.columns.str.contains('|'.join(['x1','x2','x3']))]
y_test = testing_data.iloc[:,testing_data.columns.str.contains('y')]
X_test = testing_data.iloc[:,testing_data.columns.str.contains('|'.join(l_vars))]
y_train = pandas.Series(y_train['y'], index=y_train.index)
y_test = pandas.Series(y_test['y'], index=y_test.index)
regressor = DecisionTreeRegressor(random_state = 0)
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
Run Code Online (Sandbox Code Playgroud)
我期望大致相同的结果,并且两个调用的所有数据类型似乎都相同。
我想念什么?
我有unix文件
a,b,c,d
e,f,g,h
u,v,x,y
Run Code Online (Sandbox Code Playgroud)
我想分开打印第一个col和其他所有col
即
a,b
a,c
a,d
e,f
e,g
e,h
Run Code Online (Sandbox Code Playgroud)
等等
提前致谢