In this article, we propose a novel method using machine learning, especially for artificial neural networks (ANNs) to achieve variability analysis and performance optimization of the plasmonic refractive index sensor (RIS). A Fano resonance (FR) based RIS which consisted of two plasmonic waveguides end-coupled to each other by an asymmetrical square resonator is taken as an illustration to demonstrate the effectiveness of the ANNs. The results reveal that the ANNs can be used in fast and accurate variability analysis because the predicted transmission spectrums and transmittances generated by ANNs are approximate to the actual simulated results. In addition, the ANNs can effectively solve the performance optimization and inverse design problems for the RIS by predicting the structure parameters for RIS accurately. Obviously, our proposed method has potential applications in optical sensing, device design, optical interconnects and so on.