Home>

When I run with python, I get the following error:

Traceback (most recent call last):
File "analysis_resultstableZZZ.csv", line 1, in
id, signatures_id, hit_count, analysis_result
NameError: name 'signatures_id' is not defined

Please let me know if you understand the meaning of the error statement.

Source

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
# Load data --- (* 1)
analysisresults_data = pd.read_csv ("analysis_resultstableZZZ.csv", encoding = "utf-8")
# Separate data into labels and input data --- (* 2)
y = analysisresults_data.loc [:, "analysis_result"]
x = analysisresults_data.loc [:, ["id", "signatures_id", "hit_count"]]
# Separate for learning and testing --- (* 3)
x_train, x_test, y_train, y_test = train_test_split (x, y, test_size = 0.2, train_size = 0.8, shuffle = True, random_state = 0)
# Learn --- (* 4)
clf = SVC ()
clf.fit (x_train, y_train)
# Rate --- (* 5)
y_pred = clf.predict (x_test)
print ("Accuracy rate =", accuracy_score (y_test, y_pred))

CSV file

id, signatures_id, hit_count, analysis_result
4,12,4,0
5,12,3,0
6,12,3,0
7,12,3,0
8,12,3,0
11,10,2,0
21,10,8,0
22,12,2,0
23,10,2,0
24,10,4,0
25,10,2,0
26,10,4,0
27,10,2,0
28,10,4,0
33,10,2,0
34,12,4,0
35,10,4,0
36,10,8,0
37,10,4,0
  • Answer # 1

    Traceback (most recent call last):
    File "analysis_resultstableZZZ.csv", line 1, in
    id, signatures_id, hit_count, analysis_result
    NameError: name 'signatures_id' is not defined

    Running with python is not a "csv file".

    Some question texts are presented assource. Save the file with an appropriate file name and try again.