scikit-learn

Trying to apply fit_transofrm() function from sklearn.compose.ColumnTransformer class on array but getting "tuple index out of range" error

Trying to apply fit_transofrm() function from sklearn.compose.ColumnTransformer class on array but getting "tuple index out of range" error Question: I am beginner in ML/AI and trying to do pre-proccesing on my dataset of digits that I’ve made myself. I want to apply OneHotEncoding on my categorical variable (which is a dependent one,idk if it is …

Total answers: 1

Is sklearn.model_selection.GridSearchCV can do custom threshold?

Is sklearn.model_selection.GridSearchCV can do custom threshold? Question: My goal is to do threshold tuning before parameter tuning. The idea is simple, in imbalanced dataset, if class 1 is minority, then the threshold should be lower than 0.5, so it predict more instance as class 1 instead of 0. Therefore, I believe, by changing the threshold …

Total answers: 1

MinMaxScaler Python Changes original Data

MinMaxScaler Python Changes original Data Question: I am trying to have 4 of my 5 csv column to predict the last column. i used MinMaxScaler to scale my data to 0-1 range, but at some point when i want to invers_transform it, MinMaxScaler changes my original data. Here is my Code: dataset = read_csv(‘zz.csv’, header=0, …

Total answers: 1

do i need to use exactly same attribute names to properties in custom preprocessing class which inherit scikit learn BaseEstimator?

do i need to use exactly same attribute names to properties in custom preprocessing class which inherit scikit learn BaseEstimator? Question: when writing custom classes inherit from BaseEstimator of the sklearn throwing AttributeError: object has no attribute . but that attribute is present and has values. class BaseNull(BaseEstimator, TransformerMixin): def __init__(self, variables: Union[str, list[str]], row_wise: …

Total answers: 1

How to identify in which region new point will lie using Sklearn Python?

How to identify in which region new point will lie using Sklearn Python? Question: I have a sample code for the Sklearn taken from the website. I am trying to learn how to classify points using Sklearn(Scikit-Learn). Here is the code: import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap from sklearn.model_selection …

Total answers: 3

Linear regression for time series

Linear regression for time series Question: I am pretty new to Machine Learning and have some confusion, so sorry for trivial question. I have time series data set, very simple with two columns – Date and Price. I’m predicting the price and want to add some features to my model like moving average for last …

Total answers: 2

Scikit-Learn Linear Regression using Datetime Values and forecasting

Scikit-Learn Linear Regression using Datetime Values and forecasting Question: Below is a sample of the dataset. row_id datetime energy 1 2008-03-01 00:00:00 1259.985563 2 2008-03-01 01:00:00 1095.541500 3 2008-03-01 02:00:00 1056.247500 4 2008-03-01 03:00:00 1034.742000 5 2008-03-01 04:00:00 1026.334500 The dataset has datetime values and energy consumption for that hour in object and float64 dtypes. …

Total answers: 1

AxisError: axis -1 is out of bounds

AxisError: axis -1 is out of bounds Question: I already referred the posts here,here and here Am trying to run a lassoCV model and fit it on my training dataset. So, I tried the below code (this works) from numpy import arange from sklearn.linear_model import LassoCV from sklearn.model_selection import RepeatedKFold # define model evaluation method …

Total answers: 1

Pythonic way to create dataset for multilabel text classification

Pythonic way to create dataset for multilabel text classification Question: I have a text dataset that looks like this. import pandas as pd df = pd.DataFrame({‘Sentence’: [‘Hello World’, ‘The quick brown fox jumps over the lazy dog.’, ‘Just some text to make third sentence!’ ], ‘label’: [‘greetings’, ‘dog,fox’, ‘some_class,someother_class’ ]}) I want to transform this …

Total answers: 1

cannot import name 'BisectingKMeans' from 'sklearn.cluster' (C:UsersAdministratoranaconda3libsite-packagessklearncluster__init__.py)

cannot import name 'BisectingKMeans' from 'sklearn.cluster' (C:UsersAdministratoranaconda3libsite-packagessklearncluster__init__.py) Question: When I try to use sklearn.cluster.BisectingKMeans in my jupyter notebook, an ImportError occured. It is said in the document that this method is new in version 1.1, and my scikit-learn version is 1.1.3. I was using the base environment so it’s not an issue of lacking package …

Total answers: 1