A machine learning (ML)-based multifunctional optical spectrum analysis technique is proposed to perform not only the conventional analysis functions but also the extended analysis functions, including center wavelength detection, optical signal-to-noise (OSNR) calculation, bandwidth recognition, as well as spectral distortion diagnosis. We have investigated four widely used ML algorithms, including support vector machine (SVM), artificial neural network, k-nearest neighbors, and decision tree. First, the wavelengths, OSNRs, and bandwidths of optical signals are processed by four ML methods based on the spectral data. The good performance and fast processing speed are obtained, especially for SVM, achieving the optimal accuracy (100%) and the least test time. For the need of the practical application, we also investigate the more complicated case, where wavelength, OSNR, and bandwidth are variable simultaneously so that the ML should analyze these three parameters comprehensively. Even in this case, the overall accuracy is still larger than 99.1%. In addition, the extended analysis functions are also studied to diagnose the spectral distortion caused by the cascaded filtering effect and off-center filtering effect. The number of cascaded filters and the offsets of filter shift and laser drift can be effectively estimated by the SVM with high average accuracy and low standard deviation, which are useful for failure detection and distortion recovery. This technique has the potential to be applied in the optical spectrum analyzer to implement the multifunctional spectrum analysis or in the optical performance monitor to execute the spectral distortion diagnosis.