class_docstr: Instantiate a fastText classifier that is compatible with :py:class:`CleanLearning <cleanlab.classification.CleanLearning>`.
  
  Parameters
  ----------
  train_data_fn: str
      File name of the training data in the format compatible with fastText.
  
  test_data_fn: str, optional
      File name of the test data in the format compatible with fastText.
class_docstr_tok: ["Instantiate","a","fastText","classifier","that","is","compatible","with",":","py",":","class",":","`","CleanLearning","<","cleanlab.classification.CleanLearning",">","`",".","Parameters","--","--","--","--","--","train_data_fn",":","str","File","name","of","the","training","data","in","the","format","compatible","with","fastText",".","test_data_fn",":","str",",","optional","File","name","of","the","test","data","in","the","format","compatible","with","fastText","."]
docstr: Compute the average precision @ k (single label) of the
  labels predicted from X and the true labels given by y.
  score expects a `y` variable. In this case, `y` is the noisy labels.
docstr_tok: ["Compute","the","average","precision","@","k","(","single","label",")","of","the","labels","predicted","from","X","and","the","true","labels","given","by","y.","score","expects","a","`","y","`","variable",".","In","this","case",",","`","y","`","is","the","noisy","labels","."]
code: def score(self, X=None, y=None, sample_weight=None, k=None):
      """Compute the average precision @ k (single label) of the
      labels predicted from X and the true labels given by y.
      score expects a `y` variable. In this case, `y` is the noisy labels.
      """
  
      # Set the k for precision@k.
      # For single label: 1 if label is in top k, else 0
      if k is None:
          k = self.p_at_k
  
      fn = self.test_data_fn
      pred_list = []
      if y is None:
          labels_list = []
      for labels, text in data_loader(
          fn=fn, indices=X, batch_size=self.batch_size
      ):
          pred = self.clf.predict(text, k=k)[0]
          pred_list.append(pred)
          if y is None:
              labels_list.append(labels)
      pred = np.array([z for l in pred_list for z in l])
      if y is None:
          y = [z for l in labels_list for z in l]
      else:
          y = [self.num2label[z] for z in y]
  
      apk = np.mean([y[i] in l for i, l in enumerate(pred)])
  
      return apk
  
file_path: cleanlab/cleanlab/models/fasttext.py
imports: import time
  import os
  import copy
  import numpy
  from sklearn.base import BaseEstimator
  from fasttext import train_supervised, load_model
label_desc: Use image node_id 8 for calling the FastTextClassifier obj's underlying member method code with example usage: obj.score(X, y, sample_weight, k) and returns: apk