Efficient and Accurate Machine Learning Model Computation in Data Science Languages with Data Summarization via a Gram Matrix