title: ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). sklearn
body: <p>Here is my My code:</p>
  <pre><code>import pandas as pd 
  df = pd.read_csv('train.csv')
  
  gender_dict = {&quot;male&quot;: 1, &quot;female&quot;: 2}
  eye_color_dict = {&quot;amber&quot;: 1, &quot;blue&quot;: 2, &quot;brown&quot;: 3, &quot;gray&quot;: 4, &quot;green&quot;: 5, &quot;hazel&quot;: 6}
  race_dict = {&quot;black&quot;: 1, &quot;white&quot;: 2, &quot;middle_eastern&quot;: 3,&quot;asian&quot;:4}
  accommodation_type_dict = {&quot;apartment&quot;: 1, &quot;homeless&quot;: 2, &quot;shared_residence&quot;: 3, &quot;villa&quot;: 4, &quot;other&quot;: 5}
  education_status_dict = {&quot;associate_degree&quot;: 1, &quot;bachelors_degree&quot;: 2, &quot;graduate_or_professional_degree&quot;: 3, &quot;high_school&quot;: 4, &quot;less_than_9th_grade&quot;: 5, &quot;not_applicable&quot;: 6}
  blood_type_dict = {&quot;A+&quot;: 1, &quot;A-&quot;: 2, &quot;B+&quot;: 3, &quot;B-&quot;: 4, &quot;O+&quot;: 5, &quot;O-&quot;: 6, &quot;AB+&quot;: 7, &quot;AB-&quot;: 8}
  occupation_dict = {&quot;agriculture&quot;: 1, &quot;art&quot;: 2, &quot;business&quot;: 3, &quot;education&quot;: 4, &quot;engineering&quot;: 5, &quot;healthcare&quot;: 6, &quot;unemployed&quot;: 7, &quot;other&quot;: 8}
  living_area_dict = {&quot;suburbs&quot;: 1, &quot;rural&quot;: 2, &quot;urban&quot;: 3, &quot;other&quot;: 4}
  sports_engagement_dict = {&quot;never&quot;: 1, &quot;sometimes&quot;: 2, &quot;seldom&quot;: 3, &quot;regularly&quot;: 4}
  favorite_music_genre_dict = {&quot;r&amp;b&quot;: 1, &quot;rock&quot;: 2, &quot;pop&quot;: 3, &quot;country&quot;: 4, &quot;other&quot;: 5, &quot;edm&quot;: 6, &quot;classical&quot;: 7}
  favorite_color_dict = {&quot;green&quot;: 1, &quot;orange&quot;: 2, &quot;yellow&quot;: 3, &quot;purple&quot;: 4, &quot;blue&quot;: 5, &quot;pink&quot;: 6, &quot;red&quot;: 7}
  owned_car_brand_dict = {&quot;audi&quot;: 1, &quot;bmw&quot;: 2, &quot;ford&quot;: 3, &quot;honda&quot;: 4, &quot;hyundai&quot;: 5, &quot;kia&quot;: 6, &quot;none&quot;: 7, &quot;tesla&quot;: 8, &quot;other&quot;: 9, &quot;mitsubishi&quot;: 10}
  hours_worked_each_week_dict = {&quot;not_applicable&quot;: 1}
  owns_a_pet_dict = {&quot;yes&quot;: 1, &quot;no&quot;: 2}
  has_health_insurance_dict = {&quot;yes&quot;: 1, &quot;no&quot;: 2}
  has_cancer_dict = {&quot;yes&quot;: 1, &quot;no&quot;: 2}
  smokes_dict = {&quot;yes&quot;: 1, &quot;no&quot;: 2}
  has_alzheimers_dict = {&quot;yes&quot;: 1, &quot;no&quot;: 2}
  facial_hair_dict = {&quot;long&quot;: 1, &quot;short&quot;: 2, &quot;none&quot;: 3}
  diet_type_dict = {&quot;regular&quot;: 1, &quot;vegetarian&quot;: 2, &quot;keto&quot;: 3, &quot;vegan&quot;: 4, &quot;low-carb&quot;: 5, &quot;paleo&quot;: 6}
  
  df['gender'] = df['gender'].map(gender_dict)
  df['eye_color'] = df['eye_color'].map(eye_color_dict)
  df['race'] = df['race'].map(race_dict)
  df['accommodation_type'] = df['accommodation_type'].map(accommodation_type_dict)
  df['education_status'] = df['education_status'].map(education_status_dict)
  df['blood_type'] = df['blood_type'].map(blood_type_dict)
  df['occupation'] = df['occupation'].map(occupation_dict)
  df['living_area'] = df['living_area'].map(living_area_dict)
  df['sports_engagement'] = df['sports_engagement'].map(sports_engagement_dict)
  df['favorite_music_genre'] = df['favorite_music_genre'].map(favorite_music_genre_dict)
  df['favorite_color'] = df['favorite_color'].map(favorite_color_dict)
  df['owned_car_brand'] = df['owned_car_brand'].map(owned_car_brand_dict)
  df['hours_worked_each_week'] = df['hours_worked_each_week'].map(hours_worked_each_week_dict)
  df['owns_a_pet'] = df['owns_a_pet'].map(owns_a_pet_dict)
  df['has_health_insurance'] = df['has_health_insurance'].map(has_health_insurance_dict)
  df['has_cancer'] = df['has_cancer'].map(has_cancer_dict)
  df['smokes'] = df['smokes'].map(smokes_dict)
  df['has_alzheimers'] = df['has_alzheimers'].map(has_alzheimers_dict)
  df['facial_hair'] = df['facial_hair'].map(facial_hair_dict)
  df['diet_type'] = df['diet_type'].map(diet_type_dict)
  
  import sklearn
  from sklearn import svm, preprocessing
  
  df = sklearn.utils.shuffle(df)
  
  X = df.drop(&quot;infected&quot;, axis=1).values
  X = preprocessing.scale(X)
  y = df['infected'].values
  
  test_size = 200
  
  X_train = X[:-test_size]
  y_train = y[:-test_size]
  
  X_test = X[-test_size:]
  y_test = y[-test_size:]
  
  clf = svm.SVR(kernel=&quot;linear&quot;)
  clf.fit(X_train,y_train)
  
  clf.score(X_test,y_test)
  
  for X,y in zip(X_test, y_test):
      print(f&quot;Model: {clf.predict([X])[0]}, Actual: {y}&quot;)
    
  </code></pre>
  <p>I'm getting value error:</p>
  <blockquote>
  <p>ValueError: Input contains NaN, infinity or a value too large for dtype('float64').</p>
  </blockquote>
  <p>And it told me :</p>
  <blockquote>
  <p><code>&lt;ipython-input-1-8b8c4c2d113b&gt; in &lt;module&gt;</code>
  <code>62 </code>
  <code>63 clf = svm.SVR(kernel=&quot;linear&quot;)</code>
  <code>---&gt; 64 clf.fit(X_train,y_train)</code>
  <code>65  </code>66 clf.score(X_test,y_test)`</p>
  </blockquote>
  <p><a href="https://1drv.ms/u/s!Al32Y2Ae1QmOaJiT4urDkIfhVJo?e=0jJkFs" rel="nofollow noreferrer">this is the link to train.csv</a></p>
  <p>I'm using jupyter-notebook, I'm new to sklearn and ml
  I attached the CSV file above, thank you for your help</p>