dotnet / dotnet/machinelearning

Field with type string cannot be transformed for one hot encoder

Open
#6,889 4 comments 0 reactions 0 assignees View on GitHub
area-Transforms untriaged
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

**System Information (please complete the following information):**
- OS & Version: Windows 10
- ML.NET Version: ML.NET v3.0.0-preview.23511.1
- .NET Version: .NET 7.0

**Describe the bug**
I'm not able to process the data which I'm providing, when I'm using in the model one hot encoder. The string can not be processed.
![image](https://github.com/dotnet/machinelearning/assets/28846353/37454c0a-4201-4380-8ec9-77b03e07360e)

**To Reproduce**
Steps to reproduce the behavior:
```
//Define DataViewSchema for data preparation pipeline and trained model
DataViewSchema dataPrepPipelineSchema, modelSchema;

// Load trained model
ITransformer dataPrepPipeline = mlContext.Model.Load("data_preparation_pipeline.zip", out dataPrepPipelineSchema);
ITransformer predictionPipeline = mlContext.Model.Load("model.zip", out modelSchema);

//Load New Data
var newData = DataFrame.LoadCsv("data/input.csv");

// Preprocess Data
IDataView transformedNewData = dataPrepPipeline.Transform(newData);

IDataView predictions = predictionPipeline.Transform(transformedNewData);
```

**Expected behavior**
Model can load data with type string
[data_preparation_pipeline.zip](https://github.com/dotnet/machinelearning/files/13451636/data_preparation_pipeline.zip)
[model.zip](https://github.com/dotnet/machinelearning/files/13451637/model.zip)
[input.csv](https://github.com/dotnet/machinelearning/files/13451641/input.csv)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.