Я использую Pycharm для запуска кода интерфейса машинного обучения. Алгоритм SVM продолжает сбивать мой интерфейс со следующей ошибкой:
line 1220, in pushButton_8_handlerax1 = sns.distplot(Y_predict)
line 979, in invraise LinAlgError("singular matrix")
numpy.linalg.LinAlgError: singular matrix
Код ниже.
from sklearn import model_selection
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
from sklearn.preprocessing import LabelEncoder
from sklearn import tree
from sklearn.metrics import accuracy_score
import pickle
from PIL import Image
import numpy as np
import seaborn as sns
def plot_distribution(inp):
plt.figure()
ax = sns.distplot(inp)
plt.axvline(np.mean(inp), color="k", linestyle="dashed", linewidth=5)
_, max_ = plt.ylim()
plt.text(
inp.mean() + inp.mean() / 10,
max_ - max_ / 10,
"Mean: {:.2f}".format(inp.mean()),
)
return plt.figure
print(np.mean(Y_test))
print(np.mean(Y_predict))
# ________________________Dist Predict Vs. Test and Means value_________________________
plt.figure(figsize=(9, 5))
o = np.mean(Y_test)
tt = np.mean(Y_train)
ax1 = sns.distplot(Y_predict)
ax2 = sns.distplot(Y_test)
RR1 = ('Mean:', tt)
RR2 = ('Mean:', o)
plt.axvline(np.mean(Y_predict), color='b', linestyle='dashed', linewidth=5, label=RR1)
plt.axvline(np.mean(Y_test), color='orange', linestyle='dashed', linewidth=5, label=RR2)
plt.legend()
plt.savefig('DecisionTreeClassifier2.png')
В основном, ошибка в ax1 = sns.distplot (Y_predict).
Я надеюсь, что смог объяснить проблему.
Спасибо