docstr: Train model for max_iters iterations from scratch.
docstr_tok: ["Train","model","for","max_iters","iterations","from","scratch","."]
code: def solve(self, X, missing_mask):
      """Train model for max_iters iterations from scratch."""
      X = check_array(X, force_all_finite=False)
  
      # shape data to fit into keras model
      (n_samples, n_features) = X.shape
      observed_mask = ~missing_mask
      training_indices = list(zip(*np.where(observed_mask)))
  
      self.user_vecs = np.random.normal(
          scale=1.0 / self.rank, size=(n_samples, self.rank)
      )
      self.item_vecs = np.random.normal(
          scale=1.0 / self.rank, size=(n_features, self.rank)
      )
  
      self.user_bias = np.zeros(n_samples)
      self.item_bias = np.zeros(n_features)
      self.global_bias = np.mean(X[observed_mask])
  
      for i in range(self.max_iters):
          # to do: early stopping
          if (i + 1) % 10 == 0 and self._v:
              X_reconstruction = self.clip(self.predict_all())
              mae = masked_mae(
                  X_true=X, X_pred=X_reconstruction, mask=observed_mask
              )
              print(
                  "[MatrixFactorization] Iter %d: observed MAE=%0.6f rank=%d"
                  % (i + 1, mae, self.rank)
              )
  
          np.random.shuffle(training_indices)
          self.sgd(X, training_indices)
          i += 1
  
      X_filled = X.copy()
      X_filled[missing_mask] = self.clip(
          self.predict_all()[missing_mask]
      )
      return X_filled
  
file_path: fancyimpute/fancyimpute/matrix_factorization.py
imports: import numpy
  from sklearn.utils import check_array
  from .solver import Solver
  from .common import masked_mae
label_desc: Use image node_id 2 for calling the MatrixFactorization obj's underlying member method code with example usage: obj.solve(X, missing_mask) and returns: X_filled