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_79109487
stackoverflow
MACHINE_LEARNING
How to check whether an sklearn estimator is a scaler?
How to check whether an sklearn estimator is a scaler? I'm writing a function that needs to determine whether an object passed to it is an imputer (can check with isinstance(obj, _BaseImputer)), a scaler, or something else. While all imputers have a common base class that identifies them as imputers, scalers do not. I...
https://stackoverflow.com/questions/79109487/how-to-check-whether-an-sklearn-estimator-is-a-scaler
python, scikit-learn, isinstance
1,729,504,030
se_63922690
stackoverflow
MACHINE_LEARNING
Decision tree Regressor model get max_depth value of the model with highest accuracy
Decision tree Regressor model get max_depth value of the model with highest accuracy Build a Decision tree Regressor model from X_train set and Y_train labels, with default parameters. Name the model as dt_reg. Evaluate the model accuracy on the training data set and print its score. Evaluate the model accuracy on the...
https://stackoverflow.com/questions/63922690/decision-tree-regressor-model-get-max-depth-value-of-the-model-with-highest-accu
python, machine-learning, scikit-learn, decision-tree
1,600,268,000
se_70862659
stackoverflow
MACHINE_LEARNING
SVR/SVM output predictions are very similar to each other but far from true value
SVR/SVM output predictions are very similar to each other but far from true value The main idea is to predict 2 target output, based on input features. the input features are already scaled using Standardscaler() from sklearn. size of X_train is (190 x 6), Y_train = (190 x 2). X_test is (20 x 6), Y_test = (20x2) lin...
https://stackoverflow.com/questions/70862659/svr-svm-output-predictions-are-very-similar-to-each-other-but-far-from-true-valu
python, scikit-learn, linear-regression, svm, gridsearchcv
1,643,196,163
se_79107349
stackoverflow
MACHINE_LEARNING
ValueError: could not convert string to float: '?' while working with MSE
ValueError: could not convert string to float: '?' while working with MSE I am using the auto-mpg dataset . I am giving the link of the dataset below: https://www.kaggle.com/datasets/uciml/autompg-dataset I am giving the code below: df = pd.read_csv('data/auto-mpg.csv') df.head() df = df.drop('car name', axis...
https://stackoverflow.com/questions/79107349/valueerror-could-not-convert-string-to-float-while-working-with-mse
python, machine-learning, scikit-learn, decision-tree
1,729,435,784
se_34847210
stackoverflow
MACHINE_LEARNING
What exactly does 'use_idf' do when creating a TfidfTransformer in sklearn?
What exactly does &#39;use_idf&#39; do when creating a TfidfTransformer in sklearn? I am using the TfidfTransformer from the sklearn package in Python 2.7. As I was getting comfortable with the arguments, I became a bit confused about use_idf, as in: TfidfVectorizer(use_idf=False).fit_transform(<corpus goes here>)...
https://stackoverflow.com/questions/34847210/what-exactly-does-use-idf-do-when-creating-a-tfidftransformer-in-sklearn
python, scikit-learn, tf-idf
1,453,090,296
se_79095468
stackoverflow
MACHINE_LEARNING
How to pass parameters to this sklearn Cox model in a Pipeline?
How to pass parameters to this sklearn Cox model in a Pipeline? If I run the following Python code it works well: target = 'churn' tranOH = ColumnTransformer([ ('one', OneHotEncoder(drop='first', dtype='int'), make_column_selector(dtype_include='category', pattern=f"^(?!{target}).*") ) ], remainder='passthrough') ...
https://stackoverflow.com/questions/79095468/how-to-pass-parameters-to-this-sklearn-cox-model-in-a-pipeline
python, scikit-learn, cox-regression, scikit-learn-pipeline
1,729,105,098
se_33204500
stackoverflow
MACHINE_LEARNING
Pandas - automatically detect date columns **at run time**
Pandas - automatically detect date columns **at run time** I was wondering if pandas is capable of automatically detecting which columns are datetime objects and read those columns in as dates instead of strings? I am looking at the api and related stack overflow posts but I can't seem to figure it out. This is a b...
https://stackoverflow.com/questions/33204500/pandas-automatically-detect-date-columns-at-run-time
python, pandas, scikit-learn
1,445,211,521
se_79086293
stackoverflow
MACHINE_LEARNING
Gaussian process binary classification: why is the variance with GPy much smaller than with scikit-learn?
Gaussian process binary classification: why is the variance with GPy much smaller than with scikit-learn? I'm learning about binary classification with Gaussian Processes and I am comparing GPy with scikit-learn on a toy 1D problem inspired by Martin Krasser's blog post. Both implementations (GPy and scikit-learn) see...
https://stackoverflow.com/questions/79086293/gaussian-process-binary-classification-why-is-the-variance-with-gpy-much-smalle
python, machine-learning, scikit-learn, gaussian-process, gpy
1,728,911,416
se_54267745
stackoverflow
MACHINE_LEARNING
Implementing custom loss function in scikit learn
Implementing custom loss function in scikit learn I want to implement a custom loss function in scikit learn. I use the following code snippet: def my_custom_loss_func(y_true,y_pred): diff3=max((abs(y_true-y_pred))*y_true) return diff3 score=make_scorer(my_custom_loss_func,greater_ is_better=False) clf=RandomF...
https://stackoverflow.com/questions/54267745/implementing-custom-loss-function-in-scikit-learn
python, machine-learning, scikit-learn, data-science, gridsearchcv
1,547,905,667
se_78636029
stackoverflow
MACHINE_LEARNING
Plot a decision tree from HistGratientBoostingClassifier
Plot a decision tree from HistGratientBoostingClassifier I have a HistGradientBoostingClassifier model and I want to plot one or more of its decision trees, nevertheless I can't manage to find a native function to do it, I can access the Tree predictor objects and thus it's nodes, but in order to plot it into the skle...
https://stackoverflow.com/questions/78636029/plot-a-decision-tree-from-histgratientboostingclassifier
python, machine-learning, scikit-learn, classification, decision-tree
1,718,695,594
se_34649969
stackoverflow
MACHINE_LEARNING
How to find the features names of the coefficients using scikit linear regression?
How to find the features names of the coefficients using scikit linear regression? I use scikit linear regression and if I change the order of the features, the coef are still printed in the same order, hence I would like to know the mapping of the feature with the coeff. #training the model model_1_features = ['sqft_...
https://stackoverflow.com/questions/34649969/how-to-find-the-features-names-of-the-coefficients-using-scikit-linear-regressio
python, machine-learning, scikit-learn, linear-regression
1,452,153,484
se_79093729
stackoverflow
MACHINE_LEARNING
Why does mean prediction go flat after more data points are added in Gaussian Process Regressor
Why does mean prediction go flat after more data points are added in Gaussian Process Regressor Im trying to do a Bayesian optimization in a robot simulator to find optimal Kd and Kp values that fit a desired trajectory (Sinusoidal motion). First I make some random movements of the arm using random Kp and Kd values wi...
https://stackoverflow.com/questions/79093729/why-does-mean-prediction-go-flat-after-more-data-points-are-added-in-gaussian-pr
python, scikit-learn, gaussian-process
1,729,076,343
se_18306416
stackoverflow
MACHINE_LEARNING
AdaBoostClassifier with different base learners
AdaBoostClassifier with different base learners I am trying to use AdaBoostClassifier with a base learner other than DecisionTree. I have tried SVM and KNeighborsClassifier but I get errors. What are the classifiers that can be used with AdaBoostClassifier?
https://stackoverflow.com/questions/18306416/adaboostclassifier-with-different-base-learners
machine-learning, scikit-learn, adaboost
1,376,886,685
se_79090407
stackoverflow
MACHINE_LEARNING
Is it normal for a class in multiclass SVM to have nearly all data points as support vectors?
Is it normal for a class in multiclass SVM to have nearly all data points as support vectors? I’m using scikit-learn’s SVC for multiclass classification of the iris dataset and one class has almost all its data points as support vectors. Is this expected, or could there be an issue with my implementation or parameter ...
https://stackoverflow.com/questions/79090407/is-it-normal-for-a-class-in-multiclass-svm-to-have-nearly-all-data-points-as-sup
python, machine-learning, scikit-learn, classification, svm
1,729,002,511
se_62240050
stackoverflow
MACHINE_LEARNING
How to run model on new data that requires pd.get_dummies?
How to run model on new data that requires pd.get_dummies? I have a model that runs the following: import pandas as pd import numpy as np # initialize list of lists data = [['tom', 10,1,'a'], ['tom', 15,5,'a'], ['tom', 14,1,'a'], ['tom', 15,4,'b'], ['tom', 18,1,'b'], ['tom', 15,6,'a'], ['tom', 17,3,'a'] , ['t...
https://stackoverflow.com/questions/62240050/how-to-run-model-on-new-data-that-requires-pd-get-dummies
python, pandas, scikit-learn
1,591,495,166
se_29788047
stackoverflow
MACHINE_LEARNING
Keep TFIDF result for predicting new content
Keep TFIDF result for predicting new content I am using sklearn on Python to do some clustering. I've trained 200,000 data, and code below works well. corpus = open("token_from_xml.txt") vectorizer = CountVectorizer(decode_error="replace") transformer = TfidfTransformer() tfidf = transformer.fit_transform(vectorizer.f...
https://stackoverflow.com/questions/29788047/keep-tfidf-result-for-predicting-new-content
python, machine-learning, scikit-learn, tf-idf
1,429,678,506
se_45044225
stackoverflow
MACHINE_LEARNING
Splitting data to training and testing
Splitting data to training and testing Does anyone know how can I train on one dataset and test on another dataset? So far I only know we can split one dataset into training and testing with this line of code: X_train, X_test, y_train, y_test = \ train_test_split(X, y, test_size=0.30, random_state=1) I don...
https://stackoverflow.com/questions/45044225/splitting-data-to-training-and-testing
split, scikit-learn, training-data
1,499,806,110
se_79063665
stackoverflow
MACHINE_LEARNING
python non-linear regressor for incremental learning
python non-linear regressor for incremental learning I'm wondering if there is a non-linear regression routine with scikit-learn which allows for incremental learning, ie though the partial_fit call. I see that SGDRegressor and PassiveAggressiveRegressor both allow partial_fit, but are linear, and my data is decidedly...
https://stackoverflow.com/questions/79063665/python-non-linear-regressor-for-incremental-learning
machine-learning, scikit-learn, non-linear-regression, incremental
1,728,335,939
se_36382572
stackoverflow
MACHINE_LEARNING
How to apply model trained with PCA and Random Forest to test data?
How to apply model trained with PCA and Random Forest to test data? In solving one of the machine learning problem, I am implementing PCA on training data and and then applying .transform on train data using sklearn. After observing the variances, I retain only those columns from the transformed data whose variance is...
https://stackoverflow.com/questions/36382572/how-to-apply-model-trained-with-pca-and-random-forest-to-test-data
python-2.7, machine-learning, scikit-learn, random-forest
1,459,667,221
se_20224526
stackoverflow
MACHINE_LEARNING
How to extract the decision rules from scikit-learn decision-tree?
How to extract the decision rules from scikit-learn decision-tree? Can I extract the underlying decision-rules (or 'decision paths') from a trained tree in a decision tree as a textual list? Something like: if A>0.4 then if B<0.2 then if C>0.8 then class='X'
https://stackoverflow.com/questions/20224526/how-to-extract-the-decision-rules-from-scikit-learn-decision-tree
python, machine-learning, scikit-learn, decision-tree, random-forest
1,385,488,680
se_38519716
stackoverflow
MACHINE_LEARNING
Scikit-learn SVM digit recognition
Scikit-learn SVM digit recognition I want to make a program to recognize the digit in an image. I follow the tutorial in scikit learn . I can train and fit the svm classifier like the following. First, I import the libraries and dataset from sklearn import datasets, svm, metrics digits = datasets.load_digits() n_samp...
https://stackoverflow.com/questions/38519716/scikit-learn-svm-digit-recognition
python, image, scikit-learn, mnist
1,469,169,310
se_79076968
stackoverflow
MACHINE_LEARNING
Grid Search gives nan for best_score with LOGO or LOO, not k-fold CV
Grid Search gives nan for best_score with LOGO or LOO, not k-fold CV I have a nan R2 score problem with grid search. FDODB=pd.read_excel('Final Training Set for LOGO.xlsx') array = FDODB.values X = array[:,2:126] Y = array[:,1] Compd = array[:,0] scaler = StandardScaler() X = scaler.fit_transform(X) params = { '...
https://stackoverflow.com/questions/79076968/grid-search-gives-nan-for-best-score-with-logo-or-loo-not-k-fold-cv
python, machine-learning, scikit-learn, grid-search
1,728,626,501
se_75644384
stackoverflow
MACHINE_LEARNING
How to solve Error `Axes&#39; object has no attribute &#39;is_first_col&#39;?
How to solve Error `Axes&#39; object has no attribute &#39;is_first_col&#39;? from sklearn.model_selection import train_test_split, cross_val_score, StratifiedKFold from matplotlib import pyplot from sklearn.preprocessing import StandardScaler import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv('D:\...
https://stackoverflow.com/questions/75644384/how-to-solve-error-axes-object-has-no-attribute-is-first-col
python, pandas, matplotlib, scikit-learn
1,678,040,331
se_67417292
stackoverflow
MACHINE_LEARNING
How to Adjust Feature Weights in Random Forest Model?
How to Adjust Feature Weights in Random Forest Model? I am utilizing Scikit-Learn's Random Forest library, and I wanted to know if it is possible to change the feature weights, so specific features have more impact. I went through the Random Forest documentation, but I only see weight change for classes which I am not...
https://stackoverflow.com/questions/67417292/how-to-adjust-feature-weights-in-random-forest-model
python, machine-learning, scikit-learn, random-forest
1,620,300,838
se_34674797
stackoverflow
MACHINE_LEARNING
XGBoost XGBClassifier Defaults in Python
XGBoost XGBClassifier Defaults in Python I am attempting to use XGBoosts classifier to classify some binary data. When I do the simplest thing and just use the defaults (as follows) clf = xgb.XGBClassifier() metLearn=CalibratedClassifierCV(clf, method='isotonic', cv=2) metLearn.fit(train, trainTarget) testPredictions ...
https://stackoverflow.com/questions/34674797/xgboost-xgbclassifier-defaults-in-python
python, scikit-learn, classification, analytics, xgboost
1,452,249,037
se_71566189
stackoverflow
MACHINE_LEARNING
Error : All estimators should implement fit and transform, or can be &#39;drop&#39; or &#39;passthrough&#39; specifiers when using make_column_transformer
Error : All estimators should implement fit and transform, or can be &#39;drop&#39; or &#39;passthrough&#39; 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=n...
https://stackoverflow.com/questions/71566189/error-all-estimators-should-implement-fit-and-transform-or-can-be-drop-or
python, machine-learning, scikit-learn, sklearn-pandas, scikit-learn-pipeline
1,647,915,201
se_79070409
stackoverflow
MACHINE_LEARNING
How do I pass sklearns train_test_split actual dataseries and not single values as input argument?
How do I pass sklearns train_test_split actual dataseries and not single values as input argument? I want to train an LSTM-based RNN model for binary classification and for that I wanted to use tensorflow keras model with LSTM layers. In order to do so, I need testing input and output as well as validation input and o...
https://stackoverflow.com/questions/79070409/how-do-i-pass-sklearns-train-test-split-actual-dataseries-and-not-single-values
python, numpy, tensorflow, keras, scikit-learn
1,728,479,624
se_79057824
stackoverflow
MACHINE_LEARNING
LogisticRegression not returning correct results
LogisticRegression not returning correct results I am trying to predict a classification using logistic regression, based on training data, for a series of points in testing data. I am getting an output, without errors, but the results, I am told, are wrong (the incorrect output would be considered an error, but there...
https://stackoverflow.com/questions/79057824/logisticregression-not-returning-correct-results
python, machine-learning, scikit-learn, classification, logistic-regression
1,728,157,286
se_63393253
stackoverflow
MACHINE_LEARNING
Decision tree with a probability target
Decision tree with a probability target I'm currently working on a model to predict a probability of fatality once a person is infected with the Corona virus. I'm using a Dutch dataset with categorical variables: date of infection, fatality or cured, gender, age-group etc. It was suggested to use a decision tree, whic...
https://stackoverflow.com/questions/63393253/decision-tree-with-a-probability-target
python, scikit-learn, decision-tree
1,597,314,900
se_73013164
stackoverflow
MACHINE_LEARNING
Sklearn StackingClassifier very slow and inconsistent cpu usage
Sklearn StackingClassifier very slow and inconsistent cpu usage I've been trying out the StackingClassifier and StackingRegressor from sklearn recently but I've noticed it's always very slow and uses my cpu inefficiently. Let's say (just for the sake of this example) that I want to use StackingClassifier to stack a ra...
https://stackoverflow.com/questions/73013164/sklearn-stackingclassifier-very-slow-and-inconsistent-cpu-usage
python, machine-learning, scikit-learn
1,658,072,670
se_53900675
stackoverflow
MACHINE_LEARNING
How to impute test data with imputed values of training data with GridSearchCV and sklearn Pipeline
How to impute test data with imputed values of training data with GridSearchCV and sklearn Pipeline I am trying to improve my submissions for the Kaggle House Prices Competition found here. I'm working with the Iowa data available here. I'm trying to train and test my model using a sklearn pipeline, cross-validating w...
https://stackoverflow.com/questions/53900675/how-to-impute-test-data-with-imputed-values-of-training-data-with-gridsearchcv-a
python, machine-learning, scikit-learn, xgboost, grid-search
1,545,530,723
se_32494216
stackoverflow
MACHINE_LEARNING
How to retrieve the Hessian after a logistic regression in scikit-learn?
How to retrieve the Hessian after a logistic regression in scikit-learn? I am using the package scikit-learn to compute a logistic regression on a moderately large data set (300k rows, 2k cols. That's pretty large to me!). Now, since scikit-learn does not produce confidence intervals, I am calculating them myself. T...
https://stackoverflow.com/questions/32494216/how-to-retrieve-the-hessian-after-a-logistic-regression-in-scikit-learn
scikit-learn, logistic-regression, hessian-matrix
1,441,864,775
se_79061782
stackoverflow
MACHINE_LEARNING
ImportError: numpy.core.multiarray failed to import with newest numpy version
ImportError: numpy.core.multiarray failed to import with newest numpy version I am trying to run this code in VSCode and keep running into this error message: A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compile...
https://stackoverflow.com/questions/79061782/importerror-numpy-core-multiarray-failed-to-import-with-newest-numpy-version
python, numpy, scikit-learn
1,728,301,219
se_51968669
stackoverflow
MACHINE_LEARNING
Predict() with sklearn LogisticRegression and RandomForest models always predict minority class (1)
Predict() with sklearn LogisticRegression and RandomForest models always predict minority class (1) I'm building a Logistic Regression model to predict if a transaction is valid (1) or not (0) with a dataset of just 150 observations. My data is distributed as follows between the two classes: 106 observations are 0 (n...
https://stackoverflow.com/questions/51968669/predict-with-sklearn-logisticregression-and-randomforest-models-always-predict
python, machine-learning, scikit-learn, logistic-regression
1,534,946,632
se_46694664
stackoverflow
MACHINE_LEARNING
Prediction using sklearn&#39;s RandomForestRegressor
Prediction using sklearn&#39;s RandomForestRegressor Here's what my data looks like... date,locale,category,site,alexa_rank,sessions,user_logins 20170110,US,1,google,1,500,5000 20170110,EU,1,google,2,400,2000 20170111,US,2,facebook,2,400,2000 ... and so on. This is just a toy dataset I came up with, but which resembl...
https://stackoverflow.com/questions/46694664/prediction-using-sklearns-randomforestregressor
machine-learning, scikit-learn, regression, random-forest
1,507,744,537
se_74250634
stackoverflow
MACHINE_LEARNING
Can we perform stratify for linear regression model?
Can we perform stratify for linear regression model? I wanted to perform stratify method while splitting tran_test_split for linear regression problem. I know that stratify will perform on classification problems as it excepts 2 or more classes what to know is there any method or way to perform this method for linear ...
https://stackoverflow.com/questions/74250634/can-we-perform-stratify-for-linear-regression-model
python, scikit-learn, model, linear-regression, train-test-split
1,667,106,518
se_62710093
stackoverflow
MACHINE_LEARNING
How do I install sklearn module properly?
How do I install sklearn module properly? I'm trying to install sklearn module using pip command but after the installation is completed , all I can see is this folder C:\Users\Aditi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn-0.0-py...
https://stackoverflow.com/questions/62710093/how-do-i-install-sklearn-module-properly
python, scikit-learn, data-science, sklearn-pandas
1,593,759,652
se_19233771
stackoverflow
MACHINE_LEARNING
sklearn plot confusion matrix with labels
sklearn plot confusion matrix with labels I want to plot a confusion matrix to visualize the classifer's performance, but it shows only the numbers of the labels, not the labels themselves: from sklearn.metrics import confusion_matrix import pylab as pl y_test=['business', 'business', 'business', 'business', 'busines...
https://stackoverflow.com/questions/19233771/sklearn-plot-confusion-matrix-with-labels
python, matplotlib, scikit-learn
1,381,176,533
se_73479899
stackoverflow
MACHINE_LEARNING
sklearn can&#39;t find lapack in new conda environment
sklearn can&#39;t find lapack in new conda environment Question: Why can't sklearn detect its liblapack dependency and how do I fix this? Background: I the following conda environment (torch-nightly) with scikit-learn installed (note that the liblapack dependency also exists): (torch-nightly) au@a2 ~ % conda list |gre...
https://stackoverflow.com/questions/73479899/sklearn-cant-find-lapack-in-new-conda-environment
python, numpy, scikit-learn, scipy, lapack
1,661,378,279
se_69847866
stackoverflow
MACHINE_LEARNING
Can I set a random state for the Complement Naive Bayes?
Can I set a random state for the Complement Naive Bayes? I note I can set the random state in random forest classifier, but not in Complement Naive Bayes. I get error TypeError: __init__() got an unexpected keyword argument 'random_state' I assume this is because naive_bayes is computing the probability of each class...
https://stackoverflow.com/questions/69847866/can-i-set-a-random-state-for-the-complement-naive-bayes
scikit-learn, naivebayes
1,636,077,425
se_79047194
stackoverflow
MACHINE_LEARNING
How to scale conditionally using sklearn minmaxscaler
How to scale conditionally using sklearn minmaxscaler I have a column that has positive, 0 and negative values. Rows with 0 values constitute 90% of dataframe. I want to scale this column but without touching 0 value rows. Only those rows that have non zero value should be scaled between -1 to 1 according to the range...
https://stackoverflow.com/questions/79047194/how-to-scale-conditionally-using-sklearn-minmaxscaler
python-3.x, pandas, scikit-learn, scaling
1,727,879,003
se_77927215
stackoverflow
MACHINE_LEARNING
Understanding scikit learn import variants
Understanding scikit learn import variants Scikit learn import statements in their tutorials are on the form from sklearn.decomposition import PCA Another versions that works is import sklearn.decomposition pca = sklearn.decomposition.PCA(n_components = 2) However import sklearn pca = sklearn.decomposition.PCA(n_com...
https://stackoverflow.com/questions/77927215/understanding-scikit-learn-import-variants
python, scikit-learn, python-import
1,706,879,189
se_39662398
stackoverflow
MACHINE_LEARNING
scikit learn output metrics.classification_report into CSV/tab-delimited format
scikit learn output metrics.classification_report into CSV/tab-delimited format I'm doing a multiclass text classification in Scikit-Learn. The dataset is being trained using the Multinomial Naive Bayes classifier having hundreds of labels. Here's an extract from the Scikit Learn script for fitting the MNB model from ...
https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format
python, csv, text, scikit-learn, classification
1,474,638,319
se_79031928
stackoverflow
MACHINE_LEARNING
Why does average_precision_score ignore predictions where y_true = 0?
Why does average_precision_score ignore predictions where y_true = 0? Consider this example: import numpy as np from sklearn import metrics y_true = np.array([[1, 1, 1],[0, 0, 0],[0, 0, 0]]) y_pred = np.array([[1, 1, 1],[.9, .9, .9],[.8, .8, .8]]) aps = metrics.average_precision_score(y_true, y_pred, average='micro'...
https://stackoverflow.com/questions/79031928/why-does-average-precision-score-ignore-predictions-where-y-true-0
python, scikit-learn
1,727,449,372
se_79043871
stackoverflow
MACHINE_LEARNING
How to prevent big sklearn random forest model from overloading the CPU core?
How to prevent big sklearn random forest model from overloading the CPU core? I trained a random forest model with sklearn using RandomizedSearchCV. I stored the model as a joblib file and now I use it to make forecasts everyday on a server in a docker container. Basically the process is: watcher.py: def watch(): ...
https://stackoverflow.com/questions/79043871/how-to-prevent-big-sklearn-random-forest-model-from-overloading-the-cpu-core
python, docker, machine-learning, scikit-learn, parallel-processing
1,727,797,784
se_62541593
stackoverflow
MACHINE_LEARNING
How to create balanced k-means geospatial clusters?
How to create balanced k-means geospatial clusters? I have 9000 USA-based points (that are accounts) with a variety of different string and numeric columns/attributes. I'm trying to evenly divide these points/accounts up into equitable groupings that are both spatially grouped as well as weighted (in a gravity sense) ...
https://stackoverflow.com/questions/62541593/how-to-create-balanced-k-means-geospatial-clusters
python, pandas, scikit-learn, cluster-analysis, geospatial
1,592,937,326
se_44932469
stackoverflow
MACHINE_LEARNING
Optimizer Tuning in sklearn Gaussian Process Regressor
Optimizer Tuning in sklearn Gaussian Process Regressor I'm attempting to use a GaussianProcessRegressor as part of scikit-learn 0.18.1 I'm training on 200 data points and using 13 input features for my kernel – a constant multiplied by a radial basis function with twelve elements. The model runs without complaints, b...
https://stackoverflow.com/questions/44932469/optimizer-tuning-in-sklearn-gaussian-process-regressor
python, machine-learning, scikit-learn, data-science
1,499,275,386
se_55484101
stackoverflow
MACHINE_LEARNING
Trying to Find Optimal Price Point in a Data Set
Trying to Find Optimal Price Point in a Data Set I have a data set that looks like this. Year Quarter Quantity Price 2000 1 23 142 2000 2 23 144 2000 3 23 147 2000 4 23 151 2001 1 22 160 2001 2 22 183 2001 3 22 186 2001 4 22 186 2002 1 21 212 2002 2 19 ...
https://stackoverflow.com/questions/55484101/trying-to-find-optimal-price-point-in-a-data-set
python, python-3.x, scikit-learn
1,554,242,095
se_79030256
stackoverflow
MACHINE_LEARNING
How can I achieve accurate imputation of missing values in a dataset?
How can I achieve accurate imputation of missing values in a dataset? I'm working with a dataset containing details about used cars, and I've encountered several missing values in the Fuel_Type column. The possible values include 'Gasoline', 'E85 Flex Fuel', 'Hybrid', 'Diesel', and others. Currently, my data has over ...
https://stackoverflow.com/questions/79030256/how-can-i-achieve-accurate-imputation-of-missing-values-in-a-dataset
python, pandas, machine-learning, scikit-learn, data-cleaning
1,727,421,340
se_41981441
stackoverflow
MACHINE_LEARNING
Keep pandas index while applying sklearn
Keep pandas index while applying sklearn I have a dataset which has a DateTime index and I'm using PCA from sklearn to reduce the number of dimensions. The following question bugs me - will PCA keep the order of the points in my series so that I can reuse the index from the original dataframe? df = pd.DataFrame(...)...
https://stackoverflow.com/questions/41981441/keep-pandas-index-while-applying-sklearn
pandas, scikit-learn
1,485,957,011
se_68917363
stackoverflow
MACHINE_LEARNING
How to resolve: TypeError: fit() missing 1 required positional argument: &#39;y&#39;
How to resolve: TypeError: fit() missing 1 required positional argument: &#39;y&#39; # Decision Tree from sklearn.tree import DecisionTreeClassifier clf = DecisionTreeClassifier() clf = DecisionTreeClassifier.fit(X_train, y_train) y_pred = DecisionTreeClassifier.predict(X_test) print(r2_score(y_test, y_pred)) pri...
https://stackoverflow.com/questions/68917363/how-to-resolve-typeerror-fit-missing-1-required-positional-argument-y
python, python-3.x, scikit-learn
1,629,869,919
se_79021659
stackoverflow
MACHINE_LEARNING
Extend LabelEncoder classes
Extend LabelEncoder classes I have a LabelEncoder with 500 classes. To store and load it, I used pickle: with open('../data/label_encoder_v500.pkl', 'rb') as file: label_encoder = pickle.load(file) I want to add 24 new classes to this encoder, keeping existing labels unchanged. additional_classes = ['class501', '...
https://stackoverflow.com/questions/79021659/extend-labelencoder-classes
python, scikit-learn, label-encoding
1,727,250,397
se_79018913
stackoverflow
MACHINE_LEARNING
ValueError: setting an array element with a sequence. No irregular datatype or jagged array not a duplicate
ValueError: setting an array element with a sequence. No irregular datatype or jagged array not a duplicate Ok, I found this weird. I am building a text classifier. I have used the gensim's word2vec with aggregation when I try to run it through an sklearn classifier it gives me the ValueError: setting an array element...
https://stackoverflow.com/questions/79018913/valueerror-setting-an-array-element-with-a-sequence-no-irregular-datatype-or-j
python, numpy, scikit-learn
1,727,185,738
se_36652196
stackoverflow
MACHINE_LEARNING
How to make FeatureUnion return Dataframe
How to make FeatureUnion return Dataframe So I currently have a Pipeline that has a lot of customer transformers: p = Pipeline([ ("GetTimeFromDate",TimeTransformer("Date")), #Custom Transformer that adds ["time"] column ("GetZipFromAddress",ZipTransformer("Address")), #Custom Transformer that adds ["zip"] column ("Gr...
https://stackoverflow.com/questions/36652196/how-to-make-featureunion-return-dataframe
python-2.7, machine-learning, scikit-learn, pipeline, feature-extraction
1,460,737,094
se_52269187
stackoverflow
MACHINE_LEARNING
Facing ValueError: Target is multiclass but average=&#39;binary&#39;
Facing ValueError: Target is multiclass but average=&#39;binary&#39; I'm trying to use Naive Bayes algorithm for my dataset. I'm able to find out the accuracy but trying to find out precision and recall for the same. But, it is throwing the following error: ValueError: Target is multiclass but average='binary'. Please...
https://stackoverflow.com/questions/52269187/facing-valueerror-target-is-multiclass-but-average-binary
python, machine-learning, scikit-learn, valueerror, precision-recall
1,536,643,684
se_62759662
stackoverflow
MACHINE_LEARNING
Is there a way to convert a single LightGBM decision tree (decision rules) to Python code (conditional statements)?
Is there a way to convert a single LightGBM decision tree (decision rules) to Python code (conditional statements)? I am trying to convert a single LightGBM decision tree i.e. num_boost_round = 1 with num_leaves = 16 to Python conditional statements. Is there a way to do this? I found a post on stackoverflow about ...
https://stackoverflow.com/questions/62759662/is-there-a-way-to-convert-a-single-lightgbm-decision-tree-decision-rules-to-py
python, scikit-learn, decision-tree, lightgbm
1,594,050,426
se_10526579
stackoverflow
MACHINE_LEARNING
Use scikit-learn to classify into multiple categories
Use scikit-learn to classify into multiple categories I'm trying to use one of scikit-learn's supervised learning methods to classify pieces of text into one or more categories. The predict function of all the algorithms I tried just returns one match. For example I have a piece of text: "Theaters in New York compar...
https://stackoverflow.com/questions/10526579/use-scikit-learn-to-classify-into-multiple-categories
python, classification, scikit-learn
1,336,615,171
se_73226353
stackoverflow
MACHINE_LEARNING
Clip output from sklearn pipeline predict
Clip output from sklearn pipeline predict Let's see the following pipeline: scaler = ScalerFactory.get_scaler(scaler_type) model = MultiOutputRegressor(lgb.LGBMRegressor(metric='tweedie', **hyperparameters)) steps = [('scaler', scaler), ('model', model)] pipeline = Pipeline(steps) pipeline.fit(X, y, model__feature_nam...
https://stackoverflow.com/questions/73226353/clip-output-from-sklearn-pipeline-predict
python, python-3.x, scikit-learn, pipeline, scikit-learn-pipeline
1,659,552,368
se_76635503
stackoverflow
MACHINE_LEARNING
ValueError: multilabel-indicator is not supported confusion matrix
ValueError: multilabel-indicator is not supported confusion matrix multilabel-indicator is not supported is the error message I get, when trying to run: can you give me any solution or hint. import seaborn as sns sns.heatmap(confusion_matrix(y_test, y_pred), annot = True) ValueError Tra...
https://stackoverflow.com/questions/76635503/valueerror-multilabel-indicator-is-not-supported-confusion-matrix
python, machine-learning, scikit-learn, classification, confusion-matrix
1,688,720,761
se_30502284
stackoverflow
MACHINE_LEARNING
A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array
A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array Code goes as follows, I am trying to use training data for GBRT regression trees, same data works good for other classifiers but gives above error for GBRT. please help : dataset = load_files('train') vectorizer ...
https://stackoverflow.com/questions/30502284/a-sparse-matrix-was-passed-but-dense-data-is-required-use-x-toarray-to-conve
python, scikit-learn
1,432,804,738
se_54597212
stackoverflow
MACHINE_LEARNING
Using hyphen/dash in python repository name and package name
Using hyphen/dash in python repository name and package name I am trying to make my git repository pip-installable. In preparation for that I am restructuring the repo to follow the right conventions. My understanding from looking at other repositories is that I should put all my source code in a package that has the ...
https://stackoverflow.com/questions/54597212/using-hyphen-dash-in-python-repository-name-and-package-name
python, scikit-learn, pip, package, pypi
1,549,645,639
se_65655002
stackoverflow
MACHINE_LEARNING
cubic spline regression with sklearn?
cubic spline regression with sklearn? I want to regress very accurately a target which depends non-linearly from a single variable x. In my sklearn pipeline, I use: pipe = Pipeline([('poly', PolynomialFeatures(3, include_bias=False)), \ ('regr', ElasticNet(random_state=0))]) This appears to give ...
https://stackoverflow.com/questions/65655002/cubic-spline-regression-with-sklearn
python, scikit-learn, cubic-spline
1,610,292,914
se_72101295
stackoverflow
MACHINE_LEARNING
Python : GridSearchCV taking too long to finish running
Python : GridSearchCV taking too long to finish running I'm attempting to do a grid search to optimize my model but it's taking far too long to execute. My total dataset is only about 15,000 observations with about 30-40 variables. I was successfully able to run a random forest through the gridsearch which took about ...
https://stackoverflow.com/questions/72101295/python-gridsearchcv-taking-too-long-to-finish-running
python, machine-learning, scikit-learn, data-science, cross-validation
1,651,589,480
se_79000471
stackoverflow
MACHINE_LEARNING
Object of type CustomScaler is not registered/supported with gurobi_ml
Object of type CustomScaler is not registered/supported with gurobi_ml I have built a CustomScaler to scale my data in sklearn.pipeline.make_pipeline. It contained transform and inversetransform function. When I used gurobipy to optimise the regression model, I got the title error. It is not categorically mentioned on...
https://stackoverflow.com/questions/79000471/object-of-type-customscaler-is-not-registered-supported-with-gurobi-ml
machine-learning, scikit-learn, mathematical-optimization, gurobi
1,726,703,416
se_58020899
stackoverflow
MACHINE_LEARNING
Fitting KDE with scikitlearn and pandas leads to distributions outside the range of data
Fitting KDE with scikitlearn and pandas leads to distributions outside the range of data I am fitting a distribution of scores ranging from 1-13 for a set of data using scikit-learn KDE functions and Pandas plot.kde. I have set the bandwidth with a gridsearchCV method. However, when the distributions are plotted the r...
https://stackoverflow.com/questions/58020899/fitting-kde-with-scikitlearn-and-pandas-leads-to-distributions-outside-the-range
pandas, python-2.7, scikit-learn, probability
1,568,945,463
se_76593906
stackoverflow
MACHINE_LEARNING
How to resolve &quot;cannot import name &#39;_MissingValues&#39; from &#39;sklearn.utils._param_validation&#39;&quot; issue when trying to import imblearn?
How to resolve &quot;cannot import name &#39;_MissingValues&#39; from &#39;sklearn.utils._param_validation&#39;&quot; issue when trying to import imblearn? I am trying to import imblearn into my python notebook after installing the required modules. However, I am getting the following error: Additional info: I am usi...
https://stackoverflow.com/questions/76593906/how-to-resolve-cannot-import-name-missingvalues-from-sklearn-utils-param-v
python, python-3.x, scikit-learn, imblearn
1,688,201,535
se_39525716
stackoverflow
MACHINE_LEARNING
DecisionTreeRegressor &#39;tree_&#39; attribute documentation (Tree class)
DecisionTreeRegressor &#39;tree_&#39; attribute documentation (Tree class) I am trying to find the documentation on the 'Tree' class which is the class of the 'tree_' parameter of a 'DecisionTreeRegressor' but no success. Would anybody know if this class is documented anywhere please ? Thanks, Yoann
https://stackoverflow.com/questions/39525716/decisiontreeregressor-tree-attribute-documentation-tree-class
python, scikit-learn
1,474,009,998
se_74599395
stackoverflow
MACHINE_LEARNING
How to run Scikit&#39;s gp_minimize in parallel?
How to run Scikit&#39;s gp_minimize in parallel? I am unable to make skopt.gp_minimize run at multiple cores. According to the documentation, the parameter n_jobs should set the number of cores. However, setting n_cores>1 seems to have no effect. Here is a minimal example that reproduces the problem: from skopt import...
https://stackoverflow.com/questions/74599395/how-to-run-scikits-gp-minimize-in-parallel
python, optimization, scikit-learn, anaconda, scikit-optimize
1,669,632,192
se_78989293
stackoverflow
MACHINE_LEARNING
InconsistentVersionWarning: Trying to unpickle estimator StandardScaler from version 1.2.2 when using version 1.3.2
InconsistentVersionWarning: Trying to unpickle estimator StandardScaler from version 1.2.2 when using version 1.3.2 I am trying to train a machine learning model which uses the PowerTransformer from scikit-learn to transform my training data. And here is my code: from sklearn import preprocessing from sklearn.preproce...
https://stackoverflow.com/questions/78989293/inconsistentversionwarning-trying-to-unpickle-estimator-standardscaler-from-ver
python, scikit-learn
1,726,473,637
se_78891598
stackoverflow
MACHINE_LEARNING
Persistent Issue Importing KerasClassifier
Persistent Issue Importing KerasClassifier I’ve been facing a persistent issue with importing the KerasClassifier library in my Python environment, and I’m hoping to get some advice on how to resolve it. I keep encountering an intermittent issue where the import sometimes works fine, and at other times, I get the foll...
https://stackoverflow.com/questions/78891598/persistent-issue-importing-kerasclassifier
tensorflow, keras, scikit-learn, tensorflow2.0, scikeras
1,724,145,773
se_68442936
stackoverflow
MACHINE_LEARNING
I&#39;m doing a machine learning project using MNIST data set with jupyter notebook
I&#39;m doing a machine learning project using MNIST data set with jupyter notebook I'm very new to Machine Learning and I'm writing the python code for performing handwriting recognition on the MNIST dataset in a Jupyter notebook. But when I try to run the notebook I get the following error. Can anyone help me in fig...
https://stackoverflow.com/questions/68442936/im-doing-a-machine-learning-project-using-mnist-data-set-with-jupyter-notebook
python, numpy, machine-learning, scikit-learn
1,626,707,698
se_78984046
stackoverflow
MACHINE_LEARNING
PartialDependenceDisplay.from_estimator plots having lines with 0 values
PartialDependenceDisplay.from_estimator plots having lines with 0 values Need to evaluate the two way interaction between two variables after regressor model. Used PartialDependenceDisplay.from_estimator to plot but the contour lines inside the plot all have value 0.Not sure what might cause this. Checked the data an...
https://stackoverflow.com/questions/78984046/partialdependencedisplay-from-estimator-plots-having-lines-with-0-values
python, matplotlib, scikit-learn
1,726,274,050
se_78130876
stackoverflow
MACHINE_LEARNING
ValueError with Scikit-Learn
ValueError with Scikit-Learn link to car data.csv My code: import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split car_data = pd.read_csv('car_data.csv') # Create X X = car_data.drop('Buy Rate', axis=1) # Create Y y = car_data['Buy Rate'] clf = Ra...
https://stackoverflow.com/questions/78130876/valueerror-with-scikit-learn
python, pandas, scikit-learn, model
1,709,944,936
se_78981288
stackoverflow
MACHINE_LEARNING
ClassifierChain with Random Forest: Why is np.nan not supported even though Base Estimator handles it?
ClassifierChain with Random Forest: Why is np.nan not supported even though Base Estimator handles it? I'm working on a multilabel classification problem using the ClassifierChain approach with RandomForestClassifier as the base estimator. I've encountered an issue where my input matrix X contains np.nan values. When ...
https://stackoverflow.com/questions/78981288/classifierchain-with-random-forest-why-is-np-nan-not-supported-even-though-base
python-3.x, machine-learning, scikit-learn, nan, random-forest
1,726,215,924
se_40142835
stackoverflow
MACHINE_LEARNING
Image not segmenting properly using DBSCAN
Image not segmenting properly using DBSCAN I am trying to use DBSCAN from scikitlearn to segment an image based on color. The results I'm getting are . As you can see there are 3 clusters. My goal is to separate the buoys in the picture into different clusters. But obviously they are showing up as the same cluster. ...
https://stackoverflow.com/questions/40142835/image-not-segmenting-properly-using-dbscan
opencv, scikit-learn, computer-vision, image-segmentation, dbscan
1,476,917,875
se_69469083
stackoverflow
MACHINE_LEARNING
Machine learning not predicting correct results
Machine learning not predicting correct results I am working on creating a simple Python machine learning script which will predict if loan will be approved or not based on below parameters business experience: should be greater than 7 year of founded: should be after 2015 loan: no previous or current loan If above c...
https://stackoverflow.com/questions/69469083/machine-learning-not-predicting-correct-results
python, machine-learning, scikit-learn, logistic-regression
1,633,536,440
se_60043276
stackoverflow
MACHINE_LEARNING
ValueError: With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters
ValueError: With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters I wrote a text classification program. When I run the program it crashes with an error as seen in this screenshot: ValueError: With n_samples=0, test_size=0.2 and train_...
https://stackoverflow.com/questions/60043276/valueerror-with-n-samples-0-test-size-0-2-and-train-size-none-the-resulting-t
python, scikit-learn, nlp
1,580,747,106
se_66094139
stackoverflow
MACHINE_LEARNING
Issue setting up SciKeras model
Issue setting up SciKeras model I have an existing setup using scikit-learn, but am looking into expanding into deep learning with Keras. I am also using Dask, which recommends using SciKeras. The way the SciKeras KerasClassifier is currently setup, seems to fit as expected (from the verbose output), but the model see...
https://stackoverflow.com/questions/66094139/issue-setting-up-scikeras-model
python, machine-learning, keras, scikit-learn, deep-learning
1,612,739,996
se_72583838
stackoverflow
MACHINE_LEARNING
ModuleNotFoundError: No module named &#39;numpy.random.bit_generator&#39; while importing sklearn
ModuleNotFoundError: No module named &#39;numpy.random.bit_generator&#39; while importing sklearn I installed opencv, tensorflow and other tools on my Macbook M1 air by watching this tutorial: After installing, opencv and tensorflow works fine but when I try to import sklearn the mentioned error occurs. Here is the Er...
https://stackoverflow.com/questions/72583838/modulenotfounderror-no-module-named-numpy-random-bit-generator-while-importin
numpy, opencv, scikit-learn, conda, mini-forge
1,654,945,982
se_78958361
stackoverflow
MACHINE_LEARNING
Is it possible to transform a target variable using `ravel()` or `to_numpy()` in a `sklearn` pipeline?
Is it possible to transform a target variable using `ravel()` or `to_numpy()` in a `sklearn` pipeline? I am using RStudio and tidymodels in an R markdown document. I would like to incorporate some models from scikit-learn. Getting data from the R code chunks to the Python code chunk works well, but when I train and te...
https://stackoverflow.com/questions/78958361/is-it-possible-to-transform-a-target-variable-using-ravel-or-to-numpy-in
python, r, machine-learning, scikit-learn
1,725,647,505
se_38733220
stackoverflow
MACHINE_LEARNING
Difference between scikit-learn and sklearn (now deprecated)
Difference between scikit-learn and sklearn (now deprecated) On OS X 10.11.6 and python 2.7.10 I need to import from sklearn manifold. I have numpy 1.8 Orc1, scipy .13 Ob1 and scikit-learn 0.17.1 installed. I used pip to install sklearn(0.0), but when I try to import from sklearn manifold I get the following: T...
https://stackoverflow.com/questions/38733220/difference-between-scikit-learn-and-sklearn-now-deprecated
python, python-3.x, python-2.7, scikit-learn
1,470,190,041
se_71550664
stackoverflow
MACHINE_LEARNING
Library data extraction from a python syntax using AST(Abstract Syntax Tree) module
Library data extraction from a python syntax using AST(Abstract Syntax Tree) module """ import sklearn as sk from sklearn.ensemble import ExtraTreesRegressor from sklearn.model_selection import train_test_split selection = ExtraTreesRegressor() selection.fit(X,y) X_train, X_test, y_train, y_test = train_test_split(X, ...
https://stackoverflow.com/questions/71550664/library-data-extraction-from-a-python-syntax-using-astabstract-syntax-tree-mod
python, json, scikit-learn, extract, abstract-syntax-tree
1,647,810,526
se_50957340
stackoverflow
MACHINE_LEARNING
Isolation Forest Sklearn for 1D array or list and how to tune hyper parameters
Isolation Forest Sklearn for 1D array or list and how to tune hyper parameters Is there a way to implement sklearn isolation forest for a 1D array or list? All the examples I came across are for data of 2 Dimension or more. I have right now developed a model with three features and the example code snipped is mentione...
https://stackoverflow.com/questions/50957340/isolation-forest-sklearn-for-1d-array-or-list-and-how-to-tune-hyper-parameters
python, algorithm, machine-learning, scikit-learn, anomaly-detection
1,529,530,337
se_78963115
stackoverflow
MACHINE_LEARNING
Can I force sklearn to use float32 instead of float64?
Can I force sklearn to use float32 instead of float64? I am building a product recommender that will use the description of products to find similar products and recommend them. I am using CountVectorizer over the description to find semantically similar descriptions, rank them and suggest those similar. The problem c...
https://stackoverflow.com/questions/78963115/can-i-force-sklearn-to-use-float32-instead-of-float64
python, scikit-learn, ram, cosine-similarity
1,725,822,022
se_78969301
stackoverflow
MACHINE_LEARNING
Loading a pipeline with a dense-array conversion step
Loading a pipeline with a dense-array conversion step I trained and saved the following model using joblib: def to_dense(x): return np.asarray(x.todense()) to_dense_array = FunctionTransformer(to_dense, accept_sparse=True) model = make_pipeline( TfidfVectorizer(), to_dense_array, HistGradientBoosting...
https://stackoverflow.com/questions/78969301/loading-a-pipeline-with-a-dense-array-conversion-step
python, numpy, scikit-learn, numpy-ndarray, joblib
1,725,968,212
se_78963884
stackoverflow
MACHINE_LEARNING
Simulating scikit-learn&#39;s OneHotEncoder mixed data type error
Simulating scikit-learn&#39;s OneHotEncoder mixed data type error My focus is on the caveat mentioned in OneHotEncoder's list parameter doc. list : categories[i] holds the categories expected in the ith column. The passed categories should not mix strings and numeric values within a single feature, and should be sort...
https://stackoverflow.com/questions/78963884/simulating-scikit-learns-onehotencoder-mixed-data-type-error
python-3.x, pandas, dataframe, scikit-learn
1,725,856,225
se_40845304
stackoverflow
MACHINE_LEARNING
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility I have this error for trying to load a saved SVM model. I have tried uninstalling sklearn, NumPy and SciPy, reinstalling the latest versions all-together again (using pip). I am still getting this error. Why? In [1]: import sklearn; print s...
https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility
python, numpy, scikit-learn
1,480,339,068
se_78949366
stackoverflow
MACHINE_LEARNING
Is there a way to use SciPy&#39;s differential evolution, or another library, to minimize one of a multi-output regressor&#39;s outs and bound the others?
Is there a way to use SciPy&#39;s differential evolution, or another library, to minimize one of a multi-output regressor&#39;s outs and bound the others? I am using a simple RandomForestRegressor from sklearn to predict 3 outputs, and it works well. The problem is that I now need to optimize one of the outputs to be ...
https://stackoverflow.com/questions/78949366/is-there-a-way-to-use-scipys-differential-evolution-or-another-library-to-min
python, scikit-learn, scipy, mathematical-optimization, differential-evolution
1,725,462,832
se_41666627
stackoverflow
MACHINE_LEARNING
Using own image in sklearn digits example
Using own image in sklearn digits example So I've been toying around with sklearn and python and try to understand how machine learning works. I got the basic examples right but there's one thing I'm struggling with. For example let's say I'm using the digits dataset, once I got my classifier ready and tested. How wo...
https://stackoverflow.com/questions/41666627/using-own-image-in-sklearn-digits-example
python, machine-learning, scikit-learn
1,484,516,368
se_78948520
stackoverflow
MACHINE_LEARNING
Using StratifiedGroupKFold in StackingClassifier
Using StratifiedGroupKFold in StackingClassifier How to specify StratifiedGroupKFold within StackingClassifier in sklearn? from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier from sklearn.svm import NuSVC from sklearn.linear_model import LogisticRegression from sklearn.preprocess...
https://stackoverflow.com/questions/78948520/using-stratifiedgroupkfold-in-stackingclassifier
python, scikit-learn
1,725,451,098
se_78953273
stackoverflow
MACHINE_LEARNING
Importing a Model with Scikit Learn on Vertex
Importing a Model with Scikit Learn on Vertex I'm trying to import a model from my local but everytime I get the same error from gcp logs. The framework is scikit-learn AttributeError: Can't get attribute 'preprocess_text' on <module 'model_server' from '/usr/app/model_server.py'> The code snippet with this problem i...
https://stackoverflow.com/questions/78953273/importing-a-model-with-scikit-learn-on-vertex
machine-learning, google-cloud-platform, scikit-learn, google-cloud-vertex-ai
1,725,542,674
se_72464571
stackoverflow
MACHINE_LEARNING
precision_recall_fscore_support support returns None
precision_recall_fscore_support support returns None I'm trying to extract all the relevant 'weighted average' measures from classification report. I get the recall, precision and fscore correct. support, however returns None, whereas I expect it to be, 500 which is the total of 'yes' in my multiclass classification. ...
https://stackoverflow.com/questions/72464571/precision-recall-fscore-support-support-returns-none
scikit-learn, classification
1,654,097,743
se_48758383
stackoverflow
MACHINE_LEARNING
All intermediate steps should be transformers and implement fit and transform
All intermediate steps should be transformers and implement fit and transform I am implementing a pipeline using important features selection and then using the same features to train my random forest classifier. Following is my code. m = ExtraTreesClassifier(n_estimators = 10) m.fit(train_cv_x,train_cv_y) sel = Selec...
https://stackoverflow.com/questions/48758383/all-intermediate-steps-should-be-transformers-and-implement-fit-and-transform
python, machine-learning, scikit-learn, typeerror, feature-selection
1,518,487,189
se_68869466
stackoverflow
MACHINE_LEARNING
Use sklearn transformers on list of columns and preserve the input columns
Use sklearn transformers on list of columns and preserve the input columns Using sklearn transformers, I'd like to be able to apply transformations to a list of columns and have the transformer create new columns with the transformed values rather than apply them to the existing ones. Is this possible? The transformer...
https://stackoverflow.com/questions/68869466/use-sklearn-transformers-on-list-of-columns-and-preserve-the-input-columns
python, scikit-learn
1,629,509,314
se_78203591
stackoverflow
MACHINE_LEARNING
Problem with the installation of scikit multiflow
Problem with the installation of scikit multiflow When I try to install scikit-multiflow library into a virtual environment using pip in command prompt, I constantly get this issue because there is no file called 'numpy.distutils', despite installing numpy library and Microsoft Vedio Studio Installer with version 14.0...
https://stackoverflow.com/questions/78203591/problem-with-the-installation-of-scikit-multiflow
scikit-learn, scikit-multilearn
1,711,071,077
se_78940566
stackoverflow
MACHINE_LEARNING
How do I convert string data to numerical data using Label Encoder?
How do I convert string data to numerical data using Label Encoder? I was trying to convert string data into numerical data in a CSV excel sheet. It kept giving me an error about previously unseen labels, so I searched it up and found that we can use Label Encoder to convert all these values to numeric. I created a li...
https://stackoverflow.com/questions/78940566/how-do-i-convert-string-data-to-numerical-data-using-label-encoder
python, pandas, scikit-learn, label-encoding
1,725,281,638
se_78938692
stackoverflow
MACHINE_LEARNING
Reconciling disparity between test-accuracy and confusion matrix in tensorflow
Reconciling disparity between test-accuracy and confusion matrix in tensorflow Update: it's definitely something going on with the the predict function using a custom generator. When I fetch all the test data in one batch and run predictions on it, then create a confusion matrix between predictions and labels, I get w...
https://stackoverflow.com/questions/78938692/reconciling-disparity-between-test-accuracy-and-confusion-matrix-in-tensorflow
python, tensorflow, scikit-learn
1,725,241,616
se_78928473
stackoverflow
MACHINE_LEARNING
What does `fit_transform` do in the context of Scikit Learn PCA?
What does `fit_transform` do in the context of Scikit Learn PCA? I don't understand what fit_transform does compared to fit in the context of Scikit Learn and PCA. https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html# PCA takes some data and attempts to measure a set of eigenvectors, wher...
https://stackoverflow.com/questions/78928473/what-does-fit-transform-do-in-the-context-of-scikit-learn-pca
scikit-learn, pca
1,724,943,696
se_78935707
stackoverflow
MACHINE_LEARNING
Apply Scaler() on each ID on polars dataframe
Apply Scaler() on each ID on polars dataframe I have a dataset with multiple columns and an ID column. Each ID can have different magnitudes and varying sizes across these columns. I want to normalize the columns for each ID separately. import polars as pl from sklearn.preprocessing import MinMaxScaler scaler = MinMa...
https://stackoverflow.com/questions/78935707/apply-scaler-on-each-id-on-polars-dataframe
python, scikit-learn, python-polars
1,725,124,178
se_72648690
stackoverflow
MACHINE_LEARNING
ML model error &#39;numpy.ndarray&#39; object has no attribute &#39;predict&#39;
ML model error &#39;numpy.ndarray&#39; object has no attribute &#39;predict&#39; I was trying to make a predictive model, but I can't find a way to solve this numpy-related issue with my code. I already imported the pickle file containing the model I saved from Google Colab, but I can't seem to make it work. Any type ...
https://stackoverflow.com/questions/72648690/ml-model-error-numpy-ndarray-object-has-no-attribute-predict
python, pandas, numpy, flask, scikit-learn
1,655,395,059