title: ValueError: Expected 2D array, got 1D array instead: array=[19. 27.896 0. 1. 0. ]. Reshape your data either using array.reshape(-1, 1)
body: <p>I am trying to predict the insurance cost of an individual in the United States using K Nearest Neighbors</p>
  <p>I have succesfully trained the data set and it started trowing the error when i tried to predict</p>
  <pre><code>ValueError: Expected 2D array, got 1D array instead:
  array=[19.    27.896  0.     1.     0.   ].
  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.
  </code></pre>
  <p>while while executing the following code:</p>
  <pre><code>import pandas as pd 
  import numpy as np
  from sklearn.neighbors import KNeighborsClassifier
  knn = KNeighborsClassifier(n_neighbors=1)
  
  
  insurance = pd.read_csv(r&quot;C:\Users\USER\Desktop\data set\insurance.csv&quot;)
  insurance2 = pd.read_csv(r&quot;C:\Users\USER\Desktop\data set\insurance.csv&quot;)
  
  
  insurance['charges'] = insurance['charges'].astype('int')
  
  sex_s=[]
  for i in insurance['sex']:
      if i == &quot;female&quot;:
          sex_s.append(1)
      elif i == &quot;male&quot;:
          sex_s.append(0)
      
  insurance2['sx']=sex_s
  
  smk=[]
  for y in insurance['smoker']:
      if y == &quot;yes&quot;:
          smk.append(1)
      elif y == &quot;no&quot;:
          smk.append(0)
  
  insurance2['smks']=smk
  
  
  
  insurance2 = insurance2.drop(['charges',&quot;region&quot;, 'sex','smoker'], axis =1)
  
  insurance2.rename(columns={'smks':'smoker', 'sx':'sex'}, inplace = True)
  
  
  insurance2['bmi'] = insurance2['bmi'].astype('int')
  insurance2['children'] = insurance2['children'].astype('int')
  insurance2['sex'] = insurance2['sex'].astype('int')
  insurance2['smoker'] = insurance2['smoker'].astype('int')
  insurance2['age'] = insurance2['age'].astype('int')
  insurance2.dtypes
  
  
  X = insurance2
  y = insurance['charges']
  
  
  knn.fit(X,y)
  
  knn.predict([19, 27.896, 0, 1, 0])
  </code></pre>
  <p>this is my first time trying to predict</p>