roc

How to calculate AUC for One Class SVM in python?

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have difficulty in plotting OneClassSVM's AUC plot in python (I am using sklearn which generates confusion matrix like [[tp, fp],[fn,tn]] with fn=tn=0 . from sklearn.metrics import roc_curve, auc fpr, tpr, thresholds = roc_curve(y_test, y_nb_predicted) roc_auc = auc(fpr, tpr) # this generates ValueError[1] print "Area under the ROC curve : %f" % roc_auc plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc) I want to handle error [1] and plot AUC for OneClassSVM . [1] ValueError: Input contains NaN, infinity or a value too large

Sklearn: ROC for multiclass classification

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm doing different text classification experiments. Now I need to calculate the AUC-ROC for each task. For the binary classifications, I already made it work with this code: scaler = StandardScaler(with_mean=False) enc = LabelEncoder() y = enc.fit_transform(labels) feat_sel = SelectKBest(mutual_info_classif, k=200) clf = linear_model.LogisticRegression() pipe = Pipeline([('vectorizer', DictVectorizer()), ('scaler', StandardScaler(with_mean=False)), ('mutual_info', feat_sel), ('logistregress', clf)]) y_pred = model_selection.cross_val

How to plot a ROC curve for a knn model

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using ROCR package and i was wondering how can one plot a ROC curve for knn model in R? Is there any way to plot it all with this package? I don't know how to use the prediction function of ROCR for knn. Here's my example, i am using isolet dataset from UCI repository where i renamed the class attribute as y: cl<-factor(isolet_training$y) knn_isolet<-knn(isolet_training, isolet_testing, cl, k=2, prob=TRUE) Now my question is, what are the arguments to pass to the prediction function of ROC. I tried the 2 below alternatives which are not

How to get ROC curve for decision tree?

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to find ROC curve and AUROC curve for decision tree. My code was something like clf.fit(x,y) y_score = clf.fit(x,y).decision_function(test[col]) pred = clf.predict_proba(test[col]) print(sklearn.metrics.roc_auc_score(actual,y_score)) fpr,tpr,thre = sklearn.metrics.roc_curve(actual,y_score) output: Error() 'DecisionTreeClassifier' object has no attribute 'decision_function' basically, the error is coming up while finding the y_score. Please explain what is y_score and how to solve this problem? 回答1: First of all, the

plotting ROC in R with ROCR vs pROC

回眸只為那壹抹淺笑 提交于 2019-12-03 05:47:11
问题 I am plotting ROCs and measuring partial AUC as a metric of ecological niche model quality. As I am working in R, I am using the ROCR and the pROC packages. I'll settle on one to use, but for now, I just wanted to see how they performed, and if one met my needs better. One thing that confuses me is that, when plotting a ROC, the axes are as follows: ROCR x axis: 'true positive rate' 0 -> 1 y axis: 'false positive rate', 0 -> 1 pROC x axis: 'sensitivity' 0 -> 1 y axis: 'specificity' 1 -> 0.

How to compute ROC and AUC under ROC after training using caret in R?

一曲冷凌霜 提交于 2019-12-03 05:17:59
问题 I have used caret package's train function with 10-fold cross validation. I also have got class probabilities for predicted classes by setting classProbs = TRUE in trControl , as follows: myTrainingControl <- trainControl(method = "cv", number = 10, savePredictions = TRUE, classProbs = TRUE, verboseIter = TRUE) randomForestFit = train(x = input[3:154], y = as.factor(input$Target), method = "rf", trControl = myTrainingControl, preProcess = c("center","scale"), ntree = 50) The output

Simple line plots using seaborn

旧街凉风 提交于 2019-12-03 04:04:49
问题 I'm trying to plot a ROC curve using seaborn (python). With matplotlib I simply use the function plot : plt.plot(one_minus_specificity, sensitivity, 'bs--') where one_minus_specificity and sensitivity are two lists of paired values. Is there a simple counterparts of the plot function in seaborn? I had a look at the gallery but I didn't find any straightforward method. 回答1: Since seaborn also uses matplotlib to do its plotting you can easily combine the two. If you only want to adopt the

How to calculate AUC with tensorflow?

こ雲淡風輕ζ 提交于 2019-12-03 03:09:21
I've built a binary classifier using Tensorflow and now I would like to evaluate the classifier using AUC and accuracy. As far as accuracy is concerned, I can easily do like this: X = tf.placeholder('float', [None, n_input]) y = tf.placeholder('float', [None, n_classes]) pred = mlp(X, weights, biases, dropout_keep_prob) correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) When calculating AUC I use the following: print(tf.argmax(pred, 1).dtype.name) print(tf.argmax(pred, 1).dtype.name) a = tf.cast(tf.argmax(pred, 1)

Multiple ROC curves in one plot ROCR

眉间皱痕 提交于 2019-12-03 02:22:23
问题 Is it possible to plot the roc curve for diffrent classifiers in the same plot using the ROCR package? I've tried: >plot(perf.neuralNet, colorize=TRUE) >lines(perf.randomForest) But I get: Error en as.double(y) : cannot coerce type 'S4' to vector of type 'double' Thank you! 回答1: The problem with your lines -approach is that there is no generic S4 lines function for an object of class performance defined in the ROCR package. But you can use the generic plot function as you did with an

scikit-learn - ROC curve with confidence intervals

天涯浪子 提交于 2019-12-03 02:02:13
问题 I am able to get a ROC curve using scikit-learn with fpr , tpr , thresholds = metrics.roc_curve(y_true,y_pred, pos_label=1) , where y_true is a list of values based on my gold standard (i.e., 0 for negative and 1 for positive cases) and y_pred is a corresponding list of scores (e.g., 0.053497243 , 0.008521122 , 0.022781548 , 0.101885263 , 0.012913795 , 0.0 , 0.042881547 [...]) I am trying to figure out how to add confidence intervals to that curve, but didn't find any easy way to do that with