id
stringlengths
7
11
source
stringclasses
1 value
category
stringclasses
11 values
title
stringlengths
15
214
text
stringlengths
70
30.5k
url
stringlengths
57
160
tags
stringlengths
3
113
created_at
int64
1.22B
1.79B
se_79259003
stackoverflow
MACHINE_LEARNING
Why do scikit-learn predict(X) methods accept a 2D matrix rather than a 1D vector?
Why do scikit-learn predict(X) methods accept a 2D matrix rather than a 1D vector? Does anyone know why the predict(X) methods of scikit-learn classifiers and regressors expect input X to be a 2D array (matrix) rather than a 1D array (vector)? I'm just curious about the history of the design. With the existing design,...
https://stackoverflow.com/questions/79259003/why-do-scikit-learn-predictx-methods-accept-a-2d-matrix-rather-than-a-1d-vecto
methods, scikit-learn, predict
1,733,509,775
se_79242610
stackoverflow
MACHINE_LEARNING
Implementing sklearn.ensemble.GradientBoostingRegressor with sklearn.multioutput.MultiOutputRegressor and sklearn.model_selection.RandomizedSearchCV
Implementing sklearn.ensemble.GradientBoostingRegressor with sklearn.multioutput.MultiOutputRegressor and sklearn.model_selection.RandomizedSearchCV I'm trying to create models that support multivariate output. One of the models I'm trying to use is the GradientBoostingRegressor which does not natively support multiva...
https://stackoverflow.com/questions/79242610/implementing-sklearn-ensemble-gradientboostingregressor-with-sklearn-multioutput
python, scikit-learn
1,733,093,388
se_65048479
stackoverflow
MACHINE_LEARNING
Unable to run autosklearn on colab
Unable to run autosklearn on colab I am trying to run auto-sklearn on Google colab. I have successfully installed AutoSklearn but it gives me error while running following code: Input: import autosklearn.classfication Output: --------------------------------------------------------------------------- IncorrectPac...
https://stackoverflow.com/questions/65048479/unable-to-run-autosklearn-on-colab
scikit-learn, google-colaboratory
1,606,558,408
se_70278059
stackoverflow
MACHINE_LEARNING
Plotting the ROC curve for a multiclass problem
Plotting the ROC curve for a multiclass problem I am trying to apply the idea of sklearn ROC extension to multiclass to my dataset. My per-class ROC curve looks find of a straight line each, unline the sklearn's example showing curve's fluctuating. I give an MWE below to show what I mean: # all imports import numpy as...
https://stackoverflow.com/questions/70278059/plotting-the-roc-curve-for-a-multiclass-problem
python, machine-learning, scikit-learn, roc, auc
1,638,979,334
se_79249247
stackoverflow
MACHINE_LEARNING
How do I make a neural network class with fit and predict functions like with sklearn models, when my train and test data are different sizes?
How do I make a neural network class with fit and predict functions like with sklearn models, when my train and test data are different sizes? I'm trying to make a neural network model that will answer a linear regression problem (I've already made a model using sklearn's LinearRegression and I'd like to compare the t...
https://stackoverflow.com/questions/79249247/how-do-i-make-a-neural-network-class-with-fit-and-predict-functions-like-with-sk
machine-learning, scikit-learn, pytorch, neural-network, linear-regression
1,733,262,070
se_71181291
stackoverflow
MACHINE_LEARNING
What is the difference between RepeatedStratifiedKFold and StratifiedKFold in sklearn?
What is the difference between RepeatedStratifiedKFold and StratifiedKFold in sklearn? I tried to read the docs for RepeatedStratifiedKFold and StratifiedKFold, but couldn't tell the difference between the two methods, except that RepeatedStratifiedKFold repeats StratifiedKFold n times with different randomization in...
https://stackoverflow.com/questions/71181291/what-is-the-difference-between-repeatedstratifiedkfold-and-stratifiedkfold-in-sk
python, machine-learning, scikit-learn, classification, cross-validation
1,645,230,161
se_70557002
stackoverflow
MACHINE_LEARNING
Why does sklearn tf-idf vectorizer give the highest scores to stopwords?
Why does sklearn tf-idf vectorizer give the highest scores to stopwords? I implemented Tf-idf with sklearn for each category of the Brown corpus in nltk library. There are 15 categories and for each of them the highest score is assigned to a stopword. The default parameter is use_idf=True, so I'm using idf. The corpus...
https://stackoverflow.com/questions/70557002/why-does-sklearn-tf-idf-vectorizer-give-the-highest-scores-to-stopwords
python, scikit-learn, nltk, tf-idf, tfidfvectorizer
1,641,135,423
se_70727739
stackoverflow
MACHINE_LEARNING
TfidfVectorizer seems to be giving incorrect results
TfidfVectorizer seems to be giving incorrect results I have a list of length 7 (7 subjectes) Each element in the list contains a long string of words. Each element of the list can be viewed as a topic with a long sentence that sets it apart I want to check which words make each topic unique (each element in the list) ...
https://stackoverflow.com/questions/70727739/tfidfvectorizer-seems-to-be-giving-incorrect-results
python, scikit-learn, nlp, tf-idf, tfidfvectorizer
1,642,312,988
se_66249963
stackoverflow
MACHINE_LEARNING
sklearn mutual_info_classif returns different values depending on feature order
sklearn mutual_info_classif returns different values depending on feature order I noticed behavior in the sklearn mutual_info_classif function that is inconsistent with what I expect in the mutual information objective. Given a set of columns ['A', 'B', 'C'] and a dependent variable y, the mutual information computed...
https://stackoverflow.com/questions/66249963/sklearn-mutual-info-classif-returns-different-values-depending-on-feature-order
python, scikit-learn, entropy
1,613,596,058
se_79244221
stackoverflow
MACHINE_LEARNING
Feature Importance with ColumnTransform and OneHotEncoder in RandomForestClassifier
Feature Importance with ColumnTransform and OneHotEncoder in RandomForestClassifier Apologies for bothering you, but I haven't been able to find a definitive answer after searching the site. I'm building a RandomForestClassifier on some clinical data where the target variable (outcome) is binary (0 or 1). I'm using Py...
https://stackoverflow.com/questions/79244221/feature-importance-with-columntransform-and-onehotencoder-in-randomforestclassif
python, scikit-learn, pipeline, random-forest
1,733,144,944
se_59287936
stackoverflow
MACHINE_LEARNING
Custom estimator for sklearn with a lot of params
Custom estimator for sklearn with a lot of params I am trying to make custom estimator for sklearn with a lot of params. As i understand, i should do something like this: class MyEstim(BaseEstimator): def __init__(self, param1, param2): super().__init__() self.param1 = param1 self.param2 = ...
https://stackoverflow.com/questions/59287936/custom-estimator-for-sklearn-with-a-lot-of-params
python, parameters, scikit-learn
1,576,074,298
se_44443479
stackoverflow
MACHINE_LEARNING
How to show loss values during training in scikit-learn?
How to show loss values during training in scikit-learn? I want check my loss values during the training time so I can observe the loss at each iteration. So far I haven't found an easy way for scikit learn to give me a history of loss values, nor did I find a functionality already within scikit to plot the loss for m...
https://stackoverflow.com/questions/44443479/how-to-show-loss-values-during-training-in-scikit-learn
python, machine-learning, scikit-learn
1,496,947,855
se_79232519
stackoverflow
MACHINE_LEARNING
Is the GaussianProcessRegressor estimator in scikit-learn able to be parallelized on multi-core?
Is the GaussianProcessRegressor estimator in scikit-learn able to be parallelized on multi-core? I do not notice any performance improvements when using GaussianProcessRegressor on a machine which has 8 cores (16 threads), although i do only use physical cores. So I wonder, is the GaussianProcessRegressor class in skl...
https://stackoverflow.com/questions/79232519/is-the-gaussianprocessregressor-estimator-in-scikit-learn-able-to-be-parallelize
machine-learning, scikit-learn, python-multiprocessing, gaussian-process
1,732,765,016
se_79237483
stackoverflow
MACHINE_LEARNING
Discrepancy between sklearn's r2_score() and PyTorch's MSELoss()?
Discrepancy between sklearn's r2_score() and PyTorch's MSELoss()? I am not sure if I am missing something very basic but I have started to notice some slight discrepancies between R2 scores returned by sklearn's r2_score() function and R2 scores calculated from PyTorch's MSELoss() (with the additional help of ...
https://stackoverflow.com/questions/79237483/discrepancy-between-sklearns-r2-score-and-pytorchs-mseloss
scikit-learn, pytorch
1,732,891,551
se_55632010
stackoverflow
MACHINE_LEARNING
Using scikit-learn's MLPClassifier in AdaBoostClassifier
Using scikit-learn's MLPClassifier in AdaBoostClassifier For a binary classification problem I want to use the MLPClassifier as the base estimator in the AdaBoostClassifier. However, this does not work because MLPClassifier does not implement sample_weight, which is required for AdaBoostClassifier (see here). Befo...
https://stackoverflow.com/questions/55632010/using-scikit-learns-mlpclassifier-in-adaboostclassifier
machine-learning, scikit-learn, neural-network, adaboost
1,554,984,049
se_68586561
stackoverflow
MACHINE_LEARNING
sklearn: multi-class problem and reporting sensitivity and specificity
sklearn: multi-class problem and reporting sensitivity and specificity I have a three-class problem and I'm able to report precision and recall for each class with the below code: from sklearn.metrics import classification_report print(classification_report(y_test, y_pred)) which gives me the precision and recall nic...
https://stackoverflow.com/questions/68586561/sklearn-multi-class-problem-and-reporting-sensitivity-and-specificity
python, scikit-learn, classification, supervised-learning
1,627,627,692
se_78699230
stackoverflow
MACHINE_LEARNING
How to save single Random Forest model with cross validation?
How to save single Random Forest model with cross validation? I am using 10 fold cross validation, trying to predict binary labels (Y) based on the embedding inputs (X). I want to save one of the models (perhaps the one with the highest ROC AUC). I'm not sure how to do it because the ROC AUCs are not stored and I don'...
https://stackoverflow.com/questions/78699230/how-to-save-single-random-forest-model-with-cross-validation
python, pandas, numpy, scikit-learn, cross-validation
1,719,954,145
se_69836915
stackoverflow
MACHINE_LEARNING
Sklearn built-in function for Hard margin SVM
Sklearn built-in function for Hard margin SVM I know that there is a built-in function for soft margin SVM as follows. from sklearn.svm import SVC clf = SVC(C=1, kernel = 'linear') clf.fit(X, y) But for Hard margin SVM, we need C=0, right? But the code report error ValueError: C <= 0 when I let C=0.
https://stackoverflow.com/questions/69836915/sklearn-built-in-function-for-hard-margin-svm
python, scikit-learn, svm
1,636,017,719
se_79210867
stackoverflow
MACHINE_LEARNING
Is there a way to load a saved SKLearn VectorStore using langchain?
Is there a way to load a saved SKLearn VectorStore using langchain? I created and saved a vectorstore using langchain_community.vectorstores SKLearnVectorStore and I can't load it. I created and saved vectorstore as below: from langchain_community.vectorstores import SKLearnVectorStore vectorstore = SKLearnVectorStor...
https://stackoverflow.com/questions/79210867/is-there-a-way-to-load-a-saved-sklearn-vectorstore-using-langchain
scikit-learn, langchain, rag, vectorstore
1,732,187,234
se_42178070
stackoverflow
MACHINE_LEARNING
Jupyter Notebook ImportError: No module named &#39;sklearn&#39;
Jupyter Notebook ImportError: No module named &#39;sklearn&#39; I am trying to run on my local machine. I get an error ImportError: No module named 'sklearn' only in jupyter notebook It works fine when I use python from the command line both with the carnd-term1 env activated and deactivated. I have installed sklea...
https://stackoverflow.com/questions/42178070/jupyter-notebook-importerror-no-module-named-sklearn
scikit-learn, jupyter-notebook, conda
1,486,829,322
se_77907033
stackoverflow
MACHINE_LEARNING
sklearn &quot;transform_output&quot; setting different in Flask application context v request context
sklearn &quot;transform_output&quot; setting different in Flask application context v request context I'm working on modifying a working Flask application I've been using to serve an ML model to now serve predictions from a new, updated model. The model is an sklearn pipeline object I've trained and serialized using t...
https://stackoverflow.com/questions/77907033/sklearn-transform-output-setting-different-in-flask-application-context-v-requ
machine-learning, flask, scikit-learn, pipeline, werkzeug
1,706,624,266
se_79208596
stackoverflow
MACHINE_LEARNING
Custom Scikit-learn Model Persistence
Custom Scikit-learn Model Persistence I know there are several out of the box methods of saving the model. However I want to save the model as a database blob. I've seen examples where people extract 'coefs' etc from the dict of the estimator but when I try this with RandomForrestRegressor (for example) it says there ...
https://stackoverflow.com/questions/79208596/custom-scikit-learn-model-persistence
scikit-learn, persistence
1,732,128,642
se_66956197
stackoverflow
MACHINE_LEARNING
VS Code: ModuleNotFoundError: No module named &#39;sklearn&#39;
VS Code: ModuleNotFoundError: No module named &#39;sklearn&#39; I am working in VS Code to run a Python script in conda environment named myenv where sklearn is already installed. However when I import it and run the script I get the following error: Traceback (most recent call last): File "d:\ML\Project\src\train....
https://stackoverflow.com/questions/66956197/vs-code-modulenotfounderror-no-module-named-sklearn
python, python-3.x, visual-studio-code, scikit-learn, pip
1,617,639,778
se_66154986
stackoverflow
MACHINE_LEARNING
Why am I getting 100% accuracy when using a Linear Regression model to predict stock prices?
Why am I getting 100% accuracy when using a Linear Regression model to predict stock prices? I'm trying to predict stock prices in python using a linear regression model. I split the data using train_test_split so from what I understand, my test data should not be in my training data so I do not understand why the mod...
https://stackoverflow.com/questions/66154986/why-am-i-getting-100-accuracy-when-using-a-linear-regression-model-to-predict-s
python, machine-learning, scikit-learn, linear-regression
1,613,047,243
se_12738827
stackoverflow
MACHINE_LEARNING
How can I call scikit-learn classifiers from Java?
How can I call scikit-learn classifiers from Java? I have a classifier that I trained using Python's scikit-learn. How can I use the classifier from a Java program? Can I use Jython? Is there some way to save the classifier in Python and load it in Java? Is there some other way to use it?
https://stackoverflow.com/questions/12738827/how-can-i-call-scikit-learn-classifiers-from-java
java, python, jython, scikit-learn
1,349,405,426
se_61882244
stackoverflow
MACHINE_LEARNING
Sk-learn GridSearchCV fits on full data
Sk-learn GridSearchCV fits on full data I used sklearn GridSearchCV to search # of topics using lda model. After fitting the model, the fitted model is saved in CV_model.best_estimator_. Based on sklearn docs, GridSearchCV has default option refit, default=True, which 'Refit an estimator using the best found parameter...
https://stackoverflow.com/questions/61882244/sk-learn-gridsearchcv-fits-on-full-data
machine-learning, scikit-learn, topic-modeling, grid-search
1,589,855,347
se_49408371
stackoverflow
MACHINE_LEARNING
When to use min-max-scalar and standard-scalar?
When to use min-max-scalar and standard-scalar? When should I use min-max-scaler and when Standard Scalar? I think it depends on the data. Are there any features of data to look out for to decide which preprocessing method to go for? I looked at the docs but can someone give me more insight into it?
https://stackoverflow.com/questions/49408371/when-to-use-min-max-scalar-and-standard-scalar
python-3.x, scikit-learn
1,521,640,793
se_75941142
stackoverflow
MACHINE_LEARNING
Speedup Sklearn model fitting
Speedup Sklearn model fitting I am profiling Sklearn model: clf = GridSearchCV(..., n_jobs=-1) %time clf.fit(X_train, y_train) ... CPU times: user 2min 35s, sys: 3.07 s, total: 2min 38s Wall time: 8min 40s Wall Time is significantly larger than CPU total time. Does it mean, that Sklearn is not fully utilizing CP...
https://stackoverflow.com/questions/75941142/speedup-sklearn-model-fitting
python, performance, scikit-learn, jupyter-notebook, thread-priority
1,680,707,514
se_59157093
stackoverflow
MACHINE_LEARNING
Download sklearn datasets behind a proxy
Download sklearn datasets behind a proxy I installed sklearn in my enviorment and running it now on jupyter notebook on windows. How can I avoid the error: URLError: urlopen error [Errno 11004] getaddrinfo failed I am running the following code: import sklearn import sklearn.ensemble import sklearn.metrics fro...
https://stackoverflow.com/questions/59157093/download-sklearn-datasets-behind-a-proxy
python, scikit-learn
1,575,375,911
se_79197656
stackoverflow
MACHINE_LEARNING
How to reduce the size of Numpy data type
How to reduce the size of Numpy data type I am using Python to do cosine similarity. similarity_matrix = cosine_similarity(tfidf_matrix) The problem is that I am getting this error MemoryError: Unable to allocate 44.8 GiB for an array with shape (6011226750,) and data type float64 I don't think I need float64 for th...
https://stackoverflow.com/questions/79197656/how-to-reduce-the-size-of-numpy-data-type
python, numpy, scikit-learn, cosine-similarity
1,731,861,709
se_64068419
stackoverflow
MACHINE_LEARNING
how to visualize the iris dataset on 2d plots for different combinations of features
how to visualize the iris dataset on 2d plots for different combinations of features I want to visualize the iris dataset in 2d with all six combinations (sepal width-sepal length) , (petal width-sepal length), (sepal length-petal width), (petal length-petal width) (petal length-sepal width) (sepal width-petal length)...
https://stackoverflow.com/questions/64068419/how-to-visualize-the-iris-dataset-on-2d-plots-for-different-combinations-of-feat
python, machine-learning, scikit-learn
1,601,053,230
se_79075564
stackoverflow
MACHINE_LEARNING
What is the best way to fit a quadratic polynomial to p-dimensional data and compute its gradient and Hessian matrix?
What is the best way to fit a quadratic polynomial to p-dimensional data and compute its gradient and Hessian matrix? I have been trying to use the scikit-learn library to solve this problem. Roughly: from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LinearRegression # Make or loa...
https://stackoverflow.com/questions/79075564/what-is-the-best-way-to-fit-a-quadratic-polynomial-to-p-dimensional-data-and-com
python, scikit-learn, linear-regression, polynomials, hessian-matrix
1,728,581,532
se_31948879
stackoverflow
MACHINE_LEARNING
Using explicit (predefined) validation set for grid search with sklearn
Using explicit (predefined) validation set for grid search with sklearn I have a dataset, which has previously been split into 3 sets: train, validation and test. These sets have to be used as given in order to compare the performance across different algorithms. I would now like to optimize the parameters of my SVM ...
https://stackoverflow.com/questions/31948879/using-explicit-predefined-validation-set-for-grid-search-with-sklearn
python, validation, scikit-learn, cross-validation
1,439,316,209
se_78554891
stackoverflow
MACHINE_LEARNING
How to fit a multiple observations to single Gaussian Process
How to fit a multiple observations to single Gaussian Process I am trying to fit multiple observations to a single Gaussian Process. I try to fit the data of two observations (Y) like this: import numpy as np from sklearn.gaussian_process import GaussianProcessRegressor from sklearn.gaussian_process.kernels import RBF...
https://stackoverflow.com/questions/78554891/how-to-fit-a-multiple-observations-to-single-gaussian-process
python, machine-learning, scikit-learn, regression, gaussian-process
1,717,071,370
se_71090431
stackoverflow
MACHINE_LEARNING
Python- How to import DecisionTree Classifier from sklearn.tree
Python- How to import DecisionTree Classifier from sklearn.tree May I know how to import DecisionTreeClassifier from sklearn.tree as there is an error shown: ModuleNotFoundError: No module named 'sklearn' Also, every time when I want to import functions like pandas, I need to pip install them which is time-consuming....
https://stackoverflow.com/questions/71090431/python-how-to-import-decisiontree-classifier-from-sklearn-tree
python, scikit-learn, decision-tree
1,644,656,777
se_79183884
stackoverflow
MACHINE_LEARNING
How to use Python to replicate Random Forest Regression prediction using decision paths?
How to use Python to replicate Random Forest Regression prediction using decision paths? I'm trying to test whether I've understood the way RandomForestRegressor produces forecast after a model's fitted. I used the California housing example to train a simple model and predict the first value in my test set. I then us...
https://stackoverflow.com/questions/79183884/how-to-use-python-to-replicate-random-forest-regression-prediction-using-decisio
machine-learning, scikit-learn, data-science, random-forest
1,731,484,553
se_79182452
stackoverflow
MACHINE_LEARNING
Ignore NaN to calculate mean_absolute_error
Ignore NaN to calculate mean_absolute_error I'm trying to calculate MAE (Mean absolute error). In my original DataFrame, I have 1826 rows and 3 columns. I'm using columns 2 and 3 to calculate MAE. But, in column 2, I have some NaN values. When I used: from sklearn.metrics import mean_absolute_error and selected these...
https://stackoverflow.com/questions/79182452/ignore-nan-to-calculate-mean-absolute-error
python, pandas, scikit-learn
1,731,439,210
se_79181092
stackoverflow
MACHINE_LEARNING
Efficient parallelization of silhouette score calculation
Efficient parallelization of silhouette score calculation I have a large dataset (2 million rows, 100 columns), and I need to perform clusterization. I used the elbow method to determine the optimal number of clusters. However, in order to get a more refined picture, I also need to calculate the silhouette scores for ...
https://stackoverflow.com/questions/79181092/efficient-parallelization-of-silhouette-score-calculation
python, scikit-learn, cluster-analysis, k-means, joblib
1,731,414,411
se_76812504
stackoverflow
MACHINE_LEARNING
AttributeError: &#39;RFECV&#39; object has no attribute &#39;grid_scores_&#39;
AttributeError: &#39;RFECV&#39; object has no attribute &#39;grid_scores_&#39; Problem I faced: Getting this error continuously AttributeError: 'RFECV' object has no attribute 'grid_scores_'. The code is given below: from sklearn.ensemble import RandomForestClassifier from sklearn.feature_selection import RFECV from s...
https://stackoverflow.com/questions/76812504/attributeerror-rfecv-object-has-no-attribute-grid-scores
python, scikit-learn, attributeerror, feature-selection
1,690,898,955
se_79167713
stackoverflow
MACHINE_LEARNING
How to create a scaler applying log transformation and MinMaxScaler in sklearn
How to create a scaler applying log transformation and MinMaxScaler in sklearn I want to apply log() to my DataFrame and MinMaxScaler() together. I want the output to be a pandas DataFrame() with indexes and columns from the original data. I want to use the parameters used to fit_transform() to inverse_transform() res...
https://stackoverflow.com/questions/79167713/how-to-create-a-scaler-applying-log-transformation-and-minmaxscaler-in-sklearn
python, pandas, scikit-learn, data-preprocessing
1,731,004,869
se_79176937
stackoverflow
MACHINE_LEARNING
Problem in installing and using scikit-learn in Python
Problem in installing and using scikit-learn in Python I want to run the following code in jupyter-notebook from sklearn.linear_model import SGDRegressor before that, I have used the following lines in windows cmd: python -m venv sklearn-env sklearn-env\Scripts\activate pip install -U scikit-learn But still when I ru...
https://stackoverflow.com/questions/79176937/problem-in-installing-and-using-scikit-learn-in-python
python, scikit-learn, jupyter-notebook, pip, python-venv
1,731,314,702
se_79176191
stackoverflow
MACHINE_LEARNING
Cannot convert dataframe column to a int64 data type
Cannot convert dataframe column to a int64 data type I have a problem. In my Pandas DataFrame, I have a column called 'job' column. I've created a simple and custom transformer that will map values in that column that corresponds to the type of job. The problem arises when after mapping the values and inspecting it, t...
https://stackoverflow.com/questions/79176191/cannot-convert-dataframe-column-to-a-int64-data-type
python, python-3.x, pandas, dataframe, scikit-learn
1,731,290,401
se_50013828
stackoverflow
MACHINE_LEARNING
ScikitLearn model giving &#39;LocalOutlierFactor&#39; object has no attribute &#39;predict&#39; Error
ScikitLearn model giving &#39;LocalOutlierFactor&#39; object has no attribute &#39;predict&#39; Error I'm new to machine learning world and I have built and trained a ml model using ScikitLearn library.It works perfectly well in the Jupyter notebook but when I deployed this model to Google Cloud ML and try to serve it...
https://stackoverflow.com/questions/50013828/scikitlearn-model-giving-localoutlierfactor-object-has-no-attribute-predict
python, scikit-learn, google-cloud-platform, google-cloud-ml
1,524,628,608
se_59435472
stackoverflow
MACHINE_LEARNING
Implementing Bag of Words in scikit-learn
Implementing Bag of Words in scikit-learn from sklearn.feature_extraction.text import CountVectorizer import pandas as pd headers = ['label', 'sms_message'] df = pd.read_csv ('spam.csv', names = headers) df ['label'] = df['label'].map({'ham': 0, 'spam': 1}) print (df.head(7)) print (df.shape) count_vector = CountVecto...
https://stackoverflow.com/questions/59435472/implementing-bag-of-words-in-scikit-learn
python, scikit-learn
1,576,924,957
se_42993550
stackoverflow
MACHINE_LEARNING
GridSearchCV - XGBoost - Early Stopping
GridSearchCV - XGBoost - Early Stopping i am trying to do hyperparemeter search with using scikit-learn's GridSearchCV on XGBoost. During gridsearch i'd like it to early stop, since it reduce search time drastically and (expecting to) have better results on my prediction/regression task. I am using XGBoost via its Sci...
https://stackoverflow.com/questions/42993550/gridsearchcv-xgboost-early-stopping
python-3.x, scikit-learn, regression, data-science, xgboost
1,490,339,703
se_78874263
stackoverflow
MACHINE_LEARNING
Error get_features_name_out in getting back the feature name
Error get_features_name_out in getting back the feature name I want to know the feature importance to my data, so I use permutation_importance. When I get the result, it seems the feature already decoded, and I want to know the name of my feauture using get_features_name_out. It turns an error 'StandardScaler' object ...
https://stackoverflow.com/questions/78874263/error-get-features-name-out-in-getting-back-the-feature-name
python, pandas, scikit-learn, data-science
1,723,710,687
se_79170289
stackoverflow
MACHINE_LEARNING
Columns are missing after imputing and creating dummy variables. How should I fix this?
Columns are missing after imputing and creating dummy variables. How should I fix this? In short: My columns are different between train set and test set after imputing. Code of making train, test dataset random_state_value = 0 #Define target X = data.drop(columns = 'income', axis=1) y = data['income'] #Split X_trai...
https://stackoverflow.com/questions/79170289/columns-are-missing-after-imputing-and-creating-dummy-variables-how-should-i-fi
python, machine-learning, scikit-learn
1,731,073,596
se_79169993
stackoverflow
MACHINE_LEARNING
How to get scikit-learn to ensure that all prediction outputs should sum to 100%?
How to get scikit-learn to ensure that all prediction outputs should sum to 100%? I have a 'MultiOutputRegressor' which is based on a 'LinearRegression' regressor. I am using it to predict three outputs per row of X_data (like a classifier) which represent the percentage likelihood of three outcomes. The regressor is ...
https://stackoverflow.com/questions/79169993/how-to-get-scikit-learn-to-ensure-that-all-prediction-outputs-should-sum-to-100
python, scikit-learn, output, linear-regression
1,731,067,972
se_70345909
stackoverflow
MACHINE_LEARNING
Implementing GridSearchCV and Pipelines to perform Hyperparameters Tuning for KNN Algorithm
Implementing GridSearchCV and Pipelines to perform Hyperparameters Tuning for KNN Algorithm I have been reading about perfroming Hyperparameters Tuning for KNN Algorthim, and understood that the best practice of implementing it is to make sure that for each fold, my dataset should be normalized and oversamplmed using ...
https://stackoverflow.com/questions/70345909/implementing-gridsearchcv-and-pipelines-to-perform-hyperparameters-tuning-for-kn
python, machine-learning, scikit-learn, gridsearchcv, rapids
1,639,470,986
se_79165974
stackoverflow
MACHINE_LEARNING
how do i set ‘random_state’ correctly so that my results are always the same?
how do i set ‘random_state’ correctly so that my results are always the same? If I have for example this snippet of code: knn = KNeighborsClassifier() grid_search_knn = GridSearchCV( estimator=knn, n_jobs=-1) Do I have to set it like this: knn = KNeighborsClassifier(random_state=42) grid_search_knn = GridSea...
https://stackoverflow.com/questions/79165974/how-do-i-set-random-state-correctly-so-that-my-results-are-always-the-same
python, machine-learning, scikit-learn
1,730,974,676
se_56549270
stackoverflow
MACHINE_LEARNING
ImportError: cannot import name &#39;MultiOutputMixin&#39; from &#39;sklearn.base&#39;
ImportError: cannot import name &#39;MultiOutputMixin&#39; from &#39;sklearn.base&#39; I want to do a linear regression with scikit-learn. When I try to import the linear model package the error message from the title appears. I tried to follow the solution from a similar problem. The suggestion is basically to just g...
https://stackoverflow.com/questions/56549270/importerror-cannot-import-name-multioutputmixin-from-sklearn-base
python, scikit-learn
1,560,275,566
se_57629912
stackoverflow
MACHINE_LEARNING
How to do cross validation and grid search if I have a customized ensemble model in python pipeline
How to do cross validation and grid search if I have a customized ensemble model in python pipeline I am building a customized ensemble model and would like to do cross validation and grid search in python using pipeline. How can I do it? I have a data set contains web content. What I want to do is Split the content ...
https://stackoverflow.com/questions/57629912/how-to-do-cross-validation-and-grid-search-if-i-have-a-customized-ensemble-model
python, scikit-learn, cross-validation, grid-search, ensemble-learning
1,566,577,260
se_73488178
stackoverflow
MACHINE_LEARNING
Pipeline for more than 2 classifiers
Pipeline for more than 2 classifiers I am trying to build an ensemble using Knn and random forest classifiers. steps = [('scaler', StandardScaler()), ('regressor', VotingClassifier(estimators=[ ('knn', KNeighborsClassifier()), ('clf', RandomForestClassifier())]))] pipeline = Pipeline(steps) parameters ...
https://stackoverflow.com/questions/73488178/pipeline-for-more-than-2-classifiers
python-3.x, scikit-learn, random-forest, knn, scikit-learn-pipeline
1,661,433,279
se_79162743
stackoverflow
MACHINE_LEARNING
scikit-learn classifiers and regressors caching training data?
scikit-learn classifiers and regressors caching training data? I have some 22,000 rows of training data. I use train_test_split to get training and testing data. I run fitting and then get some idea of how well fitting went using various methods or estimation. I want to have the fitted model go back over the 22,000 ro...
https://stackoverflow.com/questions/79162743/scikit-learn-classifiers-and-regressors-caching-training-data
python, scikit-learn, model-fitting
1,730,898,765
se_56420730
stackoverflow
MACHINE_LEARNING
Cannot Reproduce the Splitting of Train and Test using sklearn
Cannot Reproduce the Splitting of Train and Test using sklearn I am using Jupyter Notebook version 5.6.0 through the Anaconda Navigator. I am trying to split my dataset to Train and Test but whenever I shutdown and reopen my notebook and rerun the code, it creates a different training and test set. The random_state wo...
https://stackoverflow.com/questions/56420730/cannot-reproduce-the-splitting-of-train-and-test-using-sklearn
python, scikit-learn, split
1,559,531,697
se_53648699
stackoverflow
MACHINE_LEARNING
Scikit train_test_split by an index
Scikit train_test_split by an index I have a pandas dataframe indexed by date. Let's assume it from Jan-1 to Jan-30. I want to split this dataset into X_train, X_test, y_train, y_test but I don't want to mix the dates so I want the train and test samples to be divided by a certain date (or index). I'm trying X_train, ...
https://stackoverflow.com/questions/53648699/scikit-train-test-split-by-an-index
python, pandas, scikit-learn, classification
1,544,090,211
se_79151805
stackoverflow
MACHINE_LEARNING
Why is my data not getting properly concatenated?
Why is my data not getting properly concatenated? I split the data using train_test_split after preprocessing: from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test= train_test_split(X,y,test_size=0.2,random_state=42) Then did robust scaling separately for the numerical columns in test an...
https://stackoverflow.com/questions/79151805/why-is-my-data-not-getting-properly-concatenated
pandas, dataframe, scikit-learn, concatenation, scaling
1,730,592,385
se_79154123
stackoverflow
MACHINE_LEARNING
How to apply the exported sklearn trained tree to the test data
How to apply the exported sklearn trained tree to the test data from sklearn.tree import DecisionTreeRegressor, export_text cols_X = ['f1', 'f2'] df_train = pd.DataFrame([[1, 3, 4], [2, 5, 1], [7, 8, 7]], columns=['f1', 'f2', 'label']) df_test = pd.DataFrame([[2, 5], [3, 1]], columns=cols_X) tree = DecisionTreeRegre...
https://stackoverflow.com/questions/79154123/how-to-apply-the-exported-sklearn-trained-tree-to-the-test-data
scikit-learn, decision-tree
1,730,690,694
se_14863125
stackoverflow
MACHINE_LEARNING
sklearn logistic regression with unbalanced classes
sklearn logistic regression with unbalanced classes I'm solving a classification problem with sklearn's logistic regression in python. My problem is a general/generic one. I have a dataset with two classes/result (positive/negative or 1/0), but the set is highly unbalanced. There are ~5% positives and ~95% negative...
https://stackoverflow.com/questions/14863125/sklearn-logistic-regression-with-unbalanced-classes
python, scikit-learn, classification
1,360,789,584
se_50639464
stackoverflow
MACHINE_LEARNING
Explained variance from scikit-learn MDS
Explained variance from scikit-learn MDS Is there a way to calculate the explained variance (eigenvalues) from scikit learn's MDS? I've seen this thread, but I think scikit learn's MDS is a "non-classical" form of MDS, so I'm guessing it wouldn't work? Is there a way to compute the explained variance from running scik...
https://stackoverflow.com/questions/50639464/explained-variance-from-scikit-learn-mds
python, scikit-learn
1,527,842,770
se_79134937
stackoverflow
MACHINE_LEARNING
How to apply multiple estimator on multiple number of features to select the combination with highest f1 score?
How to apply multiple estimator on multiple number of features to select the combination with highest f1 score? I would like to run recursive feature elimination with multiple estimator algorithms on multiple number of features and keep the highest f1 score combination on the test data. Instead of reviewing the result...
https://stackoverflow.com/questions/79134937/how-to-apply-multiple-estimator-on-multiple-number-of-features-to-select-the-com
python, machine-learning, scikit-learn, classification, rfe
1,730,145,440
se_79095328
stackoverflow
MACHINE_LEARNING
Numpy dependency error when using sklearn-1.5:10 environment to deploy Azure ML model
Numpy dependency error when using sklearn-1.5:10 environment to deploy Azure ML model I'm using the sklearn-1.5(version 10) environment to deploy a ML model which uses sklearn.ensemble._forest.RandomForestClassifier. When deploying the endpoint I keep running into dependency issues with numpy. I specifically get the f...
https://stackoverflow.com/questions/79095328/numpy-dependency-error-when-using-sklearn-1-510-environment-to-deploy-azure-ml
azure, scikit-learn, deployment, endpoint, ml-studio
1,729,102,497
se_79156832
stackoverflow
MACHINE_LEARNING
Weird info ordering in scikit-learn trees
Weird info ordering in scikit-learn trees When plotting scikit-learn trees (on iris data as an example), as in the below code: from sklearn.datasets import load_iris from sklearn import tree iris = load_iris() X, y = iris.data, iris.target clf = tree.DecisionTreeClassifier() clf = clf.fit(X, y) tree.plot_tree(clf) e...
https://stackoverflow.com/questions/79156832/weird-info-ordering-in-scikit-learn-trees
scikit-learn, decision-tree
1,730,750,344
se_77528037
stackoverflow
MACHINE_LEARNING
RuntimeError: Failed to import transformers.models.clip.processing_clip because of the following error
RuntimeError: Failed to import transformers.models.clip.processing_clip because of the following error RuntimeError: Failed to import transformers.models.clip.processing_clip because of the following error (look up to see its traceback): [Errno 2] No such file or directory: 'C:\\Users\\xxx\\AppData\\Local\\Temp\\_MEI1...
https://stackoverflow.com/questions/77528037/runtimeerror-failed-to-import-transformers-models-clip-processing-clip-because
python, scikit-learn, pyinstaller, sentence-transformers
1,700,638,150
se_70009445
stackoverflow
MACHINE_LEARNING
disable internal scikit input validation checks
disable internal scikit input validation checks Under the hood Scikit-Learn does a lot of input validation checks defined here such as checking for (X,y) shapes, expected scalars/arrays, ensuring estimator is already fitted, etc. When designing models these checks are extremely useful to catch early bugs, but these be...
https://stackoverflow.com/questions/70009445/disable-internal-scikit-input-validation-checks
performance, validation, scikit-learn
1,637,172,307
se_73193085
stackoverflow
MACHINE_LEARNING
k-NN GridSearchCV taking extremely long time to execute
k-NN GridSearchCV taking extremely long time to execute I am attempting to use sklearn to train a KNN model on the MNIST classification task. When I try to tune my parameters using either sklearn's GridSearchCV or RandomisedSearchCV classes, my code is taking an extremely long time to execute. As an experiment, I crea...
https://stackoverflow.com/questions/73193085/k-nn-gridsearchcv-taking-extremely-long-time-to-execute
python, scikit-learn, cross-validation, knn, gridsearchcv
1,659,354,006
se_67428836
stackoverflow
MACHINE_LEARNING
yellowbrick implementation error - AttributeError: &#39;LogisticRegression&#39; object has no attribute &#39;fig&#39;
yellowbrick implementation error - AttributeError: &#39;LogisticRegression&#39; object has no attribute &#39;fig&#39; I am a new user for yellowbrick. While implementing a sklearn LogisticRegression API in yellowbrick ClassificationReport, I found some unusual error. I have tried many syntaxes as suggested by yellowbr...
https://stackoverflow.com/questions/67428836/yellowbrick-implementation-error-attributeerror-logisticregression-object-h
python, scikit-learn, classification, yellowbrick
1,620,360,085
se_79114762
stackoverflow
MACHINE_LEARNING
How do I onehotencode a single column in a dataframe?
How do I onehotencode a single column in a dataframe? I have a dataframe called "vehicles" with 8 columns. 7 are numerical but the column named 'Car_name' which is index 1 in the dataframe and is categorical. i need to encode it i tried this code and wont work ohe = OneHotEncoding(categorical_features = [1]) vehicl...
https://stackoverflow.com/questions/79114762/how-do-i-onehotencode-a-single-column-in-a-dataframe
python, machine-learning, scikit-learn, one-hot-encoding
1,729,609,924
se_46599534
stackoverflow
MACHINE_LEARNING
How to find the best value of k For the k-NN?
How to find the best value of k For the k-NN? I have 4 different datasets and Each dataset contains two-dimensional samples that belong to one of the two classes: 1 or 2. The class labels (1 or 2) for each sample are located in the last column. The first and second columns contain the coordinates of the 2D points that...
https://stackoverflow.com/questions/46599534/how-to-find-the-best-value-of-k-for-the-k-nn
machine-learning, scikit-learn, classification, knn
1,507,271,182
se_68475534
stackoverflow
MACHINE_LEARNING
SVM model predicts instances with probability scores greater than 0.1(default threshold 0.5) as positives
SVM model predicts instances with probability scores greater than 0.1(default threshold 0.5) as positives I'm working on a binary classification problem. I had this situation that I used the logistic regression and support vector machine model imported from sklearn. These two models were fit with the same , imbalanced...
https://stackoverflow.com/questions/68475534/svm-model-predicts-instances-with-probability-scores-greater-than-0-1default-th
python, machine-learning, scikit-learn, svm, prediction
1,626,896,201
se_79137908
stackoverflow
MACHINE_LEARNING
Error when runing mlflow with sklearn model
Error when runing mlflow with sklearn model I'm training a RandomForestRegressor and keeping track of it using mlflow Using the following code works perfectly only when n_estimators is lower than 90 The code: import mlflow import mlflow.sklearn from mlflow.models import infer_signature from sklearn.ensemble import Ran...
https://stackoverflow.com/questions/79137908/error-when-runing-mlflow-with-sklearn-model
python, scikit-learn, mlflow
1,730,215,845
se_78651234
stackoverflow
MACHINE_LEARNING
How to implement pipeline into machine learning model
How to implement pipeline into machine learning model I would like to implement Onehot encoding and label encoding to my dataset using Pipeline into my random forest model. I have created a function that utilize pipeline from scikit learn together with OneHotEncoder and LabelEncoder. def create_pipeline(self, train_fe...
https://stackoverflow.com/questions/78651234/how-to-implement-pipeline-into-machine-learning-model
python, python-3.x, scikit-learn, pipeline, scikit-learn-pipeline
1,718,958,591
se_44041347
stackoverflow
MACHINE_LEARNING
sklearn: Get Distance from Point to Nearest Cluster
sklearn: Get Distance from Point to Nearest Cluster I'm using clustering algorithms like DBSCAN. It returns a 'cluster' called -1 which are points that are not part of any cluster. For these points I want to determine the distance from it to the nearest cluster to get something like a metric for how abnormal this poi...
https://stackoverflow.com/questions/44041347/sklearn-get-distance-from-point-to-nearest-cluster
python, machine-learning, scikit-learn, cluster-analysis, data-mining
1,495,092,696
se_58896645
stackoverflow
MACHINE_LEARNING
MNIST dataset with Sklearn
MNIST dataset with Sklearn I’m training linear model on MNIST dataset, but I wanted to train only on one digit that is 4. How do I choose my X_test,X_train, y_test, y_train?
https://stackoverflow.com/questions/58896645/mnist-dataset-with-sklearn
python, scikit-learn, mnist
1,573,952,929
se_65282827
stackoverflow
MACHINE_LEARNING
How to make predictions with scikit&#39;s Surprise?
How to make predictions with scikit&#39;s Surprise? I'm having some trouble understanding the Surprise workflow. I have a file for training (which I seek to split into training and validation), and a file for testing data. I'm having trouble understanding the difference between a Surprise Dataset and Trainset # Import...
https://stackoverflow.com/questions/65282827/how-to-make-predictions-with-scikits-surprise
python, machine-learning, scikit-learn, recommendation-engine, collaborative-filtering
1,607,912,384
se_31421413
stackoverflow
MACHINE_LEARNING
How to compute precision, recall, accuracy and f1-score for the multiclass case with scikit learn?
How to compute precision, recall, accuracy and f1-score for the multiclass case with scikit learn? I'm working in a sentiment analysis problem the data looks like this: label instances 5 1190 4 838 3 239 1 204 2 127 So my data is unbalanced since 1190 instances are labeled with ...
https://stackoverflow.com/questions/31421413/how-to-compute-precision-recall-accuracy-and-f1-score-for-the-multiclass-case
python, machine-learning, scikit-learn, nlp
1,436,933,856
se_66376105
stackoverflow
MACHINE_LEARNING
How to perform standardization and normalization on features from different feature engineering process?
How to perform standardization and normalization on features from different feature engineering process? I'm working with a dataset where each sample contains both numeric and text data. Therefore multiple methods are employed to build the training feature matrix from the dataset. For each sample in the dataset, I con...
https://stackoverflow.com/questions/66376105/how-to-perform-standardization-and-normalization-on-features-from-different-feat
python, machine-learning, scikit-learn, data-science
1,614,285,530
se_62520099
stackoverflow
MACHINE_LEARNING
Getting error AttributeError: &#39;bool&#39; object has no attribute &#39;transpose&#39; when attempting to fit machine learning model
Getting error AttributeError: &#39;bool&#39; object has no attribute &#39;transpose&#39; when attempting to fit machine learning model I am trying to create a machine learning model to predict who would survive on the Titanic. Everytime I try to fit my model, I get this error : coordinates = np.where(mask.transpos...
https://stackoverflow.com/questions/62520099/getting-error-attributeerror-bool-object-has-no-attribute-transpose-when-at
python, pandas, machine-learning, scikit-learn, model
1,592,846,671
se_55786860
stackoverflow
MACHINE_LEARNING
How is the hidden layer size determined for MLPRegressor in SciKitLearn?
How is the hidden layer size determined for MLPRegressor in SciKitLearn? Lets say I'm creating a neural net using the following code: from sklearn.neural_network import MLPRegressor model = MLPRegressor( hidden_layer_sizes=(100,), activation='identity' ) model.fit(X_train, y_train) For the hidden_layer_sizes, ...
https://stackoverflow.com/questions/55786860/how-is-the-hidden-layer-size-determined-for-mlpregressor-in-scikitlearn
python, machine-learning, scikit-learn, neural-network
1,555,881,701
se_79124570
stackoverflow
MACHINE_LEARNING
How can I install scikit-learn from source using my locally modified clone
How can I install scikit-learn from source using my locally modified clone I have made modifications to the scikit-learn codebase that I want to test locally, but when I run pytest, I get the error "scikit-learn is not built correctly". So I try to build it by following the developer instructions, by using this $ pip ...
https://stackoverflow.com/questions/79124570/how-can-i-install-scikit-learn-from-source-using-my-locally-modified-clone
python, visual-c++, scikit-learn, pypi
1,729,839,102
se_45758280
stackoverflow
MACHINE_LEARNING
Fast ICA using scikit learn- reconstruction error analysis
Fast ICA using scikit learn- reconstruction error analysis I am trying to use fastICA procedure in scikitLearn. For validation purposes I tried to understand the difference between PCA and ICA based signal reconstruction. The original number of observed signals are 6 and I tried to use 3 reconstruction independent c...
https://stackoverflow.com/questions/45758280/fast-ica-using-scikit-learn-reconstruction-error-analysis
machine-learning, scikit-learn, pca, dimensionality-reduction
1,503,064,097
se_23045318
stackoverflow
MACHINE_LEARNING
grid search over multiple classifiers
grid search over multiple classifiers Is there a better inbuilt way to do grid search and test multiple models in a single pipeline? Of course the parameters of the models would be different, which made is complicated for me to figure this out. Here is what I did: from sklearn.pipeline import Pipeline from sklearn.e...
https://stackoverflow.com/questions/23045318/grid-search-over-multiple-classifiers
python, scikit-learn
1,397,406,977
se_78521298
stackoverflow
MACHINE_LEARNING
circumvent 250mb layer limit
circumvent 250mb layer limit I've a python serverless project that relies on scikit-learn, pandas, numpy and sqlachemy. Combined size of these package is around 350MB which is 100MB more than allowed layer size. Is there any way to use serverless lambdas and provide these packages runtime? is there a way to optimize p...
https://stackoverflow.com/questions/78521298/circumvent-250mb-layer-limit
amazon-web-services, numpy, scikit-learn, pip, aws-serverless
1,716,445,814
se_20841167
stackoverflow
MACHINE_LEARNING
How to predict time series in scikit-learn?
How to predict time series in scikit-learn? Scikit-learn utilizes a very convenient approach based on fit and predict methods. I have time-series data in the format suited for fit and predict. For example I have the following Xs: [[1.0, 2.3, 4.5], [6.7, 2.7, 1.2], ..., [3.2, 4.7, 1.1]] and the corresponding ys: [...
https://stackoverflow.com/questions/20841167/how-to-predict-time-series-in-scikit-learn
python, machine-learning, time-series, scikit-learn
1,388,412,393
se_31379845
stackoverflow
MACHINE_LEARNING
Forecasting with time series in python
Forecasting with time series in python I want to predict the next values of a variable Y (c_start) when X (day) represent the time. As you can see in the picture, i have values for the attribute "c_start" and I would like to predict the next "c_start" values for the next 7 days(for example). May someone help me?
https://stackoverflow.com/questions/31379845/forecasting-with-time-series-in-python
python, pandas, scikit-learn, time-series
1,436,779,996
se_59843700
stackoverflow
MACHINE_LEARNING
Train machine learning model with scikit learn for time-series prediction
Train machine learning model with scikit learn for time-series prediction I need to train a model with scikit-learn to predict possible time for less people in a room. Here is how my dataset looks like: Time PeopleCount --------------------------------------------- 2019-12-29 12:40:10 ...
https://stackoverflow.com/questions/59843700/train-machine-learning-model-with-scikit-learn-for-time-series-prediction
python, machine-learning, scikit-learn
1,579,618,369
se_37556600
stackoverflow
MACHINE_LEARNING
Advice on how to predict future time series data
Advice on how to predict future time series data I have time series data for different countries and factors, e.g. birth rate for "Afghanistan" for years from 1972 up until 2007 (source). Goal: Predict e.g. birth rate for 2008 and 2012 I am familiar with linear regressions, but need some help on how to work with time ...
https://stackoverflow.com/questions/37556600/advice-on-how-to-predict-future-time-series-data
python, machine-learning, scikit-learn, time-series
1,464,733,321
se_30346605
stackoverflow
MACHINE_LEARNING
Time series forecasting with scikit learn
Time series forecasting with scikit learn I am trying to set-up a python code for forecasting a time-series, using the SVM model of scikit-learn. My data contains X values at 30 minute interval for the last 24 hours, and I need to predict y for the next timestamp. Here's what I have set up - SVR(kernel='linear', C=1e3...
https://stackoverflow.com/questions/30346605/time-series-forecasting-with-scikit-learn
python, scikit-learn, time-series, svm, forecasting
1,432,116,575
se_66538197
stackoverflow
MACHINE_LEARNING
Precision calculation warning when using GridSearchCV for Logistic Regression
Precision calculation warning when using GridSearchCV for Logistic Regression I am trying to run GridSearchCV with the LogisticRegression estimator and record the model accuracy, precision, recall, f1 metrics. However, I get the following error on the precision metric: Precision is ill-defined and being set to 0.0 due...
https://stackoverflow.com/questions/66538197/precision-calculation-warning-when-using-gridsearchcv-for-logistic-regression
python, scikit-learn, precision, logistic-regression, gridsearchcv
1,615,242,810
se_77396735
stackoverflow
MACHINE_LEARNING
How to calculate the values at each node in a scikit-learn GradientBoostingRegressor?
How to calculate the values at each node in a scikit-learn GradientBoostingRegressor? I am trying to manually calculate the values shown at each node of each tree of an ensemble returned by a GradientBoostingRegressor. So here is how I train the model: import numpy as np import matplotlib.pyplot as plt import pandas a...
https://stackoverflow.com/questions/77396735/how-to-calculate-the-values-at-each-node-in-a-scikit-learn-gradientboostingregre
scikit-learn, gradient-descent, ensemble-learning
1,698,762,213
se_79118016
stackoverflow
MACHINE_LEARNING
How to preserve data types when working with pandas and sklearn transformers?
How to preserve data types when working with pandas and sklearn transformers? While working with a large sklearn Pipeline (fit using a DataFrame) I ran into an error that lead back to a wrong data type of my input. The problem occurred on an a single observation coming from an API that is supposed to interface the mod...
https://stackoverflow.com/questions/79118016/how-to-preserve-data-types-when-working-with-pandas-and-sklearn-transformers
python, pandas, scikit-learn
1,729,688,488
se_54899647
stackoverflow
MACHINE_LEARNING
what is the difference between transformer and estimator in sklearn?
what is the difference between transformer and estimator in sklearn? I saw both transformer and estimator were mentioned in the sklearn documentation. Is there any difference between these two words?
https://stackoverflow.com/questions/54899647/what-is-the-difference-between-transformer-and-estimator-in-sklearn
scikit-learn
1,551,250,326
se_79111896
stackoverflow
MACHINE_LEARNING
Inconsistent numbers of samples error in multi-class / multi-label machine learning model
Inconsistent numbers of samples error in multi-class / multi-label machine learning model I have a OneVsOne model running fine with textual feature and target fields. To progress to a multi-class model (i.e. with multiple textual feature fields), I believe OneVsRest with Logistic Regression is suitable. However, when ...
https://stackoverflow.com/questions/79111896/inconsistent-numbers-of-samples-error-in-multi-class-multi-label-machine-learn
pandas, scikit-learn, sampling, multilabel-classification, multiclass-classification
1,729,548,914
se_55981273
stackoverflow
MACHINE_LEARNING
ZeroDivisionError when using sklearn&#39;s BaggingClassifier with GridSearchCV
ZeroDivisionError when using sklearn&#39;s BaggingClassifier with GridSearchCV I'm trying to improve a perfectly working Bernoulli Naive Bayes model with bagging. But when I try to cross-validate the BaggingClassifier, I get a very unexpected ZeroDivisionError coming from parallel.py. I've tried to change all the para...
https://stackoverflow.com/questions/55981273/zerodivisionerror-when-using-sklearns-baggingclassifier-with-gridsearchcv
python, scikit-learn, divide-by-zero
1,556,962,886
se_61998081
stackoverflow
MACHINE_LEARNING
K-Means clustering Hyperparameter Tuning
K-Means clustering Hyperparameter Tuning I am trying to perform hyperparameter tuning for Spatio-Temporal K-Means clustering by using it in a pipeline with a Decision Tree classifier. The idea is to use K-Means clustering algorithm to generate cluster-distance space matrix and clustered labels which will be then passe...
https://stackoverflow.com/questions/61998081/k-means-clustering-hyperparameter-tuning
python-3.x, machine-learning, scikit-learn, k-means
1,590,393,286
se_52771440
stackoverflow
MACHINE_LEARNING
GridSearchCV on a working pipeline returns ValueError
GridSearchCV on a working pipeline returns ValueError I am using GridSearchCV in order to find the best parameters for my pipeline. My pipeline seems to work well as I can apply: pipeline.fit(X_train, y_train) preds = pipeline.predict(X_test) And I get a decent result. But GridSearchCV obviously doesn't like somethin...
https://stackoverflow.com/questions/52771440/gridsearchcv-on-a-working-pipeline-returns-valueerror
python, pandas, scikit-learn, scikit-learn-pipeline
1,539,312,169
se_69082803
stackoverflow
MACHINE_LEARNING
Found input variables with inconsistent number of samples when I processed &quot;titanic&quot; dataset in kaggle
Found input variables with inconsistent number of samples when I processed &quot;titanic&quot; dataset in kaggle I did a toy kaggle "Titanic" dataset training and followed the instruction of a linkedin video course named" Applied Machine Learning: Algorithms" when I typed the following codes: the error occured: lr = L...
https://stackoverflow.com/questions/69082803/found-input-variables-with-inconsistent-number-of-samples-when-i-processed-tita
scikit-learn, gridsearchcv
1,630,992,467
se_67572787
stackoverflow
MACHINE_LEARNING
AttributeError and TypeError using CustomTransformers
AttributeError and TypeError using CustomTransformers I am building a model using customized transformers (KeyError: "None of [Index([('A','B','C')] , dtype='object')] are in the [columns]). When I run the below code, I get an error because of .fit: ---------------------------------------------------------------------...
https://stackoverflow.com/questions/67572787/attributeerror-and-typeerror-using-customtransformers
python, scikit-learn, scikit-learn-pipeline
1,621,265,675
se_78440449
stackoverflow
MACHINE_LEARNING
&#39;Pipeline&#39; object has no attribute &#39;_check_fit_params&#39;
&#39;Pipeline&#39; object has no attribute &#39;_check_fit_params&#39; from imblearn.over_sampling import SMOTE from imblearn.under_sampling import RandomUnderSampler from imblearn.pipeline import Pipeline # Define features and target X = df.drop('infected', axis=1) y = df['infected'] # Split the data into training ...
https://stackoverflow.com/questions/78440449/pipeline-object-has-no-attribute-check-fit-params
python, machine-learning, scikit-learn, imblearn
1,715,062,354
se_79092031
stackoverflow
MACHINE_LEARNING
Python Regime Labeling Using Explicit Threshold for Increase/Decrease from peak to trough
Python Regime Labeling Using Explicit Threshold for Increase/Decrease from peak to trough I am trying to find the longest stretches of time in a time series where the value from start to end increases by at least a certain threshold without any declines in the interim by at least that threshold. Think of the time seri...
https://stackoverflow.com/questions/79092031/python-regime-labeling-using-explicit-threshold-for-increase-decrease-from-peak
python, scikit-learn, scipy, time-series
1,729,035,059