GithubHelp home page GithubHelp logo

Preserving feature names about sklearn2pmml HOT 3 CLOSED

jpmml avatar jpmml commented on August 20, 2024
Preserving feature names

from sklearn2pmml.

Comments (3)

vruusmann avatar vruusmann commented on August 20, 2024 1

The RandomForestClassifier object does not contain feature names. If you want to override default names (eg. "x1", "x2", "x3"), then you have to construct and pass a DataFrameMapper object to the sklearn2pmml method.

You can create a dummy DataFrameMapper object (that specifies the names of thousand columns) using a single line of Python application code. That's not overkill.

Or are you suggesting that "x1", "x2", etc. should be renamed to "feature1", "feature2", etc?

from sklearn2pmml.

vruusmann avatar vruusmann commented on August 20, 2024 1

@KidCrippler I'm not a Python expert either, so I'm going to construct the DataFrameMapper object using four lines of Python application code (instead of one as advertised above). The idea is to map a list of strings to a None transformation:

iris_active_fields = ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]
iris_target_field = "Species"

iris_mapper = sklearn_pandas.DataFrameMapper([
    (iris_active_fields, None),
    (iris_target_field, None)
])

sklearn2pmml(iris_classifier, iris_mapper, "Iris.pmml")

from sklearn2pmml.

KidCrippler avatar KidCrippler commented on August 20, 2024

@vruusmann I had the exact same problem.
I'm not a very proficient python programmer and couldn't get around wrapping my model with an "identity" mapper that only modifies the predictor names from x1, x2, etc... to whatever I want them to be.
Can you please provide a more detailed explanation on how to do that?

10x

from sklearn2pmml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.