One of the biggest challenges in quantitative finance is the efficient allocation of capital. Thus, in this study, a two-step methodology was proposed, in which a combination of logistic regression and Markowitz model was performed to determine optimized portfolios. In this context, in the first step, fundamentalist indicators were used as inputs to the logistic regression model in order to select the assets with the highest return potential. Thus, in the second step, the portfolio with these assets was balanced according to the covariances between the assets, so that the risk of the portfolio was as low as possible. The database consisted of the financial statements of 77 assets listed on the Ibovespa corresponding to the period from 2012 to 2020. To analyze the results, the model was implemented during the last 5 quarters and compared to three other approaches: 1 - only the implementation of logistic regression and the assignment of equal weights to the selected assets (LR + 1/N); 2 - traditional Markowitz model (mean-variance); 3 - Ibovespa index. The results showed that the combination of machine learning and optimization models can provide more efficient portfolios, and the cumulative return obtained by this investment strategy was 13.1% higher than the Ibovespa index, while the portfolio volatility was 3.1% lower in the same period.