<h3 dir="auto">Describe the workflow you want to enable</h3>
<p dir="auto">Currently, there is no way to derive the <em>Sensitivity</em> or the <strong>Specificity</strong> from the confusions matrics<br>
The only way to be calculated is to do it yourself.  this can be simple if you are doing a simple binary classification like this one on the image.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/72753578/140646253-1db308b0-c4fc-44fc-9969-e1feb225d57d.png"><img width="896" alt="Screen Shot 2021-11-07 at 3 08 21 PM" src="https://user-images.githubusercontent.com/72753578/140646253-1db308b0-c4fc-44fc-9969-e1feb225d57d.png" style="max-width: 100%;"></a></p>
<p dir="auto">But if you are dealing with multiple categories more than 2 this can be slightly complicated and it can take time!</p>
<p dir="auto">Also, I think that calculating Sensitivity and Specificity will help analyze our model much much better</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/72753578/140646452-8c0a628b-2f16-49fc-86e0-7150c4e7e1b5.png"><img width="1098" alt="Screen Shot 2021-11-07 at 3 14 06 PM" src="https://user-images.githubusercontent.com/72753578/140646452-8c0a628b-2f16-49fc-86e0-7150c4e7e1b5.png" style="max-width: 100%;"></a></p>
. 
<h3 dir="auto">Describe your proposed solution</h3>
<p dir="auto">Add 2 new functions to <code class="notranslate">sklearn.metrics</code> that accept the confusion matrix and then return sensitive or specificity<br>
Should be something like this</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from sklearn.metrics import sensitive_score, specificity_score, confusion_matrix
conf = confusion_matrix(y_test, y_pred)
specificity = specificity_score(conf)
sensitive = sensitive_score(conf)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">metrics</span> <span class="pl-k">import</span> <span class="pl-s1">sensitive_score</span>, <span class="pl-s1">specificity_score</span>, <span class="pl-s1">confusion_matrix</span>
<span class="pl-s1">conf</span> <span class="pl-c1">=</span> <span class="pl-en">confusion_matrix</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">y_pred</span>)
<span class="pl-s1">specificity</span> <span class="pl-c1">=</span> <span class="pl-en">specificity_score</span>(<span class="pl-s1">conf</span>)
<span class="pl-s1">sensitive</span> <span class="pl-c1">=</span> <span class="pl-en">sensitive_score</span>(<span class="pl-s1">conf</span>)</pre></div>
<p dir="auto">We can do even better by make it more intuitively to use</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# it will caculate the confusion matrix internally !
specificity = specificity_score(y_test, y_pred)
sensitive = sensitive_score(y_test, y_pred)"><pre class="notranslate"><span class="pl-c"># it will caculate the confusion matrix internally !</span>
<span class="pl-s1">specificity</span> <span class="pl-c1">=</span> <span class="pl-en">specificity_score</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">y_pred</span>)
<span class="pl-s1">sensitive</span> <span class="pl-c1">=</span> <span class="pl-en">sensitive_score</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">y_pred</span>)</pre></div>
<h3 dir="auto">Describe alternatives you've considered, if relevant</h3>
<p dir="auto">I think this feature will be <code class="notranslate">good to have</code> one.<br>
I can implement it myself!!  and open a new pull request</p>
<p dir="auto">I'm not sure if this is intended, but I was confused that the <code class="notranslate">score</code> function after grid search uses a different scorer than the scorer defined in <code class="notranslate">GridSearchCV</code>.</p>
<p dir="auto">Example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from sklearn import datasets
from sklearn.linear_model import LinearRegression
from sklearn.grid_search import GridSearchCV
from sklearn.cross_validation import train_test_split
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score

digits = datasets.load_digits()
X = digits.data
y = digits.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=0)

hyperparams = [{'fit_intercept':[True, False]}]
algo = LinearRegression()

