code: import numpy as np
  import matplotlib.pyplot as plt
  from sklearn import datasets, metrics
  from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import MinMaxScaler
  from sklearn.neural_network import BernoulliRBM
  from sklearn.naive_bayes import GaussianNB
  from sklearn.pipeline import Pipeline
  
  base = datasets.load_digits()
  previsores = np.asarray(base.data, 'float32')
  classe = base.target
  
  normalizador = MinMaxScaler(feature_range=(0,1))
  previsores = normalizador.fit_transform(previsores)
  
  previsores_treinamento, previsores_teste, classe_treinamento, classe_teste = train_test_split(previsores, classe, test_size = 0.2, random_state=0)
  
  rbm = BernoulliRBM(random_state = 0)
  rbm.n_iter = 25
  rbm.n_components = 50
  naive_rbm = GaussianNB()
  classificador_rbm = Pipeline(steps = [('rbm', rbm), ('naive', naive_rbm)])
  classificador_rbm.fit(previsores_treinamento, classe_treinamento)
  
  plt.figure(figsize=(20,20))
  for i, comp in enumerate(rbm.components_):
      plt.subplot(10, 10, i + 1)
      plt.imshow(comp.reshape((8,8)), cmap=plt.cm.gray_r)
      plt.xticks(())
      plt.yticks(())
  plt.show()
  
  previsoes_rbm = classificador_rbm.predict(previsores_teste)
  precisao_rbm = metrics.accuracy_score(previsoes_rbm, classe_teste)
  
  naive_simples = GaussianNB()
  naive_simples.fit(previsores_treinamento, classe_treinamento)
  previsoes_naive = naive_simples.predict(previsores_teste)
  precisao_naive = metrics.accuracy_score(previsoes_naive, classe_teste)
apis: matplotlib.pyplot.xticks sklearn.preprocessing.MinMaxScaler matplotlib.pyplot.figure numpy.asarray sklearn.neural_network.BernoulliRBM sklearn.metrics.accuracy_score matplotlib.pyplot.subplot matplotlib.pyplot.show sklearn.datasets.load_digits sklearn.pipeline.Pipeline matplotlib.pyplot.yticks sklearn.model_selection.train_test_split sklearn.naive_bayes.GaussianNB