title: Python: Naive Bayes fit function gives TypeError: float() argument must be a string or a number
body: <p>The below code of Python 2.7 is giving error:</p>
  
  <pre><code>beta=0.5
  
  from sklearn.naive_bayes import GaussianNB
  nb = GaussianNB()
  print "Y_Train data: ",y_train
  print "X_Train data: ",X_train
  nb.fit(X_train,y_train)
  
  nb.fit(X_train,y_train)
  
  Traceback (most recent call last):
  File "&lt;ipython-input-116-c1ccb2227816&gt;", line 1, in &lt;module&gt;
  nb.fit(X_train,y_train)
  File "C:\Anaconda3\envs\py27\lib\site-packages\sklearn\naive_bayes.py", line 
  173, in fit
  X, y = check_X_y(X, y)
  File "C:\Anaconda3\envs\py27\lib\site-packages\sklearn\utils\validation.py", 
  line 510, in check_X_y
  ensure_min_features, warn_on_dtype, estimator)
  File "C:\Anaconda3\envs\py27\lib\site-packages\sklearn\utils\validation.py", 
  line 393, in check_array
  array = array.astype(np.float64)
  TypeError: float() argument must be a string or a number
  
  print train.dtypes
  </code></pre>
  
  <p>id                                                int64</p>
  
  <p>timestamp                                datetime64[ns]</p>
  
  <p>full_sq                                         float64</p>
  
  <p>product_type                                      int64</p>
  
  <p>sub_area                                          int64</p>
  
  <p>area_m                                          float64</p>
  
  <p>raion_popul                                       int64</p>
  
  <p>green_zone_part                                 float64</p>
  
  <p>indust_part                                     float64</p>
  
  <p>children_preschool                                int64</p>
  
  <p>preschool_education_centers_raion                 int64</p>
  
  <p>children_school                                   int64</p>
  
  <p>school_education_centers_raion                    int64</p>
  
  <p>school_education_centers_top_20_raion           float64</p>
  
  <p>healthcare_centers_raion                          int64</p>
  
  <p>university_top_20_raion                         float64</p>
  
  <p>sport_objects_raion                             float64</p>
  
  <p>additional_education_raion                      float64</p>
  
  <p>culture_objects_top_25                            int64</p>
  
  <p>culture_objects_top_25_raion                    float64</p>
  
  <p>shopping_centers_raion                          float64</p>
  
  <p>office_raion                                    float64</p>
  
  <p>thermal_power_plant_raion                         int64</p>
  
  <p>incineration_raion                                int64</p>
  
  <p>oil_chemistry_raion                               int64</p>
  
  <p>radiation_raion                                   int64</p>
  
  <p>railroad_terminal_raion                           int64</p>
  
  <p>big_market_raion                                  int64</p>
  
  <p>nuclear_reactor_raion                             int64</p>
  
  <p>detention_facility_raion                          int64</p>
  
  <p>full_all                                        float64</p>
  
  <p>male_f                                          float64</p>
  
  <p>female_f                                        float64</p>
  
  <p>young_all                                         int64</p>
  
  <p>young_male                                        int64</p>
  
  <p>young_female                                      int64</p>
  
  <p>work_all                                          int64</p>
  
  <p>work_male                                         int64</p>
  
  <p>work_female                                       int64</p>
  
  <p>ekder_all                                         int64</p>
  
  <p>ekder_male                                        int64</p>
  
  <p>ekder_female                                      int64</p>
  
  <p>0_6_all                                           int64</p>
  
  <p>0_6_male                                          int64</p>
  
  <p>0_6_female                                        int64</p>
  
  <p>7_14_all                                          int64</p>
  
  <p>7_14_male                                         int64</p>
  
  <p>7_14_female                                       int64</p>
  
  <p>0_17_all                                          int64</p>
  
  <p>0_17_male                                         int64</p>
  
  <p>0_17_female                                       int64</p>
  
  <p>16_29_all                                       float64</p>
  
  <p>16_29_male                                      float64</p>
  
  <p>16_29_female                                    float64</p>
  
  <p>0_13_all                                          int64</p>
  
  <p>0_13_male                                         int64</p>
  
  <p>0_13_female                                       int64</p>
  
  <p>ID_metro                                          int64</p>
  
  <p>metro_min_avto                                  float64</p>
  
  <p>metro_km_avto                                   float64</p>
  
  <p>kindergarten_km                                 float64</p>
  
  <p>school_km                                       float64</p>
  
  <p>park_km                                         float64</p>
  
  <p>green_zone_km                                   float64</p>
  
  <p>industrial_km                                   float64</p>
  
  <p>water_treatment_km                              float64</p>
  
  <p>cemetery_km                                     float64</p>
  
  <p>incineration_km                                 float64</p>
  
  <p>railroad_station_avto_km                        float64</p>
  
  <p>railroad_station_avto_min                       float64</p>
  
  <p>ID_railroad_station_avto                          int64</p>
  
  <p>public_transport_station_km                     float64</p>
  
  <p>public_transport_station_min_walk               float64</p>
  
  <p>water_km                                        float64</p>
  
  <p>water_1line                                       int64</p>
  
  <p>mkad_km                                         float64</p>
  
  <p>ttk_km                                          float64</p>
  
  <p>sadovoe_km                                      float64</p>
  
  <p>bulvar_ring_km                                  float64</p>
  
  <p>kremlin_km                                      float64</p>
  
  <p>big_road1_km                                    float64</p>
  
  <p>ID_big_road1                                      int64</p>
  
  <p>big_road1_1line                                   int64</p>
  
  <p>big_road2_km                                    float64</p>
  
  <p>ID_big_road2                                      int64</p>
  
  <p>railroad_km                                     float64</p>
  
  <p>railroad_1line                                    int64</p>
  
  <p>zd_vokzaly_avto_km                              float64</p>
  
  <p>ID_railroad_terminal                              int64</p>
  
  <p>bus_terminal_avto_km                            float64</p>
  
  <p>ID_bus_terminal                                   int64</p>
  
  <p>oil_chemistry_km                                float64</p>
  
  <p>nuclear_reactor_km                              float64</p>
  
  <p>radiation_km                                    float64</p>
  
  <p>power_transmission_line_km                      float64</p>
  
  <p>thermal_power_plant_km                          float64</p>
  
  <p>ts_km                                           float64</p>
  
  <p>big_market_km                                   float64</p>
  
  <p>market_shop_km                                  float64</p>
  
  <p>fitness_km                                      float64</p>
  
  <p>swim_pool_km                                    float64</p>
  
  <p>ice_rink_km                                     float64</p>
  
  <p>stadium_km                                      float64</p>
  
  <p>basketball_km                                   float64</p>
  
  <p>hospice_morgue_km                               float64</p>
  
  <p>detention_facility_km                           float64</p>
  
  <p>public_healthcare_km                            float64</p>
  
  <p>university_km                                   float64</p>
  
  <p>workplaces_km                                   float64</p>
  
  <p>shopping_centers_km                             float64</p>
  
  <p>office_km                                       float64</p>
  
  <p>additional_education_km                         float64</p>
  
  <p>preschool_km                                    float64</p>
  
  <p>big_church_km                                   float64</p>
  
  <p>church_synagogue_km                             float64</p>
  
  <p>mosque_km                                       float64</p>
  
  <p>theater_km                                      float64</p>
  
  <p>museum_km                                       float64</p>
  
  <p>exhibition_km                                   float64</p>
  
  <p>catering_km                                     float64</p>
  
  <p>ecology                                           int64</p>
  
  <p>green_part_500                                  float64</p>
  
  <p>prom_part_500                                   float64</p>
  
  <p>office_count_500                                float64</p>
  
  <p>office_sqm_500                                  float64</p>
  
  <p>trc_count_500                                   float64</p>
  
  <p>trc_sqm_500                                     float64</p>
  
  <p>cafe_count_500                                  float64</p>
  
  <p>cafe_count_500_na_price                         float64</p>
  
  <p>cafe_count_500_price_500                        float64</p>
  
  <p>cafe_count_500_price_1000                       float64</p>
  
  <p>cafe_count_500_price_1500                       float64</p>
  
  <p>cafe_count_500_price_2500                       float64</p>
  
  <p>cafe_count_500_price_4000                       float64</p>
  
  <p>cafe_count_500_price_high                       float64</p>
  
  <p>big_church_count_500                            float64</p>
  
  <p>church_count_500                                float64</p>
  
  <p>mosque_count_500                                float64</p>
  
  <p>leisure_count_500                               float64</p>
  
  <p>sport_count_500                                 float64</p>
  
  <p>market_count_500                                float64</p>
  
  <p>green_part_1000                                 float64</p>
  
  <p>prom_part_1000                                  float64</p>
  
  <p>office_count_1000                               float64</p>
  
  <p>office_sqm_1000                                 float64</p>
  
  <p>trc_count_1000                                  float64</p>
  
  <p>trc_sqm_1000                                    float64</p>
  
  <p>cafe_count_1000                                 float64</p>
  
  <p>cafe_count_1000_na_price                        float64</p>
  
  <p>cafe_count_1000_price_500                       float64</p>
  
  <p>cafe_count_1000_price_1000                      float64</p>
  
  <p>cafe_count_1000_price_1500                      float64</p>
  
  <p>cafe_count_1000_price_2500                      float64</p>
  
  <p>cafe_count_1000_price_4000                      float64</p>
  
  <p>cafe_count_1000_price_high                      float64</p>
  
  <p>big_church_count_1000                           float64</p>
  
  <p>church_count_1000                               float64</p>
  
  <p>mosque_count_1000                               float64</p>
  
  <p>leisure_count_1000                              float64</p>
  
  <p>sport_count_1000                                float64</p>
  
  <p>market_count_1000                               float64</p>
  
  <p>green_part_1500                                 float64</p>
  
  <p>prom_part_1500                                  float64</p>
  
  <p>office_count_1500                               float64</p>
  
  <p>office_sqm_1500                                 float64</p>
  
  <p>trc_count_1500                                  float64</p>
  
  <p>trc_sqm_1500                                    float64</p>
  
  <p>cafe_count_1500                                 float64</p>
  
  <p>cafe_count_1500_na_price                        float64</p>
  
  <p>cafe_count_1500_price_500                       float64</p>
  
  <p>cafe_count_1500_price_1000                      float64</p>
  
  <p>cafe_count_1500_price_1500                      float64</p>
  
  <p>cafe_count_1500_price_2500                      float64</p>
  
  <p>cafe_count_1500_price_4000                      float64</p>
  
  <p>cafe_count_1500_price_high                      float64</p>
  
  <p>big_church_count_1500                           float64</p>
  
  <p>church_count_1500                               float64</p>
  
  <p>mosque_count_1500                               float64</p>
  
  <p>leisure_count_1500                              float64</p>
  
  <p>sport_count_1500                                float64</p>
  
  <p>market_count_1500                               float64</p>
  
  <p>green_part_2000                                 float64</p>
  
  <p>prom_part_2000                                  float64</p>
  
  <p>office_count_2000                               float64</p>
  
  <p>office_sqm_2000                                 float64</p>
  
  <p>trc_count_2000                                  float64</p>
  
  <p>trc_sqm_2000                                    float64</p>
  
  <p>cafe_count_2000                                 float64</p>
  
  <p>cafe_count_2000_na_price                        float64</p>
  
  <p>cafe_count_2000_price_500                       float64</p>
  
  <p>cafe_count_2000_price_1000                      float64</p>
  
  <p>cafe_count_2000_price_1500                      float64</p>
  
  <p>cafe_count_2000_price_2500                      float64</p>
  
  <p>cafe_count_2000_price_4000                      float64</p>
  
  <p>cafe_count_2000_price_high                      float64</p>
  
  <p>big_church_count_2000                           float64</p>
  
  <p>church_count_2000                               float64</p>
  
  <p>mosque_count_2000                               float64</p>
  
  <p>leisure_count_2000                              float64</p>
  
  <p>sport_count_2000                                float64</p>
  
  <p>market_count_2000                               float64</p>
  
  <p>green_part_3000                                 float64</p>
  
  <p>prom_part_3000                                  float64</p>
  
  <p>office_count_3000                               float64</p>
  
  <p>office_sqm_3000                                 float64</p>
  
  <p>trc_count_3000                                  float64</p>
  
  <p>trc_sqm_3000                                    float64</p>
  
  <p>cafe_count_3000                                 float64</p>
  
  <p>cafe_count_3000_na_price                        float64</p>
  
  <p>cafe_count_3000_price_500                       float64</p>
  
  <p>cafe_count_3000_price_1000                      float64</p>
  
  <p>cafe_count_3000_price_1500                      float64</p>
  
  <p>cafe_count_3000_price_2500                      float64</p>
  
  <p>cafe_count_3000_price_4000                      float64</p>
  
  <p>cafe_count_3000_price_high                      float64</p>
  
  <p>big_church_count_3000                           float64</p>
  
  <p>church_count_3000                               float64</p>
  
  <p>mosque_count_3000                               float64</p>
  
  <p>leisure_count_3000                              float64</p>
  
  <p>sport_count_3000                                float64</p>
  
  <p>market_count_3000                                 int64</p>
  
  <p>green_part_5000                                 float64</p>
  
  <p>office_count_5000                               float64</p>
  
  <p>office_sqm_5000                                 float64</p>
  
  <p>trc_count_5000                                    int64</p>
  
  <p>trc_sqm_5000                                      int64</p>
  
  <p>cafe_count_5000                                 float64</p>
  
  <p>cafe_count_5000_na_price                        float64</p>
  
  <p>cafe_count_5000_price_500                       float64</p>
  
  <p>cafe_count_5000_price_1000                      float64</p>
  
  <p>cafe_count_5000_price_1500                      float64</p>
  
  <p>cafe_count_5000_price_2500                      float64</p>
  
  <p>cafe_count_5000_price_4000                      float64</p>
  
  <p>cafe_count_5000_price_high                      float64</p>
  
  <p>big_church_count_5000                           float64</p>
  
  <p>church_count_5000                               float64</p>
  
  <p>mosque_count_5000                                 int64</p>
  
  <p>leisure_count_5000                              float64</p>
  
  <p>sport_count_5000                                  int64</p>
  
  <p>market_count_5000                                 int64</p>
  
  <p>price_doc                                       float64</p>
  
  <p>the above are the columns with their datatypes.
  Why do you think I am getting this error please?
  Thanks in advance for your answer.</p>