pipeline

How run sklearn.preprocessing.OrdinalEncoder on several columns?

How run sklearn.preprocessing.OrdinalEncoder on several columns? Question: this code raise error: import pandas as pd from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.preprocessing import OrdinalEncoder # Define categorical columns and mapping dictionary categorical_cols = [‘color’, ‘shape’, ‘size’] mapping = {‘red’: 0, ‘green’: 1, ‘blue’: 2, ‘circle’: 0, ‘square’: 1, ‘triangle’: 2, ‘small’: 0, …

Total answers: 2

Return pipeline score as one of multiple evaluation metrics

Return pipeline score as one of multiple evaluation metrics Question: I am using a pipeline in a hyperparameter gridsearch in sklearn. I would like the search to return multiple evaluation scores – one a custom scoring function that I wrote, and the other the default score function of the pipeline. I tried using the parameter …

Total answers: 1

Issue with the aggregation function in the pipeline during online ingest

Issue with the aggregation function in the pipeline during online ingest Question: I see issue in the aggregation function (part of pipeline) during the online ingest, because aggregation output is invalid (output is different then expectation, I got value 0 instead of 6). The pipeline is really very simple: See part of code (Python and …

Total answers: 1

sklearn to pmml pipeline how to apply postprocessing linear trasnformation

sklearn to pmml pipeline how to apply postprocessing linear trasnformation Question: I’m having a tough time trying to apply a postprocessing step with the sklearn2pmml packages. What I’m trying to do is to apply a linear transformation after applying the predict_proba method within the PMMMLPipeline class in sklearn2pmml package. Any idea about how to do …

Total answers: 2

How to fail a gitlab CI pipeline if the python script throws error code 1?

How to fail a gitlab CI pipeline if the python script throws error code 1? Question: I have a python file that opens and checks for a word. The program returns 0 if pass and 1 if fails. import sys word = "test" def check(): with open("tex.txt", "r") as file: for line_number, line in enumerate(file, …

Total answers: 1

How to get an output from ONEAI NLP API?

How to get an output from ONEAI NLP API? Question: I found a very cool NLP API that helps analyze text using special skills. However, I am new to Python and I don’t know how to get the output. Can someone help? This is what I tried: # Edit this One AI API call using …

Total answers: 1

Make available .best_params_ after pipeline

Make available .best_params_ after pipeline Question: How to go about making available the clf.best_params_ after carrying a pipeline? For the code I have below, I get an: AttributeError: ‘GridSearchCV’ object has no attribute ‘best_params_‘ Here is my code: from sklearn.datasets import make_classification import numpy as np from sklearn import metrics from sklearn.metrics import accuracy_score from …

Total answers: 1

Creating variable for $sum in aggregation

MongoDB Aggregation – Creating variable for $sum Question: Sample input: { "students":[ { "name" : "John", "semesters":[ { "semester": "fall", "grades": [ {"EXAM_1" : 25}, {"EXAM_2" : 45}, {"EXAM_3" : 22} ] }, { "semester": "winter", "grades": [ {"EXAM_1" : 85}, {"EXAM_2" : 32}, {"EXAM_3" : 17} ] } ] },{ "name" : "Abraham", "semesters":[ …

Total answers: 1

Save sklearn pipeline diagram

Save sklearn pipeline diagram Question: I want to save a pipeline displayed with the set_config(display="diagram") command, see below: Is there a better way to do it than by taking a screenshot? Asked By: Joris Limonier || Source Answers: Maybe you can try the following approach screenshot from twitter Credit twitter link Answered By: amalina_sulaiman from …

Total answers: 2