Hello,
I use this iris data in variational classifier iris classification demo.
import pandas as pd
from sklearn import datasets
iris = datasets.load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['target'] = iris.target
df['target_names'] = iris.target_names[iris.target]
df.head()
x_train = df.loc[:, ['petal length (cm)', 'petal width (cm)']].to_numpy()
y_train = iris.target
y_train = [int(e / 2) for e in y_train]
X = x_train
Y = [(-1 if e==1 else 1) for e in y_train]
Y = np.tensor(Y, requires_grad=True)
But I get the bad result. I wonder how to improve model or why.
Hey @tudouuuuu!
Just want to make sure that you’re referring to this demo? I.e., you’re using the code in the Iris Classification section but just replacing the data there with the content in your post?
Yes, I am using code in the Iris classification
I also changed last plot code. I replaced xx, yy
in this way:
Before:
xx, yy = np.meshgrid(np.linspace(0.0, 1.5, 20), np.linspace(0.0, 1.5, 20))
After:
xx, yy = np.meshgrid(np.arange(X[:, 0].min() - 0.5, X[:, 0].max() + 0.5, 0.05), np.arange(X[:, 1].min() - 0.5, X[:, 1].max() + 0.5, 0.05))
Could you please attach the notebook that you’re working with? It’s hard to pinpoint exactly what’s going on without seeing your entire code.
I find when I change the number of iteration to 51 or 52, the result is good.
Thanks for your reply! @isaacdevlugt
Glad your issue is solved! I suspected it was probably just an issue with hyperparameter choices… Awesome job!
1 Like