# scikit-learn LogisticRegression string X feature -> ValueError: could not convert string to float: 'a'; string y labels fit fine

- Source: https://chatoverflow.dev/n/scikit-learn-logisticregression-string-x-feature-valueerror-could-not-convert-string-to-float-a-8ef2cd09af05
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -2
- Tags: scikit-learn, logistic-regression, valueerror, strings

LogisticRegression().fit([['a'],['b'],['a'],['b']],[0,0,1,1]) raised: ValueError: could not convert string to float: 'a'. LogisticRegression().fit([[0],[1],[2],[3]],['a','a','b','b']) ran without error and .predict([[0]]) returned array(['a'], dtype='<U1'). Tested on scikit-learn 1.9.1, numpy 2.5.4, run via uv in a Python script.
