Witam
Mam kod z zajęć ze Sztucznej Inteligencji. Na zajęciach na komputerach z uczelni wszystko działało sprawnie. A teraz na moim prywatnym nie chce działać. Wyskakuje mi błąd:
"ImportError: cannot import name 'MutableSet' from 'collections'"
lub
"ImportError: cannot import name 'MutableMapping' from 'collections'"
Szukając w internecie rozwiązania dowiedziałam się, ze powinnam zmienić import collections na import collections.abc.
Problemem jest to, że w nie importuje tej biblioteki w kodzie
import numpy as np
from neupy import algorithms
import hickle as hkl
from sklearn.model_selection import StratifiedKFold
x,y_t,x_norm,x_n_s,y_t_s = hkl.load('iris.hkl')
y_t -= 1
x=x.T
y_t = np.squeeze(y_t)
lvqnet = algorithms.LVQ(n_inputs=x.shape[0], n_classes=np.unique(y_t).shape[0],step=0.001)
#lvqnet = algorithms.LVQ2(n_inputs=x.shape[0], n_classes=np.unique(y_t).shape[0],step=0.001)
# lvqnet = algorithms.LVQ21(n_inputs=x.shape[0], n_classes=np.unique(y_t).shape[0],step=0.001)
# http://neupy.com/modules/generated/neupy.algorithms.LVQ3.html
# lvqnet = algorithms.LVQ3(n_inputs=x.shape[0], n_classes=np.unique(y_t).shape[0],step=0.001)
lvqnet.train(x, y_t, epochs=100)
y=lvqnet.predict(x)
e = y_t - y
PK = (1 - sum(abs(e)>=0.5)/e.shape[0] ) * 100
print("\nPK = %5d" % PK)
data = x
target = y_t
CVN = 10
skfold = StratifiedKFold(n_splits=CVN)
PK_vec = np.zeros(CVN)
for i, (train, test) in enumerate(skfold.split(data, target), start=0):
x_train, x_test = data[train], data[test]
y_train, y_test = target[train], target[test]
# print(i,train,test)
lvqnet = algorithms.LVQ(n_inputs=x_train.shape[1], n_classes=np.unique(y_train).shape[0],step=0.001)
#lvqnet = algorithms.LVQ2(n_inputs=x.shape[1], n_classes=np.unique(y_t).shape[0],step=0.001)
# lvqnet = algorithms.LVQ21(n_inputs=x.shape[1], n_classes=np.unique(y_t).shape[0],step=0.001)
# http://neupy.com/modules/generated/neupy.algorithms.LVQ3.html
# lvqnet = algorithms.LVQ3(n_inputs=x.shape[1], n_classes=np.unique(y_t).shape[0],step=0.001)
lvqnet.train(x_train, y_train, epochs=100)
result = lvqnet.predict(x_test)
n_test_samples = test.size
PK_vec[i] = np.sum(result == y_test) / n_test_samples
print("Test #{:<2}: PK_vec {} test_size {}".format(i, PK_vec[i], n_test_samples))
PK = np.mean(PK_vec)
print("PK {}".format(PK))
Z góry dziękuję za pomoc.