class_docstr: Singular Spectrum Analysis object
class_docstr_tok: ["Singular","Spectrum","Analysis","object"]
docstr: Calculate the relative contribution of each of the singular values
docstr_tok: ["Calculate","the","relative","contribution","of","each","of","the","singular","values"]
code: def get_contributions(X=None, s=None, plot=True):
      """Calculate the relative contribution of each of the singular values"""
      lambdas = np.power(s, 2)
      frob_norm = np.linalg.norm(X)
      ret = pd.DataFrame(
          lambdas / (frob_norm**2), columns=["Contribution"]
      )
      ret["Contribution"] = ret.Contribution.round(4)
      if plot:
          ax = ret[ret.Contribution != 0].plot.bar(legend=False)
          ax.set_xlabel("Lambda_i")
          ax.set_title("Non-zero contributions of Lambda_i")
          vals = ax.get_yticks()
          ax.set_yticklabels(["{:3.2f}%".format(x * 100) for x in vals])
          return ax
      return ret[ret.Contribution > 0]
  
imports: import numpy
  import pandas
  from numpy import matrix
  from scipy import linalg
  from matplotlib.pylab import rcParams
label_desc: Use image node_id 3 for calling the mySSA obj's underlying member method code with example usage: obj.get_contributions(X, s, plot) and returns: ret, ax