Lithium-ion batteries have high energy density, lightweight and long life cycle, thus they are the choice for powering electric vehicles. The needed high voltage battery pack is achieved using series-connected cells, that ideally should be identical. However, parameter variations of cells in EVs, along with different working conditions can cause State of Charge (SoC) and temperature imbalances that shorten battery lifetime. Moreover, a series connection can potentially be exposed to singlecell failure. This paper proposes a redundant smart battery topology based on the series connection of individual cell modules. Each module is formed by a cell with an insertion/bypass circuit and a wireless processor that monitors cell states and communicates with a Master controller. To synthesize the nominal voltage, a battery pack with a small redundant number of cells is considered. In this way, it can be made both fault-tolerant and reach higher safety. The problem is then shifted to the control algorithm that at each sampling time has to select "n" cells out of the total cells, according to some goals. A Machine Learningbased control algorithm was developed and tested in Matlab to insert/bypass the cells and reach simultaneous balancing of both SoC and temperature. The new method based on the K-nearest algorithm has been compared in simulation with a conventional sorting balancing method and showed superior performance, especially in temperature balancing.