HOLA!
EL MODELO MLKNN PARA CALCULAR PRECISION Y HAMMING LOSS NO FUNCIONA, EL PROFESOR INSTALO LA VERSION DE SCKIT-LEARN==0.24.1 PARA PODER UTILIZAR EL CODIGO EN ESE MODELO EN COLAB, PERO NO EJECUTA EL CODIGO DEL MODELO YA QUE DA ERROR EN EL ENTRENAMIENTO.
VERSION INSTALADA POR EL PROFESOR: !pip install scikit-learn==0.24.1
ERROR: Collecting scikit-learn==0.24.1 Using cached scikit-learn-0.24.1.tar.gz (7.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.10/dist-packages (from scikit-learn==0.24.1) (1.26.4) Requirement already satisfied: scipy>=0.19.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn==0.24.1) (1.13.1) Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.10/dist-packages (from scikit-learn==0.24.1) (1.4.2) Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn==0.24.1) (3.5.0) Building wheels for collected packages: scikit-learn error: subprocess-exited-with-error
× Building wheel for scikit-learn (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip. Building wheel for scikit-learn (pyproject.toml) ... error ERROR: Failed building wheel for scikit-learn Failed to build scikit-learn ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (scikit-learn)
---------------------------------------------------------------------------
MODELO MLKNN:
clasificador_mlknn = MLkNN(k=200)
clasificador_mlknn.fit(preguntas_train_tfidf, tags_train_array) Linea del codigo con ERROR
resultado_mlknn = clasificador_mlknn.score(preguntas_test_tfidf, tags_test_array)
print("Resultado {0: .2f}%".format(resultado_mlknn*100))
pronostico_mlknn = clasificador_mlknn.predict(preguntas_test_tfidf)
hamming_loss_mlknn = hamming_loss(tags_test_array, pronostico_mlknn)
print("Hamming Loss{0: .2f}".format(hamming_loss_mlknn))
ERROR:
TypeError Traceback (most recent call last) in <cell line: 2>() 1 clasificador_mlknn = MLkNN(k=200) ----> 2 clasificador_mlknn.fit(preguntas_train_tfidf, tags_train_array) # Entrenamos 3 resultado_mlknn = clasificador_mlknn.score(preguntas_test_tfidf, tags_test_array) 4 print("Resultado {0: .2f}%".format(resultado_mlknn*100)) 5 # Ahora utilizamos el PRONOSTICADOR de HAMMING LOSS:
1 frames /usr/local/lib/python3.10/dist-packages/skmultilearn/adapt/mlknn.py in compute_cond(self, X, y) 163 """ 164 --> 165 self.knn = NearestNeighbors(self.k).fit(X) 166 c = sparse.lil_matrix((self._num_labels, self.k + 1), dtype='i8') 167 cn = sparse.lil_matrix((self._num_labels, self.k + 1), dtype='i8')
TypeError: NearestNeighbors.init() takes 1 positional argument but 2 were given