All Questions
138 questions
1
vote
2
answers
70
views
ElasticNetCV in Python: Get full grid of hyperparameters with corresponding MSE?
I have fitted a ElasticNetCV in Python with three splits:
import numpy as np
from sklearn.linear_model import LinearRegression
#Sample data:
num_samples = 100 # Number of samples
num_features = 1000 ...
2
votes
3
answers
96
views
Pandas takes all columns of a dataframe even when some columns are specified
I am trying to train KMeans model using Scikit-Learn.
I am stuck on this issue for 2 days.
Pandas is selecting all columns of a dataframe even though I specified 2 columns.
Here is the dataframe in ...
0
votes
0
answers
25
views
_fit_method for KNN gives KD-tree even though I'm working in a high dimensional spce
so since KNeighborsClassifier class in sklearn find the best algorithm depending on the values from fit method when using auto (which is the default), when accessing the algorithm using ._fit_method I ...
-1
votes
2
answers
120
views
Sklearn Random Forest: determine the name of features ascertained by parameter grid for model fit and prediction
New to ML here and trying my hands on fitting a model using Random Forest. Here is my simplified code:
X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.15, ...
0
votes
1
answer
291
views
How to get predict from string data in sklearn
When I convert data from a pandas dataframe to sklearn so I can make predictions. String data becomes problematic. So I used labelencoder but it seems to limit me to using the encoded data instead of ...
0
votes
1
answer
141
views
Count fruits on tree using ML sklearn
This my python code where I am try to predict the fruit count on tree using sklearn
but ran into issue code is given below:
import cv2
from sklearn.ensemble import RandomForestClassifier
def ...
0
votes
1
answer
315
views
How to use FunctionTransformer with a custom function?
I want to use FunctionTransformer to perform calculations between columns. For instance, I want to substract two columns and add the the new column to the dataset. So I have the function:
def diff(x, ...
1
vote
1
answer
283
views
Problems applying a Sklearn ML model to a datraframe pandas with multiple columns and data types
I need to predict the data from several columns of the pandas dataframe (ml_train_inputs), where there could be columns with several data types, for example: str, float, int, timestamp, etc. In this ...
0
votes
1
answer
138
views
Problems converting text input to numeric format with TfidfVectorizer of Sklearn
I'm trying to train a model with Sklearn. In short, I have a Pandas Dataframe with two columns, the 'review' where I have the input (text format) and the 'sentiment' column, but I having trouble ...
0
votes
1
answer
2k
views
Is there a way to combine these sklearn Pipelines/ColumnTransformers so I don't have to make multiple fit_transform() calls?
I'd like to create a Pipeline where I can call fit_transform() just one time on my train dataset (train_df) and receive a fully preprocessed dataset. I don't think I can currently do that, however, ...
1
vote
1
answer
342
views
train, test, validation splits in tfds.load
so I am asked to implement the split function parameter: 80% train, 10% validation, and 10% test. And I do not understand how to do it here. Please help. Thanks.
def plot_example(x_raw, y_raw):
fig, ...
0
votes
0
answers
308
views
Multiple Linear Regression Model - ValueError: X has 6 features, but LinearRegression is expecting 22 features as input
I have fitted a Linear Regression model using sklearn in python using 22 columns of training data in order to predict market prices. See below:
#X_train is our training values to predict y
X_train = ...
0
votes
1
answer
813
views
TypeError: '<' not supported between instances of 'str' and 'bool' although info doesn't have bool in sklearn column transformer
There are similar questions asked before on stackoverflow, however, none of them could fix my problem. I don't understand why info() clearly doesn't output a "bool" but sklearn is outputting ...
0
votes
1
answer
1k
views
Decision Tree Classifier took 16min to fit
So, for some reasons, It took my laptop to 16min to fit data into DecisionTreeClassifier. It usually take like 1 sec to fit into other type of machine learning model. Anyone can help me with what is ...
3
votes
1
answer
5k
views
Error : All estimators should implement fit and transform, or can be 'drop' or 'passthrough' specifiers when using make_column_transformer
I am trying to implement a model that uses ColumnTransformer() followed by SVC().
My transform method looks like:
num_features = X_train_svm.select_dtypes(include=np.number).columns.to_list()
...