This might depend on the default value of the parameter drop_intermediate (default to true) of roc_curve(), which is meant for dropping suboptimal thresholds, doc here. You might prevent such behaviour by passing drop_intermediate=False, instead.
Here's an example:
import numpy as np
try:from sklearn.datasets import fetch_openmlmnist = fetch_openml('mnist_784', version=1, cache=True) mnist["target"] = mnist["target"].astype(np.int8)
except ImportError:from sklearn.datasets import fetch_mldata mnist = fetch_mldata('MNIST original')from sklearn.linear_model import SGDClassifier
from sklearn.model_selection import cross_val_predictX, y = mnist["data"], mnist["target"]
X_train, X_test, y_train, y_test = X[:60000], X[60000:], y[:60000], y[60000:]
shuffle_index = np.random.permutation(60000)
X_train, y_train = X_train[shuffle_index], y_train[shuffle_index]y_train_5 = (y_train == 5)
y_test_5 = (y_test == 5)sdg_clf = SGDClassifier(random_state=42, verbose=0)
sdg_clf.fit(X_train, y_train_5)y_scores = cross_val_predict(sdg_clf, X_train, y_train_5, cv=3, method='decision_function')# ROC Curvesfrom sklearn.metrics import roc_curvefpr, tpr, thresholds = roc_curve(y_train_5, y_scores)len(thresholds), len(fpr), len(tpr)
# (3472, 3472, 3472)# for roc curves, differently than for precision/recall curves, the length of thresholds and the other outputs do depend on drop_intermediate option, meant for dropping suboptimal thresholdsfpr_, tpr_, thrs = roc_curve(y_train_5, y_scores, drop_intermediate=False)
len(fpr_), len(tpr_), len(thrs)
# (60001, 60001, 60001)
This question already has answers here:ValueError: need more than 1 value to unpack python(4 answers)Closed 5 years ago.I am trying to transform a file to dictionary but having error.def txt_to_dict():…
I am learning Python and am stuck. I am trying to find the loan payment amount. I currently have:def myMonthlyPayment(Principal, annual_r, n):years = nr = ( annual_r / 100 ) / 12MonthlyPayment = (Princ…
Heres my code :hp1 = 100
health1 = you have, hp1hp1 = hp1 - 50
health1print hp1
print health1This is what it prints :50
(you have, 100)Why doesnt the hp1 change inside the health?
filename:recom.py# Returns a distance-based similarity score for person1 and person2
def sim_distance(prefs,person1,person2):
# Get the list of shared_itemssi={}for item in prefs[person1]:if item in pr…
I want to detect corners from a image with boxes, although i created the chessboard edge lines with the EDlines algorithm. Now, I have some problems to join them to create perfect boxes. Could you help…
How do I add or subtract 1 from the variable num ( in flask route) with an HTML button?
So when I click the button it change the var to 1 and refresh the page to show the new value
@app.route(/)
def n…
I found some nice examples to check, if a time is in a specific range, like this one:now_time = datetime.datetime.now().time()
start = datetime.time(17, 30)
end = datetime.time(4, 00)
if start <=…
My problem is im using Cubic Spline but i get this error trying to graph a race circuit
raise ValueError("x must be strictly increasing sequence.")
ValueError: x must be strictly increasing s…