I have a data set of 8 rows out of which seven rows are predicted and I need to predict the 8th-row data input. I am not getting where my logic is getting wrong, please let me know where I am getting wrong.{what ever predicted label present before i am getting wrong labels for that too)  flag=0 while flag==0:     cost=0     for i in range(rows):         if lDict.get(i)!=None:             dp=dotproduct(w,x[i])             #print("dotproduct",dp)             sig=sigmoid(dp)             #print("sigmoid",sig)             deviation[i]=lDict.get(i)-sig             #print("deviation",deviation)             step1=lDict.get(i)*sig             #print("step1",step1)             step2=(1-lDict.get(i))*(1-sig)             #print("step2",step2)             cost=cost+(-step1-step2)             print("cost",cost)     for i in range(cols):         for j in range(rows):             if lDict.get(j)!=None:                 delf[i]=delf[i]+(deviation[j]*x[j][i])                 #w[i]=w[i]-(eta*delf[i])                 #print("new_w",w)                 print("delf[i]",delf[i])                 #delw[i]=delw[i]+eta*delf[i]                 #print("delw",delw)     for i in range(cols):         w[i]=w[i]-(eta*delf[i])     print("updated w is ",w)   newcost=0 #print("newcost",newcost) for i in range(rows):     if lDict.get(i)!=None:         #print("w",w)         dp=dotproduct(w,x[i])         #print("newdot",dp)         sig=sigmoid(dp)         #print("newsig",sig)         step1=lDict.get(i)*sig         #print("newstep",step1)         step2=(1-lDict.get(i))*(1-sig)         #print("newstep2",step2)         cost=newcost         newcost=newcost+(-step1-step2)      print("new cost is",newcost)     print("old cost",cost)     if newcost-cost&lt;stop:         flag=1         print("flag",flag)   for i in range(rows):     if lDict.get(i)!=None:         dp=sigmoid(dotproduct(w,x[i]))         print("dp",dp)         print("weights",w)         #sig=sigmoid(dp)         #print("sig",sig)         if sig&lt;0.5:             print(0,"",i)         else:             print(1,"",i)`
I am running an analysis on the probability of loan default using logistic regression and random forests.    When I use logistic regression, the prediction is always all '1' (which means good loan).  I have never seen this before, and do not know where to start in terms of trying to sort out the issue.  There are 22 columns with 600K rows.  When I decrease the # of columns I get the same result with logistic regression.   Why could the logistic regression be so wrong?  **Actual from the data**  0 :   41932  1 :   573426  **Logistic regression output**   prediction for 1 when actually 0: 41932 prediction for 1 when actually 1:573426  A**s you can see, it always predicts a 1**   **Random forests does better:**  actual 0, pred 0 : 38800  actual 1, pred 0 : 27  actual 0, pred 1 : 3132 actual 1, pred 1 : 573399
Limit of ${a_n}^{1/n}$ is equal to $\lim_{n\to\infty} a_{n+1}/a_n$ Today my lecturer put up on the board that:  If $\lim\limits_{n\to\infty}\frac{a_{n+1}}{a_n}$ exists and $a_n&gt;0$ then   $\displaystyle \limsup\limits_{n\to\infty}\left(a_n^{\frac{1}{n}}\right)=\lim_{n\to\infty}\frac{a_{n+1}}{a_n}$  however I am not sure why this is true, can somebody give me a hint or something as to how to go about proving this.  thanks for any help Python idiom to return first item or None I'm sure there's a simpler way of doing this that's just not occurring to me.  I'm calling a bunch of methods that return a list.  The list may be empty.  If the list is non-empty, I want to return the first item; otherwise, I want to return None.  This code works:  my_list = get_list() if len(my_list) &gt; 0: return my_list[0] return None   It seems to me that there should be a simple one-line idiom for doing this, but for the life of me I can't think of it.  Is there?  Edit:  The reason that I'm looking for a one-line expression here is not that I like incredibly terse code, but because I'm having to write a lot of code like this:  x = get_first_list() if x:     # do something with x[0]     # inevitably forget the [0] part, and have a bug to fix y = get_second_list() if y:     # do something with y[0]     # inevitably forget the [0] part AGAIN, and have another bug to fix   What I'd like to be doing can certainly be accomplished with a function (and probably will be):  def first_item(list_or_none):     if list_or_none: return list_or_none[0]  x = first_item(get_first_list()) if x:     # do something with x y = first_item(get_second_list()) if y:     # do something with y   I posted the question because I'm frequently surprised by what simple expressions in Python can do, and I thought that writing a function was a silly thing to do if there was a simple expression could do the trick.  But seeing these answers, it seems like a function is the simple solution. While trying to ask a question, I got the error message     This question body does not meet our quality standards. Please make sure that it completely describes your problem - including what you have already tried - and is written using proper grammar.    Why am I getting this message? What can I do to get the system to accept my question? Can you be more specific? What are good resources on how to ask high-quality questions?      For more information, see  in the . I've got the new Canon Pixma MG 3150 and so far, I can't seem to find a driver anywhere. I do have the CD for both Windows and Mac, but this doesn't help me, as I have Ubuntu 11.10. I'd prefer to have it running on the wifi.  I'm really new to this, so I need for you to explain this to me as basically as possible. Change the title size in scrartcl I'd like to use a smaller title. I'm using the scrartcl documentclass from the . I can change it's color font but not it's size.  \setkomafont{title}{\normalfont\bfseries\small}   Everything works exept the size. I am new to photography, and need a little advice. I currently have a .   To get rolling, where do I go from here? Does the camera matter? Is this camera enough to start with? Prove $-(-a)=a$ using only ordered field axioms I need to prove for all real numbers $a$, $-(-a) = a$ using only the following properties:     I tried by starting with P12 written using symbolic logic:  $\begin{align} \forall a,b \in P \to &amp; a \cdot b \in P \Leftrightarrow True \\ \forall a \in P \land \forall b \in P \to &amp; a \cdot b \in P \Leftrightarrow True \\ \lnot \left[ \left( \forall a \in P \right) \land \left( \forall b \in P \right) \right] \lor &amp; a \cdot b \in P \Leftrightarrow True \\ \exists a \notin P \lor \exists b \notin P \lor &amp; a \cdot b \in P \Leftrightarrow True \\ \end{align} \\ $  and played with evaluating it with $b = -1$, $-a$ and so on. But, felt this wasn't really a solution because the last symbolic logic statement above is ambiguous.  Not to mention--other than P12--I haven't used any of the axioms listed above whatsoever. ( And I've not bothered to prove any of the theorems of symbolic logic I have used. )  Can anyone give me a start on this problem?  Many thanks in advance.  Edit  Thank you, everyone! .  Best regards! Image uploads from the editor strip preceding line breaks Recently, using the image uploader in the post editor has starting stripping preceding line breaks; placing the image directly after any previous text instead of at the current cursor position. This means that the inserted image is placed inline as part of the previous line of text rather than in a new paragraph as it did previously...  Before inserting the image (note the cursor position):        After inserting the image:        This also happens after the Markdown for a horizontal rule, which destroys the rule and gives us a bunch of hyphens followed by an image instead:        Seems the behaviour is a bit inconsistent... Sometimes I get the behaviour shown above and sometimes it leaves a single newline, I'm not sure when or why but single line breaks are ignored in Markdown so the rendered result is the same regardless.  Obviously it's useful to be able to have inline images, but I'm pretty certain most images aren't intended to (and shouldn't) be. How often is $1+\prod_{k=1}^n p_k$ not prime? Universal type tranformer in Haskell Equivalence of Categories and of Their Functor Categories Suppose $A, B, C$ are categories. If $A$ and $B$ are equivalent, is it the case that $C^A$ and $C^B$ are equivalent? Also, is it the case that $A^C$ and $B^C$ are equivalent.  I first conjectured that $C^A$ and $C^B$ are equivalent, but then as I tried to prove the conjecture, I started to realize that it might not be the case. So now I'm trying to find a counterexample. So far I have not been able to find one. Maybe I'm stuck with "too complicated" ideas. I strongly believe that there are very simple counterexamples. Please help. (For more detail, I got to the point where I have a cube that I want to be commutative, but I can only show that 4 of its sides are commutative squares. That's when I realize the other two sides may not necessarily commute.)  And of course, there is the second part to the problem that's not just the dual problem. I would like to know about the special case in which $A$ is a preorder and $B$ is a partial order which is the skeleton of $A$. This may have nothing to do with the validity of the statement in question at all, but it is the setting that originated this question. How to prove $\lim_{n \to \infty} \sqrt{n}(\sqrt[n]{n} - 1) = 0$? I'm trying CTest in CMake in order to automatically run some of my tests using make test target. The problem is CMake does not "understand" that the test I'm willing to run has to be built since it is part of the project.  So I'm looking for a way to explicitly specify this dependency. When using divs when is it best to use a class vs id?   Is it best to use class, on say font variant or elements within the html? Then use id for the structure/containers?   This is something I've always been a little uncertain on, any help would  be great. If $x_1,x_2,\ldots,x_n$ are the roots for $1+x+x^2+\ldots+x^n=0$, find the value of $\frac{1}{x_1-1}+\frac{1}{x_2-1}+\ldots+\frac{1}{x_n-1}$ Let $x_1,x_2,\ldots,x_n$ be the roots for $1+x+x^2+\ldots+x^n=0$. Find the value of   $$P(1)=\frac{1}{x_1-1}+\frac{1}{x_2-1}+\ldots+\frac{1}{x_n-1}$$   Source: IME entrance exam (Military Institute of Engineering, Brazil), date not provided (possibly from the 1950s)  My attempt: Developing expression $P(1)$, replacing the 1 by $x$, follows $$P(x)=\frac{(x_2-x)\cdots (x_n-x)+\ldots+(x_1-x)\cdots (x_{n-1}-x)}{(x_1-x)(x_2-x)\cdots (x_n-x)}$$    As $x_1,x_2,\ldots,x_n$ are the roots, it must be true that   $$Q(x)=(x-x_1)\cdots(x-x_n)=1+x+x^2+\ldots+x^n$$ and  $$Q(1)=(1-x_1)\cdots(1-x_n)=n+1$$ Therefore the denominator of $P(1)$ is  $$(-1)^{n} (n+1).$$ But I could not find a way to simplify the numerator.  Another fact that is probably useful is that  $$1+x^{n+1}=(1-x)(x^n+x^{n-1}+\ldots+x+1)$$ with roots that are 1 in addition of the given roots $x_1,x_2,\ldots,x_n$ for the original equation, that is  $$x_k=\text{cis}(\frac{2k\pi}{n+1}),\ \ k=1,\ldots,n.$$  This is as far as I could go...    Hints and full answers are welcomed. Ubuntu open to black screen with blinking underscore character after release upgrade I upgraded my Ubuntu OS from 12.10 to 13.04 and after the process of upgrading it via Software Updater, it requested me to restart the computer. I rebooted and on boot I proceeded to a purple screen with Ubuntu text and 5 dots below it and continued to a blank black screen with a blinking underscore character (_).  I have all my files in there and I can't access them. I tried the grub boot menu edit that other questions pointed out, but it didn't seem to do anything. How can I copy the 5 newest files from a directory to another in a "new to old" order. Checking incoming call in iphone Let $f: B(0,1) \rightarrow \mathbb{C}$ be holomorphic and suppose $\exists\ r \in (0,1)$ such that $f$ is injective in $A = \{z \in \mathbb{C} : r &lt; |z| &lt; 1\}$. Prove that $f$ is injective.  I tried using Rouché theorem, or the identity theorem, but I don't know what to do. Any hints? :) What is a good way to catch the Mysterious Stranger? When ever I hear the music to indicate the Mysterious Stranger has arrived, I can never find him. It is almost like he is not in the vault.  What is a good way to catch the Mysterious Stranger? Where does he usually show up?