#Help with basic softmax regression

3 messages · Page 1 of 1 (latest)

brisk rain
#
from sklearn import datasets as ds
import linear_models.softmaxreg as smr
import umap
import matplotlib.pyplot as plt
import numpy as np
import metrics.metrics as metrics

iris = ds.load_iris()
X = iris.data
y = iris.target

#Split the data into training/testing sets
#training 80% and testing 20%
n = X.shape[0]
n_test = int(np.rint(0.2*n))

#random sort
idx = np.random.permutation(n)
X = X[idx, :]
y = y[idx]

X_train = X[:-n_test, :] #Matrix of 120 4-variable vectors
X_test = X[-n_test:, :] #Matrix of 30 4-variable vectors
y_train = y[:-n_test] #Vector of 120 elements
y_test = y[-n_test:] #Vector of 30 elements

""" data normalization , improve convergence """
mu = np.mean(X_train, axis=0) #returns the mean
dst = np.std(X_train, axis=0) #returns the standard deviation
X_train = (X_train-mu)/dst
X_test = (X_test-mu)/dst

"""-------------------------------------------"""

SM = smr.SoftmaxReg(3)
coeff = SM.fit(X_train, y_train) #HERE
y_pred = SM.predict(X_test)

# show confusion matrix
cm = metrics.confusion_matrix(y_test, y_pred, 3)

The line in question returns the error
module 'metrics.metrics' has no attribute 'multiclass_accuracy'

What does it mean and how do I fix it?

#

The "HERE" comment is to show the line that causes the issue