Selecting Binary Classification Probability Threshold I have a binary classification problem I have modeled and I'm trying to determine the best way to select my probability threshold. Here was my modeling approach: Create a training and testing set.  My data comes in chronologically so I select data received in say Nov, Dec as my training set and Jan as my holdout (test) set. I train the models using 5 fold cross validation and the metric I'm using is area under the precision recall curve.  Based on my performance with the training set / cross validation, I then train the best model on the full training set (Nov, Dec) and predict on the hold out set (Jan). Now I want to see the confusion matrix in the hold out set (Jan).  My 'optimal' point selection on the Precision Recall Curve plotted on the hold out set (Jan) is where the F1 Score is optimized.  So I select that point and look at my confusion matrix. Now I want to use my final model.  Here are my questions:  February data comes in.  Do I have a 'gap' in that the final model I trained on Nov, Dec data  which I tested on holdout Jan that I now use to predict classes with February data?  or do I somehow incorporate Jan data (so I have Nov,Dec,Jan model) but no validation set to test on since now my model abuts February (which I want to predict)?  Assuming I use the Nov,Dec final model as the model to predict Feb, can I use the max F1 score threshold I calculated on the hold out set (Jan) when making February class predictions?   Thanks in advance.
Changing threshold in logistic regression Suppose that you have a logistic model and the predicted probabilities of a $1$ all are in $[0.2,0.3]$. So the predictions would be "0" based on a threshold of $0.5$. What would be a good threshold to choose?
I'm editing a book that includes about 25 papers written in LaTeX by different authors.  Since many of them use the same \label, to avoid collisions I redefined the \label command (and \ref and \pageref and \cite and \bibitem)  so that if the third paper has  \label{main_theorem} the aux file actually uses the tag "iii:main_theorem", and \ref{main_theorem} actually refers to the same tag.  I did a similar thing for \cite and \bibitem.  %*************** bib/cite hacks \let\TheReal@citex=\@citex \let\TheReal@bibitem=\@bibitem \let\TheReal@lbibitem=\@lbibitem \gdef\@lbibitem[#1]#2{\TheReal@lbibitem[{#1}]{#2\roman{chapter}}} \gdef\@bibitem#1{\TheReal@bibitem{#1\roman{chapter}}} \gdef\@citex[#1]#2{% \toks@={}\count@=0% \@for\@citec:=#2\do{% \advance\count@ 1 \ifnum\count@=1\edef\0{\the\toks@\expandafter\expandafter\noexpand\@citec\roman{chapter}}% \else\edef\0{\the\toks@,\expandafter\expandafter\noexpand\@citec\roman{chapter}} \fi% \toks@=\expandafter{\0}}% \TheReal@citex[#1]{\the\toks@}% } %************** label/ref/pageref hacks  %%%%%%%%%%%%% must be before ams pkgs \let\TheRealLabel=\label \let\TheRealRef=\ref \let\TheRealPageref=\pageref \gdef\label#1{\TheRealLabel{\roman{chapter}:#1}} \gdef\ref#1{\TheRealRef{\roman{chapter}:#1}} \gdef\pageref#1{\TheRealPageref{\roman{chapter}:#1}}   This all worked fine until I used hyperref, which seems to ignore the redefinition of \label, whether I load it before or after the above code.  Any suggestions?  It would be nice if the redefinition would work whether or not hyperref was loaded, so I don't want to just grab the defintion of \label out of the package and tweak it.  I'm also open to alternative methods.  Redefining \label and \ref just seemed the most straightforward (to me) solution.  Note that I also want to be able to refer to the inner labels from outside, as well.  For example, I might want to say "the main theorem of the third paper is  \ChapRef{iii}{main_theorem}  from within the introduction (a different chapter). undefined control sequence when using \addchap When I compile my thesis.tex file which is compiled fine including the \addchap, I noticed that I have used \usepackage{unnumberedtotoc}. When I want to use my thesis.tex file on another computer it says tex capacity exceeded, sorry [input stack size=5000]. When I uncomment \usepackage{unnumberedtotoc}, it says ! undefined control sequence  \addchap.  Here I have pasted all the beginning of the packages that I have used in my thesis but I still get some problems in compilation, I don't know why, but I think if I can compile this code, then I can solve the problem  :   \immediate\write18{makeindex \jobname.nlo -s nomencl.ist -o \jobname.nls} \documentclass[12pt]{report} \DeclareMathSizes{12}{30}{16}{12} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{lineno} \usepackage{amsmath}  \usepackage{array, nccmath}  \usepackage[nottoc]{tocbibind} \newcolumntype{L}{&gt;{$}l&lt;{$}} \newcolumntype{m}{&gt;{\displaystyle}l} \usepackage{framed} \usepackage{cclicenses} \usepackage{makecell} \usepackage[french]{babel} \usepackage{setspace} \usepackage{mathptmx}  \usepackage{multirow}  \usepackage{gensymb}  \usepackage{empheq}   \usepackage{mathtools}   \usepackage{array}   \renewcommand{\arraystretch}{1.9}   \newcolumntype{P}{&gt;{\centering\arraybackslash$}p{1.6em}&lt;{$}}   \newcolumntype{C}{&gt;{\centering\arraybackslash$}c&lt;{$}}   \usepackage{makecell}   \usepackage{booktabs}   \usepackage{subcaption}   \usepackage[intoc]{nomencl}   \makenomenclature   \setcounter{secnumdepth}{4}   \setcounter{tocdepth}{4}   \usepackage[justification=centering]{caption}    \usepackage{etoolbox}     \usepackage{unnumberedtotoc} %https://github.com/johannesbottcher/unnumberedtotoc/     \usepackage[automark,     plainheadsepline,     headsepline,     plainfootsepline,      footsepline,     markcase=ignoreupper]{scrlayer-scrpage}    \clearpairofpagestyles    \ihead*{\leftmark}    \cfoot*{\pagemark}    \setkomafont{pageheadfoot}{\scshape}    \usepackage{titlesec}    \graphicspath{{imagesthesis/}}    \def\frenchlistfigurename{Liste des figures}    \usepackage[a4paper,right=20mm,left=25mm,top=26mm, bottom=26mm]{geometry}    \makeatletter    \titleformat{\chapter}[display]    {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}    % this alters "before" spacing (the second length argument) to 0    \titlespacing*{\chapter}{0pt}{0pt}{20pt}    %\patchcmd{\@makechapterhead}{\vspace*{20\p@}}{}{}{}% Removes space above \chapter head    %\patchcmd{\@makeschapterhead}{\vspace*{20\p@}}{}{}{}% Removes space above \chapter* head    \makeatother    \title {itle of the thesis}    \titleformat{\paragraph}    {\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}    \titlespacing*{\paragraph}     {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}     \usepackage[thin, , thinc]{esdiff}  \usepackage{subcaption}  \usepackage{caption}  \usepackage{framed}    \usepackage{nomencl}   \setlength{\nomitemsep}{-\parskip}\usepackage{booktabs,multirow}  \renewcommand{\cellset}{\renewcommand{\arraystretch}{0.5}}   \begin{document}  \renewcommand\arraystretch{0.8} %\noindent  \doublespacing  \maketitle  \tableofcontents %\listoffigures  \addchap{Publications et communications}   \section*{$\:$  a. Publications:}  \section*{$\:$  b. Communications:}  \addchap{Remerciements}  \end{document} Problem statement  Prove that if $A$ is an uncountable set and $B$ is a countable set, then $A\setminus B$ must be uncountable.  What I think  The statement does not mention $A$ and $B$ relationship. I think there are two possibilities:   If $A \cap B = \emptyset $, then $A\setminus B$ is trivially uncountable If $A \cap B = B$, then $B \subset A$ and as a bijection can not be made between $A\setminus B$ and $\mathbb{N}$, $A\setminus B$ is uncountable.   And there is where I'm stuck. How can I prove that a bijecton can't be made?  TIA. What is a buffer overflow and how do I cause one? I have heard about a buffer overflow and I would like to know how to cause one.  Can someone show me a small buffer overflow example? New(And what they are used for?) Who was flying the Y-Wing when the Death Star exploded? Near the end of Star Wars IV: A New Hope, we see four spacecraft flying from the Death Star just moments before it explodes.     As you can see, there is the Millennium Falcon crewed by Han and Chewbacca, a pair of X-Wings which has to be Luke and Wedge, and then in the bottom corner, we see a Y-Wing. Who is this pilot and did he have any screen time to justify him actually existing in this moment? For as far as I can tell during the first trench runs, they were conducted by the Y-Wings and all of them seemed to have been destroyed during their run. So as I asked, who is flying this ship and how did survive to this moment? I am travelling to Calgary from Delhi. I have an Air India flight from Delhi to Dubai then British Airways flight from Dubai to London and Air Canada flight from London to Calgary. My query is "Do I require a transit visa." Plz help as I am travelling in four days On really old Ubuntu 6.06 - How to upgrade I'm on an old Ubuntu version (Ubuntu 6.06.2 LTS Server) which isn't really supported any more. So the automatic updates don't work. I have ISPConfig installed to manage a few web sites.  What's the best course of action? I'd like to upgrade to something current, but I can't figure out how to go about doing this, given that the apt-get scripts don't really work any longer. Given $E[Y]=1$ , $E[Y^2]=2$ and $E[Y^3]=5$, Y non negative integer random variable, find min of $P[Y=0]$ plot(density(rexp(100))   Obviously all density to the left of zero represents bias.  I'm looking to summarize some data for non-statisticians, and I want to avoid questions about why non-negative data has density to the left of zero.  The plots are for randomization checking; I want to show the distributions of variables by treatment and control groups. The distributions are often exponential-ish.  Histograms are tricky for various reasons.    A quick google search gives me work by statisticians on non-negative kernels, e.g.:  .    But has any of it been implemented in R?  Of implemented methods, are any of them "best" in some way for descriptive statistics?  EDIT:  even if the from command can solve my current problem, it'd be nice to know whether anyone has implemented kernels based on literature on non-negative density estimation As far as I can tell downvoting is mostly useless.     For questions the only people who get downvoted are lower rep users, or incredibly stupid questions    most questions that are downvoted get closed anyway which should be sufficient downvoting doesn't have too much affect on your rep anyway a negative comment is more useful and more of a push too change or delete the question  For answers downvoting is often used incorrectly as well   people commonly competitively downvote (downvoting another answer to a question that you also answered) obviously not a good behavior downvoting (and upvoting) are contagious, meaning one downvote leads to a bunch of others even though downvotes don't effect rep that much they create a negative environment, no one wants their post downvoted, on the other hand criticizing comments, I think, are far more welcome      So basically in a nutshell a downvote serves no real purpose even if a post deserves it. Flagging, closing and commenting are much more useful to everyone including the poster than downvoting so why have it.    I now see from the answers and comments that downvotes do serve a purpose and would like to retract my request. The strange thing about the maximum in Planck's law I read that it makes a difference whether you calculate $\frac{dE(\lambda) }{d \lambda}=0$ or $\frac{dE(\omega)}{d \omega}=0$ in the sense that the maximum energy density with respect to the wavelength does not coincide with the frequency maximum that one would assume to be at $\omega_{max} = \frac{c}{\lambda_{max}}$. Actually, I do not understand why this is so ( Now, I am only interested in a pure physical explanation, mathematically this is clear and due to the chain rule). Does anybody know how to explain this odd thing?  Somehow I feel that the core of the question has not been completely answered. Although I can easily look up wikipedia, where the need for the chain rule is explained, I am rather interested in understanding where the following argument breaks down, which seems to be why this question has caused some confusion in the past(as you can see by googling this question):  So we have $E(\omega)$ the energy radiated at a given frequency. Now this function has a maximum somewhere, so there is a frequency where a maximal amount of energy is emitted. In other words: If you add the sum of the photon's energies at each frequency that are emitted, you will notice that the maximum is reached at this frquency. Now $E(\lambda)$ tells you basically the same for the wavelength, but again: We know where at which frequency the maximal amount of energy is radiated, so we know the corresponding wavelength.   I think there is a need to explain this.   If anything is unclear, please let me know. Find the volume inside the paraboloid $x^2+4z^2+8y=16$ and on the positive side of xz-plane No answer was given for this question, so wanted to confirm my answer. Steps followed for solving:  V=$4\int_0^2\int_0^{\sqrt{16-4z^2}}(2-\frac{x^2}{8}-\frac{z^2}{2})dxdz$  After solving this I got V = $8\pi$. Is this answer correct? How to get product recommendations It seems as if a shift occurred and the descriptive "Oriental" was replaced by "Asian" as the accepted term in polite society — what caused this shift? I have a Gary Fisher bike (wahoo I believe). I think it's considered the entry level Fisher mountain bike.  Could I put on disc brakes as opposed to using the standard  brakes on this bike?  Standard brakes are the rim brakes.   Thanks Carlos How to Toggle Selected Objects Visibility with H shortcut as in Maya I want to be able to toggle the visibility of selected objects with a shortcut (H) the way you can do in Maya and XSI, shown in the GIF. I'm guessing scrippting is needed. I've tried to do it my self but I'm new to Python and Blender and as soon as the objects are hidden they seem to no longer be in a selection state/list. Eg if I manually select the hidden object/s in the Outliner and try to print the selected object to the console, none seem to be selected. Is this possible to do with the current state of Blender 2.8? Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis I heard that under the null hypothesis the p-value distribution should be uniform. However, simulations of binomial test in MATLAB return very different-from-uniform distributions with mean larger than 0.5 (0.518 in this case):   coin = [0 1]; success_vec = nan(20000,1);  for i = 1:20000     success = 0;     for j = 1:200         success = success + coin(randperm(2,1));     end     success_vec(i) = success; end      p_vec = binocdf(success_vec,200,0.5);     hist(p_vec);   Trying to change the way in which I generate random numbers didn't help.  I would really appreciate any explanation here. Someone told me that the English language is special (compared to German, at least) in the way that every noun could be used as a verb. I think this phenomenon is called supine. Is this correct?  Examples:   house → to house well → to well phone → to phone table → to table lamp → to lamp   At first it seemed to me that this would work with all nouns. But then I thought of the following nouns, and I think they can't be used as a verb, am I right?   person →(?) to person human →(?) to human baker →(?) to baker computer →(?) to computer example →(?) to example   It seems that nouns describing people (person, human, baker) are exceptions? But it works for "author" ("to author"). Hmm. "Computer" seems smiliar to a person's job to me (could be a human instead of a machine that computes).  But what about "example"? I think "to example (something/someone)" is not possible, is it? What would a native speaker understand/think if someone says:      He examples.      I want to example it/him.   Which are the nouns that can't be used as a verb? Sophomore's dream: $\int_0^{1} x^{-x} \; dx = \sum_{n=1}^\infty n^{-n}$ In the solution of the so-called , one of the key steps is to compute $$\int_0^1 x^n (\log x)^n~\mathrm dx$$ using the change of variables $x = \exp\left(-\frac{u}{n+1}\right)$ to obtain the Gamma function.  This substitution to me, looks like it was pulled out of thin air. Can someone help me motivate it? How would I have thought of this substitution? Delegate OpenID to Google (NOT Google Apps)