Medium-term electricity consumption and load forecasting in smart grids is an attractive topic of study, especially using innovative data analysis approaches for future energy consumption trends. Loss of electricity during generation and use is also a problem to be addressed. Both consumers and utilities can benefit from a predictive study of electricity demand and pricing. In this study, we used a new machine learning approach called AdaBoost to identify key features from an ISO-NE dataset that includes daily consumption data over eight years. Moreover, the DT classifier and RF are widely used to extract the best features from the dataset. Moreover, we predicted the electricity load and price using machine learning techniques including support vector machine (SVM) and deep learning techniques such as a convolutional neural network (CNN). Coronavirus herd immunity optimization (CHIO), a novel optimization approach, was used to modify the hyperparameters to increase efficiency, and it used classifiers to improve the performance of our classifier. By adding additional layers to the CNN and fine-tuning its parameters, the probability of overfitting the classifier was reduced. For method validation, we compared our proposed models with several benchmarks. MAE, MAPE, MSE, RMSE, the f1 score, recall, precision, and accuracy were the measures used for performance evaluation. Moreover, seven different forms of statistical analysis were given to show why our proposed approaches are preferable. The proposed CNN-CHIO and SVM techniques had the lowest MAPE error rates of 6% and 8%, respectively, and the highest accuracy rates of 95% and 92%, respectively.