Since the outbreak of COVID-19, many COVID-19 research studies have proposed different models for predicting trend of COVID-19. Among them, the prediction model based on mathematical epidemiology (SIR) is the most widely used, but most of these models are adapted in special situations based on various assumptions. In order to reflect the real-time trend of the epidemic in the process of infection for different areas, different policies and different epidemic diseases, a general adapted time- window based SIR model is proposed, which is characterized by introducing a time window mechanism for dynamic data analysis and using machine learning method predicts the Basic reproduction number R0 and the exponential growth rate of the epidemic. Multiple data sets of epidemic diseases are analyzed, and the numerical results showed that the framework can effectively measure the real-time changes of the parameters during the epidemic, and error rate of predicting the number of COVID-19 infections in a single day is within 5%