With the rapid development of the Internet of Vehicles, a large amount of vehicle network data is being generated. The large amount of data presents network communication security challenges. Although intrusion detection technology can assist in safeguarding the system from malicious attacks, the substantial data generated within the vehicle network poses time-consuming detection challenges. Thus, we propose an intrusion detection model for the Internet of Vehicles, utilizing Gaussian random incremental principal component analysis (GRIPCA) and optimal weighted extreme learning machine (OWELM). First, we utilize GRIPCA to reduce data redundancy by projecting high-dimensional data into a low-dimensional space, thus reducing storage costs. Then, we utilize the dynamic inertia weight particle swarm optimization (DPSO) to optimize the parameters of the weighted extreme learning machine (WELM) to achieve the best performance. We utilize the NSL-KDD and CIC-IDS-2017 datasets to perform experiments and compare the results with other techniques. The experimental results show the excellence of the proposed model, achieving an accuracy rate of 91.02% on the NSL KDD dataset and 94.67% on the CIC-IDS-2017 dataset.INDEX TERMS Extreme learning machine, Internet of Vehicles, intrusion detection, particle swarm optimization, principal component analysis.