GridSearchCV() to fine tune outputs ValueError and FitFailedWarning I want to fine tune some parameters for my linear SVM.
This is the code:
class SVMSentiment(Base):
&quot;&quot;&quot;Predict sentiment scores using a linear Support Vector Machine (SVM).
Uses a sklearn pipeline.
&quot;&quot;&quot;
def __init__(self, model_file: str=None) -&gt; None:
    super().__init__()
    # pip install sklearn
    from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer, TfidfVectorizer
    from sklearn.linear_model import SGDClassifier
    from sklearn.svm import LinearSVC
    from sklearn.pipeline import Pipeline
    self.pipeline = Pipeline(
        [
            #('vect', CountVectorizer()),
            #('tfidf', TfidfTransformer()),
            ('tfidf', TfidfVectorizer()),
            ('clf', LinearSVC(



            #('clf', SGDClassifier(
              #  loss='hinge',
               # penalty='l2',
                #alpha=1e-4,
                #random_state=42,
                #max_iter=100,
                #learning_rate='optimal',
                #tol=None,

            )),
        ]
    )

def predict(self, train_file: str, test_file: str, lower_case: bool) -&gt; pd.DataFrame:
    &quot;Train model using sklearn pipeline&quot;
    from sklearn.model_selection import GridSearchCV
    from sklearn.svm import SVC
    train_df = self.read_data(train_file, lower_case)
    parameters = {'C': [1, 10],
                  'gamma': [0.001, 0.01, 1]}
    model = SVC()
    grid = GridSearchCV(estimator=model, param_grid=parameters)
    grid.fit(train_df['text'], train_df['truth'])
    print(grid)
    # summarize the results of the grid search
    print(grid.best_params_)
    print(grid.best_estimator_)

    learner = self.pipeline.fit(train_df['text'], train_df['truth'])
    # Fit the learner to the test data
    test_df = self.read_data(test_file, lower_case)

    test_df['pred'] = learner.predict(test_df['text'])
    return test_df

However, I'm having some issues as it raised some ValueErrors: ValueError: could not convert string to floatand I don't know how to deal with this information. And also:  FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. How can I solve these?
The problem here is that the data train_df or test_df where ever the error is coming has a column which has a string(object) data type. you can't fit string data into a model. Only numerical data is allowed.

try printing
print(train_df.info())
print(test_df.info())


to see which column should be float type but is a string.