Phylogenetic trees are a central tool in evolutionary biology. They demonstrate evolutionary patterns among species, genes, and with modern sequencing technologies, patterns of ancestry among sets of individuals. Phylogenetic trees usually consist of tree shapes, branch lengths and partial labels. Comparing tree shapes is a main challenge in comparing phylogenetic trees as there are few tools to describe tree shapes in a quantitative, accurate, comprehensive and easy-to-interpret way. Current methods to compare tree shapes are often based on scalar indices re[fl]ecting tree imbalance, and on frequencies of small subtrees. Polynomials are important tools to describe discrete structures and have been used to study various objects including graphs and knots. There exist polynomials that describe rooted trees. In this paper, we present methods based on a polynomial that fully characterizes trees. These methods include tree metrics and machine learning tools. We use these methods to compare tree shapes randomly generated by simulations and tree shapes reconstructed from data. Moreover, we also show that the methods can be used to estimate parameters for tree shapes and select the best-[fi]t model that generates the tree shapes.