2017-05-01 3 views
0

私はSeabornとMatplotlibを使ってヒートマップをプロットしました。matplotlibとseabornヒートマッププロットを修正するには?

Matplotlibでは、ティックの名前は大丈夫ですが、私は白い線が好きではありません。 白い線はどのように消えますか?

シーボーンでは、ダニの名前は間違っていますが、私はプロットが好きです。 ティックを各四角形の中央に移動するにはどうすればよいですか? ダニの名前を修正するにはどうすればよいですか?最高のスコアはパラメータで0.857である: 'clf__C':100000.0、 'clf__gamma':1E-05

しかしseabornは使用しています: 'clf__C':1E-05、 'clf__gamma':1E-05

Ranking of best parameters 
RandomizedSearchCV took 5.58 seconds for 25 candidates parameter settings. 
Model with rank: 1 
Mean validation score: 0.857 (std: 0.036) 
Parameters: {'clf__C': 100000.0, 'clf__gamma': 1.0000000000000001e-05} 

Model with rank: 2 
Mean validation score: 0.821 (std: 0.048) 
Parameters: {'clf__C': 10000000000.0, 'clf__gamma': 1.0000000000000001e-05} 

Model with rank: 3 
Mean validation score: 0.720 (std: 0.065) 
Parameters: {'clf__C': 100000.0, 'clf__gamma': 1.0} 

Model with rank: 3 
Mean validation score: 0.720 (std: 0.065) 
Parameters: {'clf__C': 10000000000.0, 'clf__gamma': 1.0} 


MY CODE FOR SEABORN 
# You can use this to generate a (5,5) array: 
# scores = np.random.rand(5,5) 


plt.figure(figsize=(8, 6)) 
scores = inner_rs.cv_results_['mean_test_score'].reshape(len(C_range),len(gamma_range)) 
ax = sns.heatmap(scores, annot=True) 

plt.xlabel('gamma') 
plt.ylabel('C') 

plt.xticks(np.arange(len(gamma_range)), gamma_range, rotation=45) 
plt.yticks(np.arange(len(C_range)), C_range) 
plt.title('Validation accuracy') 
plt.show() 


MY CODE FOR MATPLOTLIB 

from matplotlib.colors import Normalize 

class MidpointNormalize(Normalize): 
    def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): 
     self.midpoint = midpoint 
     Normalize.__init__(self, vmin, vmax, clip) 

    def __call__(self, value, clip=None): 
     x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1] 
     return np.ma.masked_array(np.interp(value, x, y)) 


plt.figure(figsize=(8, 6)) 
scores = inner_rs.cv_results_['mean_test_score'].reshape(len(C_range),len(gamma_range)) 
plt.imshow(scores, interpolation='nearest', cmap=plt.cm.hot, 

     norm=MidpointNormalize(vmin=0.2, midpoint=0.92)) 
plt.xlabel('gamma') 
plt.ylabel('C') 
plt.colorbar() 
plt.xticks(np.arange(len(gamma_range)), gamma_range, rotation=45) 
plt.yticks(np.arange(len(C_range)), C_range) 
plt.title('Validation accuracy') 
plt.grid(False) 
plt.show() 

matplotlibの Matplotlib

SEABORN Seaborn

答えて

1

残念ながらあなたはmatplotlibのプロットのための任意のコードが表示されません。しかし、グリッドを取り除く解決策は、plt.grid(False)を使用することです。

+0

こんにちは私はmatplotlibのコードを追加しました。あなたは作品に答えます! – Aizzaac