Today's compilers have many optimization options, and it is difficult to understand all the details and the interac- tions between them. Therefore, many application develop- ers simply use the well-known compiler flags to compile all their programs. On the other hand, some researchers focus on customizing the optimizations for each program. The for- mer method may hurt the performance of some programs since non-optimal options are applied on them. The latter approach takes care of the variations of programs but suffer from the scalability problem because the optimization space is often huge. This makes it less popular for the emerging dynamic optimizing compilers. We attack this problem by exploiting two insights: first, it is feasible to categorize the programs into different classes according to their functionalities and characteristics; sec- ond, dynamic profiling information is useful for recogniz- ing the type of a program. With both insights, we present a novel approach for program optimization: first, the pro- grams are categorized into different classes and the class- level optimization decision is made by the domain experts; then, the class of an input program is recognized by the ma- chine learning models and the optimal class-level optimiza- tions are applied to obtain the best performance. We demon- strate that this approach can be applied to a binary transla- tor and great performance improvement can be achieved.