name 'x' is not defined

154
April 28, 2021, at 8:50 PM

I was doing a project in google collab. But I faced this error. What should I do ?? I am working with Gaussian Navie Bayes

import pandas as pd
import csv
from sklearn import datasets
dataset = datasets.load_wine()`
from sklearn.model_selection import train_test_split
X = dataset['data']
y = dataset['target']
x_train , x_test , y_train , y_test = train_test_split(x , y , test_size = 0.25 , random_state = 42)
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import StandardScaler
se = StandardScaler()
x_train = se.fit_transform(x_train)
x_test = se.fit_transform(x_test)
model1 = GaussianNB()
model1.fit(x_train , y_train)
y_pred = model1.predict(x_test)
accuracy = accuracy_score(y_test , y_pred)
print("The accuracy of the given data using gaussian naive bayes model is:-",accuracy)

This is the code that I used. This was done in google collab. I have attached the error snipet too..

Answer 1

Change x to X in the following line

x_train , x_test , y_train , y_test = train_test_split(X , y , test_size = 0.25 , random_state = 42)

since you mentioned X at

X = dataset['data']
READ ALSO
Change images size relative to scroll distance using jQuery

Change images size relative to scroll distance using jQuery

I have been trying my best to create a JS feature where an image changes size depending on how much I have scrolledNot changing size from A to B in an instant, but gradually changes relative to scroll distance

88
Javascript recursion, memory leak?

Javascript recursion, memory leak?

I am trying to implement a class that will perform an action once every second, it works as expected but I am unsure about memory leaksThis code I'm writing will have an uptime of several months

158
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/**/cache/storage/CAPTURE-20210427_125521.jpg

java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/**/cache/storage/CAPTURE-20210427_125521.jpg

I am developing a flutter app in which I'm using webview_flutter pluginNow inside the webview I want upload a file from the device

191