【发布时间】:2020-12-05 03:03:10
【问题描述】:
我是新手,任何事情都会有所帮助。数据量很大... 我不确定错误可能来自哪里。我什至不知道这是否是个好主意哈哈,我的 x 和 y 使用经度和纬度。
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
import pandas as pd
import numpy as np
df = pd.read_csv('aug.csv')
X = df.Lon
y = df.Lat
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1)
clf = DecisionTreeClassifier()
clf = clf.fit(X_train,y_train)
y_pred = clf.predict(X_test)```
ValueError: Expected 2D array, got 1D array instead:
array=[-73.9713 -74.0635 -73.9881 ... -74.1777 -73.9923 -73.9661].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
【问题讨论】:
-
二维数组是数组中的数组。它是一个数组数组。例如 T = [[111, 222, 333, 444], [15, 6,10], [10, 8, 12, 5], [12,15,8,6]]。
标签: python arrays pandas numpy