title: Sklearn Column Transformer ValueError: could not convert string to float:
body: <p>I am trying to make a pipeline using the <a href="https://scikit-learn.org/stable/auto_examples/compose/plot_column_transformer_mixed_types.html" rel="nofollow noreferrer">Column Transformer with Mixed Types</a> example from scikit-learn page in my dataset but I am getting the error : <code>ValueError: could not convert string to float: 'Male'</code>.</p>
  
  <pre><code>from sklearn.compose import ColumnTransformer, make_column_transformer
  from sklearn.pipeline import Pipeline
  from sklearn.impute import SimpleImputer
  from sklearn.preprocessing import StandardScaler, LabelEncoder, OneHotEncoder
  from sklearn.model_selection import train_test_split, GridSearchCV
  from sklearn.pipeline import make_pipeline
  from sklearn.compose import make_column_selector as selector
  from sklearn.linear_model import LogisticRegression
  
  numeric_transformer = Pipeline(steps=[
      ('imputer', SimpleImputer(strategy='median')),
      ('scaler', StandardScaler())
      ])
  
  categorical_transformer = Pipeline(steps=[
      ('imputer', SimpleImputer(strategy='most_frequent')),
      ('onehot',  OneHotEncoder())
      ])
  
  
  preprocessor = ColumnTransformer(transformers=[
      ('num', numeric_transformer, selector(dtype_exclude=["category",'object'])),
      ('cat', categorical_transformer, selector(dtype_include=["category",'object']))
  ])
  
  X = train.drop(['Loan_Status', 'Loan_ID'], axis=1)
  y = train['Loan_Status']
  
  
  x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=101)
  
  pipeline = Pipeline(steps = [('preprocessor', preprocessor),
                      ('classifier',LogisticRegression())
                    ])
  
  pipeline.fit(x_train, y_train)
  score = clf.score(x_test, y_test)
  </code></pre>
  
  <p>I have read other related posts with the same error but all other occur in the fit mine occurs in the score evaluation. </p>
  
  <pre><code>---------------------------------------------------------------------------
  
  ValueError                                Traceback (most recent call last)
  
  &lt;ipython-input-19-df09dd400283&gt; in &lt;module&gt;()
        4 
        5 pipeline.fit(x_train, y_train)
  ----&gt; 6 score = clf.score(x_test, y_test)
  
  4 frames
  
  /usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
       83 
       84     """
  ---&gt; 85     return array(a, dtype, copy=False, order=order)
       86 
       87 
  
  ValueError: could not convert string to float: 'Male'
  </code></pre>
  
  <p>This is an overview of the dataset dtypes :</p>
  
  <pre><code>Loan_ID               object
  Gender                object
  Married               object
  Dependents            object
  Education             object
  Self_Employed         object
  ApplicantIncome        int64
  CoapplicantIncome    float64
  LoanAmount           float64
  Loan_Amount_Term     float64
  Credit_History       float64
  Property_Area         object
  Loan_Status           object
  dtype: object
  </code></pre>
  
  <p>Also the first few rows of the dataset :
  <a href="https://i.stack.imgur.com/UlZv9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UlZv9.png" alt="enter image description here"></a></p>