Zend Framework 1.12 - Action Controller not working

Question: I am new to Zend framework and I have installed zend frameworkd 1.12. It seems to be running find except for the fact the the views don't read the command specify in the action controller.
I have tested this with two controllers one is the index controller and second a created controller through zf command. here is the code.
<?php

class TestController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        //echo "Please read this";
    }

    public function indexAction()
    {
        echo 1;
    }

}

Here is the link to the view for this controller (just to be sure that not the problem)
Zend_Projects/test1/application/views/scripts/test/index.phtml
and the output of the controller:
-->> View script for controller Test and script/action name index
It does not add the 1 or any string from the echo command
Can anyone tell me why the controller action is not be read by the view?
Please any sort of help is appreciated and I apologize in advance if this is
a stupid question.
Best of Regards
Comment: It seems like the view is not reading any action controller item at all. Any idea why?
Comment: are you using Zend_Projects/test1/application/views/scripts/test/index.phtml for opening in browser? that is wrong my friend. use Zend_Projects/test1/public/test/index or something like that...
Comment: proceeded as you advised and it still doesn't work. public folder only ad a single index.php file in there and even when I copied the index "test" files it doesn't work
Answer: If you want to output an value from your Action inside your view, you have to to pass it with:
public function indexAction()
{
   $this->view->mytext = 'Test';
}

now inside your .phtml script:
<?php echo $this->mytext; ?>

Comment: I have tried as you suggested and it does not work either. I put a simple php code in the .phtml file, it outputs that but if I specify php a variable as you displayed or echo statement in controller it doesn't read that at all. Thanks for the help still.
Answer: As per the comments to the question
You dont have to copy anything php file to public folder except for index.php also make sure there is a .htaccess file present in public folder and mod_rewrite is enabled in apache. That is if you are using apache (otherwise you should use url rewriting method of the server that you are using.) If this all sounds greek to you and I assume you dont know greek then refer http://framework.zend.com/manual/1.12/en/zend.controller.router.html
if all this is already done then there might be a problem with router. refer http://framework.zend.com/manual/1.12/en/project-structure.rewrite.html
The key is that you dont call the actual phtml file in a browser, that is done by the application. The browser always calls index.php in public folder which is done via rewriting urls. the index.php file initializes the zend application and runs it.


Necessary and sufficient condition for $\text{tr}\log(A+iB)+\text{tr}\log(A-iB)$ to be real?

Question: Assume $A$ and $B$ are square matrices which allow $\log(A+iB)$ and $\log(A-iB)$ to be well defined. What are the necessary and sufficient conditions on $A$ and $B$ to make the aforementioned trace to be real valued?
Edit: A sufficient condition is that $A$ and $B$ are self-adjoint and commute, with $A$ being positive definite, since then $A+iB$ is a normal matrix. Hence, if $A+iB$ has an eigenvalue $\lambda_n$, $A-iB$ has an eigenvalue $\lambda_n^*$. Hence the trace expression is
$$\text{tr}\log(A+iB)+\text{tr}\log(A-iB)=\sum_n\log(|\lambda_n|^2)\in\mathbb{R}$$
$A$ being positive definite is to avoid any potential branch cut issues with the logarithm. I am trying to understand whether this is also a necessary condition, or if there are some less restrictive properties of $A$ and $B$ which allow the trace in question to be real.
Answer: Assume that $\Vert A+iB - I\Vert <1$ and $\Vert A-iB - I\Vert
<1$, which is the common condition for the corresponding matrix logarithms to be defined (see Thm 2.8 in Hall, Lie Groups, Lie Algebras, and Representations, 2015).  Then, it is the case that (Thm 2.8 in Hall):
$$\exp({\ln (A+iB)}) = A+iB,\qquad \exp({\ln (A-iB)}) = A-iB \tag{1} $$
We will also use that for all matrices $X$ (Thm 2.12 in Hall):
$$\det(\exp(X)) = \exp({\mathrm{tr} X})\tag{2}$$
Finally, we will use that $\det X \det Y =\det XY$ for all matrices $X$ and $Y$. We write $^*$ for complex conjugate and $^\dagger$ for conjugate transpose.
Combining $(1)$ and $(2)$ implies
\begin{align}
&\exp[{\mathrm{tr} \ln (A+iB) + \mathrm{tr} \ln (A-iB))}] \\
&=\exp[{\mathrm{tr} \ln (A+iB) ]\exp[\mathrm{tr} \ln (A-iB))}] \\
&= \det[\exp({\ln (A+iB)}) ]\det[\exp({\ln (A-iB)) }]\\
&= \det(A+iB)\det (A-iB)\\
&= \det((A+iB)(A-iB))
\end{align}
It is clear that ${\mathrm{tr} \ln (A+iB) + \mathrm{tr} \ln (A-iB))}$ is real if and only if $$\det((A+iB)(A-iB))=\det(A^2 +i(BA-AB)+B^2)$$ is real and strictly positive.  Some simple sufficient conditions for this to be the case:

