Sklearn Pipeline: Get feature names after OneHotEncode In ColumnTransformer

You can access the feature_names using the following snippet: clf.named_steps[‘preprocessor’].transformers_[1][1]\ .named_steps[‘onehot’].get_feature_names(categorical_features) Using sklearn >= 0.21 version, we can make it even simpler: clf[‘preprocessor’].transformers_[1][1]\ [‘onehot’].get_feature_names(categorical_features) Reproducible example: import numpy as np import pandas as pd from sklearn.impute import SimpleImputer from sklearn.preprocessing import OneHotEncoder, StandardScaler from sklearn.pipeline import Pipeline from sklearn.compose import ColumnTransformer from sklearn.linear_model import LinearRegression … Read more

Functional pipes in python like %>% from R’s magrittr

Pipes are a new feature in Pandas 0.16.2. Example: import pandas as pd from sklearn.datasets import load_iris x = load_iris() x = pd.DataFrame(x.data, columns=x.feature_names) def remove_units(df): df.columns = pd.Index(map(lambda x: x.replace(” (cm)”, “”), df.columns)) return df def length_times_width(df): df[‘sepal length*width’] = df[‘sepal length’] * df[‘sepal width’] df[‘petal length*width’] = df[‘petal length’] * df[‘petal width’] x.pipe(remove_units).pipe(length_times_width) … Read more

Getting model attributes from pipeline

Did you look at the documentation: http://scikit-learn.org/dev/modules/pipeline.html I feel it is pretty clear. Update: in 0.21 you can use just square brackets: pipeline[‘pca’] or indices pipeline[1] There are two ways to get to the steps in a pipeline, either using indices or using the string names you gave: pipeline.named_steps[‘pca’] pipeline.steps[1][1] This will give you the … Read more

How do you determine if WPF is using Hardware or Software Rendering?

Check RenderCapability.Tier Graphics Rendering Tiers RenderCapability Class [UPDATE] RenderCapability.IsPixelShaderVersionSupported – Gets a value that indicates whether the specified pixel shader version is supported. RenderCapability.IsShaderEffectSoftwareRenderingSupported – Gets a value that indicates whether the system can render bitmap effects in software. RenderCapability.Tier – Gets a value that indicates the rendering tier for the current thread. RenderCapability.TierChanged – … Read more

C Minishell Adding Pipelines

Here’s some moderately generic but simple code to execute pipelines, a program I’m calling pipeline. It’s an SSCCE in a single file as presented, though I’d have the files stderr.h and stderr.c as separate files in a library to be linked with all my programs. (Actually, I have a more complex set of functions in … Read more