grid = GridSearchCV(algo, hyperparams, cv=5, scoring='mean_squared_error')
grid.fit(X_train, y_train)
print grid.score(X_test, y_test)
print mean_squared_error(y_test, grid.best_estimator_.predict(X_test))
print r2_score(y_test, grid.best_estimator_.predict(X_test))"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">sklearn</span> <span class="pl-k">import</span> <span class="pl-s1">datasets</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">linear_model</span> <span class="pl-k">import</span> <span class="pl-v">LinearRegression</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">grid_search</span> <span class="pl-k">import</span> <span class="pl-v">GridSearchCV</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">cross_validation</span> <span class="pl-k">import</span> <span class="pl-s1">train_test_split</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">metrics</span> <span class="pl-k">import</span> <span class="pl-s1">mean_squared_error</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">metrics</span> <span class="pl-k">import</span> <span class="pl-s1">r2_score</span>

<span class="pl-s1">digits</span> <span class="pl-c1">=</span> <span class="pl-s1">datasets</span>.<span class="pl-en">load_digits</span>()
<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">digits</span>.<span class="pl-s1">data</span>
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">digits</span>.<span class="pl-s1">target</span>
<span class="pl-v">X_train</span>, <span class="pl-v">X_test</span>, <span class="pl-s1">y_train</span>, <span class="pl-s1">y_test</span> <span class="pl-c1">=</span> <span class="pl-en">train_test_split</span>(<span class="pl-v">X</span>, <span class="pl-s1">y</span>, <span class="pl-s1">test_size</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>, <span class="pl-s1">random_state</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)

<span class="pl-s1">hyperparams</span> <span class="pl-c1">=</span> [{<span class="pl-s">'fit_intercept'</span>:[<span class="pl-c1">True</span>, <span class="pl-c1">False</span>]}]
<span class="pl-s1">algo</span> <span class="pl-c1">=</span> <span class="pl-v">LinearRegression</span>()

<span class="pl-s1">grid</span> <span class="pl-c1">=</span> <span class="pl-v">GridSearchCV</span>(<span class="pl-s1">algo</span>, <span class="pl-s1">hyperparams</span>, <span class="pl-s1">cv</span><span class="pl-c1">=</span><span class="pl-c1">5</span>, <span class="pl-s1">scoring</span><span class="pl-c1">=</span><span class="pl-s">'mean_squared_error'</span>)
<span class="pl-s1">grid</span>.<span class="pl-en">fit</span>(<span class="pl-v">X_train</span>, <span class="pl-s1">y_train</span>)
<span class="pl-k">print</span> <span class="pl-s1">grid</span>.<span class="pl-en">score</span>(<span class="pl-v">X_test</span>, <span class="pl-s1">y_test</span>)
<span class="pl-k">print</span> <span class="pl-en">mean_squared_error</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">grid</span>.<span class="pl-s1">best_estimator_</span>.<span class="pl-en">predict</span>(<span class="pl-v">X_test</span>))
<span class="pl-k">print</span> <span class="pl-en">r2_score</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">grid</span>.<span class="pl-s1">best_estimator_</span>.<span class="pl-en">predict</span>(<span class="pl-v">X_test</span>))</pre></div>
<p dir="auto">I expected that <code class="notranslate">grid.score()</code> would use the mean_squared_error because this was previously defined in the <code class="notranslate">scoring</code> option. It took me some time to find out that the number is actually the r2_score which seems to be the <code class="notranslate">score</code> function of <code class="notranslate">LinearRegression</code>.<br>
The documentation of <code class="notranslate">score()</code> in <code class="notranslate">BaseSearchCV</code> says:<br>
<em>The <code class="notranslate">score</code> function of the best estimator is used, or the <code class="notranslate">scoring</code> parameter where unavailable.</em><br>
Maybe the documentation of <code class="notranslate">score()</code> in <code class="notranslate">BaseSearchCV</code> could be adapted to make it clear that the calculated score is not necessarily the same as the one defined in the <code class="notranslate">scoring</code> parameter of <code class="notranslate">GridSearchCV</code>.</p>