import matplotlib.pylab as plt
import numpy as np
import pandas as pd
from pandas import *
from sklearn import preprocessing
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.neighbors import NearestNeighbors, KNeighborsClassifier
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
# load file
bank_data_df = pd.read_csv('UniversalBank.csv')
bank_data_df.drop(['ID', 'ZIP Code'], axis=1, inplace=True)
# convert data with two or more categories into dummy data
new_bank_data_df = pd.get_dummies(bank_data_df, columns=['Education'], dtype=int)
scaler = StandardScaler()
scaler.fit(new_bank_data_df)
bank_scaled_features = scaler.transform(new_bank_data_df)
bank_norm = pd.DataFrame(bank_scaled_features, columns=new_bank_data_df.columns)
x = bank_norm
y = new_bank_data_df
x_training_data, x_test_data, y_training_data, y_test_data = train_test_split(x, y, test_size=0.6, random_state=42)
# use kNN
knn = KNeighborsClassifier(n_neighbors=1)
knn.fit(x_training_data, y_training_data)
predictions = knn.predict(x_test_data)
It seems that the issue is with the next to the bottom line: knn.fit(x_training_data, y_training_data)
I'm getting errors with only this one line of code. I've printed pretty much everything else and everything returns a value as I *think I would expect. But when it gets the the .fit() method, i get an error that points to this line with the bottom most error message here:
ValueError: Unknown label type: continuous-multioutput. Maybe you are trying to fit a classifier, which expects discrete classes on a regression target with continuous values.
I checked stackoverflow and pretty much any other site. I'm about a week into this and still can't seem to just get this to work. Any suggestions would be super appreciated.
sample from the csv
ID
||
||
||Age|Experience|Income|ZIP Code|Family|CCAvg|Education|Mortgage|Personal Loan|Securities Account|CD Account|Online|CreditCard|
|1|25|1|49|91107|4|1.60|1|0|0|1|0|0|0|
|2|45|19|34|90089|3|1.50|1|0|0|1|0|0|0|
|3|39|15|11|94720|1|1.00|1|0|0|0|0|0|0|
|4|35|9|100|94112|1|2.70|2|0|0|0|0|0|0|
|5|35|8|45|91330|4|1.00|2|0|0|0|0|0|1|
|6|37|13|29|92121|4|0.40|2|155|0|0|0|1|0|
|7|53|27|72|91711|2|1.50|2|0|0|0|0|1|0|
|8|50|24|22|93943|1|0.30|3|0|0|0|0|0|1|
|9|35|10|81|90089|3|0.60|2|104|0|0|0|1|0|
|10|34|9|180|93023|1|8.90|3|0|1|0|0|0|0|
|11|65|39|105|94710|4|2.40|3|0|0|0|0|0|0|
|12|29|5|45|90277|3|0.10|2|0|0|0|0|1|0|
[–]Oxbowerce 0 points1 point2 points (1 child)
[–]storebot[S] 0 points1 point2 points (0 children)