If $A$ and $B$ are real-valued, then $A+iB=(A-iB)^*$, so $$\det(A-iB)=\det((A+iB)^*)=(\det(A+iB))^*$$
and therefore $\det(A+iB)\det(A-iB)=\vert \det(A+iB)\vert^2$.

If $A$ and $B$ are self-adjoint, then $A^\dagger=A$ and $(iB)^\dagger=-iB$ (since $iB$ is skew-adjoint), so
$$\det(A-iB)=\det(A^\dagger+(iB)^\dagger)=\det((A+iB)^\dagger)=(\det(A+iB))^*$$
and therefore $\det(A+iB)\det(A-iB)=\vert \det(A+iB)\vert^2$.

Example where $B$ is neither real nor self-adjoint, and the product of determinants is not positive: consider the 1-by-1 matrices $A=1/2$ and $B=i$. Then, $\det(1/2-1)\det(1/2+1)=-3/4$.
Comment: @fewfew4 I have further modified my answer. Actually the sufficient conditions are quite general: the result holds if $A$ and $B$ are both real-valued, as well as if they are both self-adjoint (in either case, they don't need to commute).
Comment: Is the relationship $\log\det X = \text{tr}\log X$ valid for any matrix $X$?
Comment: Yes, see https://en.wikipedia.org/wiki/Matrix_exponential#The_determinant_of_the_matrix_exponential .
Comment: I guess what I am wondering is, can we always make the extra step and write $\log\det(A^2 +i(BA-AB)+B^2)=\text{tr}\log(A^2+i(BA-AB)+B^2)$? It doesn't seem like you can for any choice of $A$ and $B$, considering we could have equally arrived at $A^2 +i(AB-BA)+B^2$ inside the argument.
Comment: When you say "This is satisfied when $A$ and $B$ commute and are self-adjoint..." do you mean it is only satisfied when these are true @Artemy
Comment: @fewfew4 I have edited my answer to make this more explicit and the assumptions clearer.  And yes, the determinant of $(A+iB)(A-iB)$ and $(A-iB)(A+iB)$ is the same.


Classifier accuracy decreases as n of n-gram models increases. Is this expected?

Question: I am trying to tackle a multi-classification problem that requires text processing. The data contains a lot of samples (approximately 100.000 samples) and one of the features I need to work with is a short (sometimes longer) written message. Dividing the dataset into a 70/30 scheme and cross-validating on the 70% for tuning, the model reaches currently 90% accuracy. I am using scikit-learn's TfidfVectorizer to extract features from the messages and RandomForestClassifier for the machine learning per se.
What I find peculiar is that as I increase the maximum n for the n-gram models considered, its accuracy decreases slightly :
n in [1,2[  ->    Accuracy: 91.0%   Dimensionality:   126,756
n in [1,2]  ->    Accuracy: 90.8%   Dimensionality:   605,010
n in [1,3]  ->    Accuracy: 90.5%   Dimensionality: 1,408,346
...         ->    ...

I initially thought that increasing the maximum n could only increase the model's accuracy but that is not reflected in my results.
Am I doing something wrong in my approach? Or is this decrease in accuracy something that could potentially happen?
Comment: It would be helpful to know what is the dimensionality of data for these ranges.
Comment: I've added them to my question
Comment: I've updated my answer accordingly.
Answer: The problem with spurious variables in Random Forest is that each tree selects only a random subset of features, and if their number gets high, so if most of them are bogus (which is most likely the case here, since most of higher n-grams will occur only a bunch of times), some trees won't learn anything useful.
Random Forests are used because single decision tree is highly likely to overfit, and averaging predictions in decreases variance compared to using a single estimator. It doesn't seem likely that your single decision trees are overfitting, since they are using only a tiny random subset of huge, mostly irrelevant feature space.
You didn't say anything about the trees - did you try using more of them and simultaneously limiting their depth? Scikit-learn's Random Forests have a couple of parameters that you can tune.
Another question would be if you really actually need decision trees - I for example would at least try using logistic regression (with Lasso/ElasticNet) for such problem, as these methods naturally fit such sparse problems - they consider all the features, and do feature selection themselves.
Comment: The forest is made of 30 trees each having default parameter values except for `max_features` which is set at 0.1 (Tuned using cross-validation) And I did explore other learning methods (Multinomial Naive Bayes, Linear SVM, ...) but I didn't give logistic regression a shot. I'll try that and see if my results become more coherent.
Answer: These results are the same for character n-grams as well. until a certain n value, accuracy will increase and then it starts to drop for both word n-grams and character n-grams. Reason for this is if the individual accuracy of a given n value is lower for a particular selected corpus size it has a slightly negative effect on combined feature selection accuracy. (larger the n larger can be the corpus size needed for improving a unit of accuracy)