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_21962046 | stackoverflow | MACHINE_LEARNING | Accessing a column in scikit dataset | Accessing a column in scikit dataset
I am loading the built-in boston data set in scikit library as:
from sklearn.datasets import load_boston
bdata = load_boston()
I want to extract all the values in the first column, which is called as CRIM. I Have written a line like:
plt.scatter(bdata.CRIM,bdata.target,color='blue... | https://stackoverflow.com/questions/21962046/accessing-a-column-in-scikit-dataset | python-3.x, numpy, scikit-learn, scikits | 1,393,111,599 |
se_52861129 | stackoverflow | MACHINE_LEARNING | How to calculate the joint log-likelihood for Bernoulli Naive Bayes | How to calculate the joint log-likelihood for Bernoulli Naive Bayes
For a classification problem using BernoulliNB , how to calculate the joint log-likelihood? The joint likelihood is to be calculated by below formula, where y(d) is the array of actual output (not predicted values) and x(d) is the data set of features... | https://stackoverflow.com/questions/52861129/how-to-calculate-the-joint-log-likelihood-for-bernoulli-naive-bayes | machine-learning, scikit-learn, naivebayes, bernoulli-probability | 1,539,799,730 |
se_46815252 | stackoverflow | MACHINE_LEARNING | Using Scikit-Learn GridSearchCV for cross validation with PredefinedSplit - Suspiciously good cross validation results | Using Scikit-Learn GridSearchCV for cross validation with PredefinedSplit - Suspiciously good cross validation results
I'd like to use scikit-learn's GridSearchCV to perform a grid search and calculate the cross validation error using a predefined development and validation split (1-fold cross validation).
I'm afraid ... | https://stackoverflow.com/questions/46815252/using-scikit-learn-gridsearchcv-for-cross-validation-with-predefinedsplit-susp | python, scikit-learn, cross-validation, grid-search | 1,508,345,174 |
se_79866049 | stackoverflow | MACHINE_LEARNING | AdaBoost performance degrades when exported to ONNX | AdaBoost performance degrades when exported to ONNX
My AdaBoost model uses SAMME.R and a Decision Tree as base learner to perform binary classification, the preprocessing is done using a MinMaxScaler. After converting to ONNX and running inference through the runtime I observed a significant (x5) increase in false pos... | https://stackoverflow.com/questions/79866049/adaboost-performance-degrades-when-exported-to-onnx | python, scikit-learn, onnx, adaboost | 1,768,214,422 |
se_65789613 | stackoverflow | MACHINE_LEARNING | all features must be in [0, 9] or [-10, 0] | all features must be in [0, 9] or [-10, 0]
I have the following code:
df = load_data()
pd.set_option('display.max_columns', None)
df.dtypes
intBillID object
chBillChargeCode object
chBillNo object
chOriginalBillNo object
sdBillDate dat... | https://stackoverflow.com/questions/65789613/all-features-must-be-in-0-9-or-10-0 | python, dataframe, scikit-learn | 1,611,051,963 |
se_79863277 | stackoverflow | MACHINE_LEARNING | Python ValueError while training Logistic Regression model | Python ValueError while training Logistic Regression model
I am trying to train a Logistic Regression model using scikit-learn in Python.
When I try to fit the model, I get the following error:
ValueError: could not convert string to float
Here is the code I am using:
from sklearn.linear_model import LogisticRegressio... | https://stackoverflow.com/questions/79863277/python-valueerror-while-training-logistic-regression-model | machine-learning, scikit-learn, logistic-regression | 1,767,872,900 |
se_47106385 | stackoverflow | MACHINE_LEARNING | Determine WHY Features Are Important in Decision Tree Models | Determine WHY Features Are Important in Decision Tree Models
Often-times stakeholders don't want a black-box model that's good at predicting; they want insights about features to have a better understanding about their business, and so they can explain it to others.
When we inspect the feature importance of an xgboost... | https://stackoverflow.com/questions/47106385/determine-why-features-are-important-in-decision-tree-models | python, machine-learning, scikit-learn, decision-tree, xgboost | 1,509,758,016 |
se_37803463 | stackoverflow | MACHINE_LEARNING | Held out training and validation set in gridsearchcv sklearn | Held out training and validation set in gridsearchcv sklearn
I see that in gridsearchcv best parameters are determined based on cross-validation, but what I really want to do is to determine the best parameters based on one held out validation set instead of cross validation.
Not sure if there is a way to do that. I... | https://stackoverflow.com/questions/37803463/held-out-training-and-validation-set-in-gridsearchcv-sklearn | python, text, parameters, scikit-learn, classification | 1,465,881,367 |
se_74669199 | stackoverflow | MACHINE_LEARNING | How do I pass in a 1d array to sklearn's LabelEncoder? | How do I pass in a 1d array to sklearn's LabelEncoder?
I'm following along an Uber-Lyft price prediction notebook on Kaggle, but I'm trying to use the Polars module.
In cell 43 where they use sklearn's LabelEncoder, they have the following loop that appears to loop through each feature, except for price, and encod... | https://stackoverflow.com/questions/74669199/how-do-i-pass-in-a-1d-array-to-sklearns-labelencoder | python, dataframe, scikit-learn, python-polars | 1,670,089,833 |
se_79024050 | stackoverflow | MACHINE_LEARNING | Issue with calculating confidence intervals for odds ratios | Issue with calculating confidence intervals for odds ratios
I'm working on a statistical analysis to calculate odds ratios and their 95% confidence intervals for several variables over specific time points. While the odds ratios are being calculated correctly, the confidence intervals (CIs) for these odds ratios are n... | https://stackoverflow.com/questions/79024050/issue-with-calculating-confidence-intervals-for-odds-ratios | python, scikit-learn, logistic-regression, statsmodels | 1,727,283,634 |
se_79832672 | stackoverflow | MACHINE_LEARNING | Good packages for bounded Linear Quantile Regression? | Good packages for bounded Linear Quantile Regression?
I'm looking for a good package to train a linear quantile regression model, i.e. $\hat y = \sum_{i=1}^n w_i \cdot X_i$. With $x_i$ are the input features, and $w_i$ are the bounded trainable weights. This should all be trained with quantile loss.
Here's the catch: ... | https://stackoverflow.com/questions/79832672/good-packages-for-bounded-linear-quantile-regression | python, scikit-learn, pytorch, linear-programming, quantile-regression | 1,764,341,400 |
se_62409303 | stackoverflow | MACHINE_LEARNING | How to handle missing values (NaN) in categorical data when using scikit-learn OneHotEncoder? | How to handle missing values (NaN) in categorical data when using scikit-learn OneHotEncoder?
I have recently started learning python to develop a predictive model for a research project using machine learning methods. I have a large dataset comprised of both numerical and categorical data. The dataset has lots of mis... | https://stackoverflow.com/questions/62409303/how-to-handle-missing-values-nan-in-categorical-data-when-using-scikit-learn-o | python, machine-learning, scikit-learn | 1,592,312,956 |
se_45079601 | stackoverflow | MACHINE_LEARNING | How can I get Gini Coefficient in sklearn | How can I get Gini Coefficient in sklearn
I would like in sklearn package, Find the gini coefficients for each feature on a class of paths
such as in iris data. like Iris-virginica Petal length giniοΌ0.4 οΌPetal width giniοΌ0.4. | https://stackoverflow.com/questions/45079601/how-can-i-get-gini-coefficient-in-sklearn | python, scikit-learn, gini | 1,499,946,169 |
se_35062665 | stackoverflow | MACHINE_LEARNING | How can I analyze a confusion matrix? | How can I analyze a confusion matrix?
When I print out scikit-learn's confusion matrix, I receive a very huge matrix. I want to analyze what are the true positives, true negatives etc. How can I do so?
This is how my confusion matrix looks like. I wish to understand this better.
[[4015 336 0 ..., 0 0 2]
... | https://stackoverflow.com/questions/35062665/how-can-i-analyze-a-confusion-matrix | python, matrix, scikit-learn, confusion-matrix | 1,453,987,172 |
se_79817519 | stackoverflow | MACHINE_LEARNING | Sklearn2pmml raises an error on 'classes_' parameter | Sklearn2pmml raises an error on 'classes_' parameter
I'm trying to create a PMML from a model, using this way :
from sklearn.preprocessing import LabelEncoder
y_h_train = LabelEncoder().fit_transform(y_train.copy(deep=True))
modele_label_encoded = model.fit(X_train, y_h_train)
import sklearn2pmml as skpmml... | https://stackoverflow.com/questions/79817519/sklearn2pmml-raises-an-error-on-classes-parameter | python, scikit-learn, pmml, sklearn2pmml | 1,762,938,276 |
se_79592409 | stackoverflow | MACHINE_LEARNING | HalvingGridSearchCV cannot fit multi label DecisionTreeClassifier | HalvingGridSearchCV cannot fit multi label DecisionTreeClassifier
I'm trying to use HalvingGridSearch to find the best DecisionTree model. My model performs a multi-label prediction on a single example, it is trained on a batch of data of size (n_samples x n_features=9418) and has an output of size (n_samples x n_outp... | https://stackoverflow.com/questions/79592409/halvinggridsearchcv-cannot-fit-multi-label-decisiontreeclassifier | python, scikit-learn, decision-tree, multilabel-classification, sklearn.model-selection | 1,745,580,030 |
se_55606521 | stackoverflow | MACHINE_LEARNING | Value error: Cannot convert string to float | Value error: Cannot convert string to float
from sklearn.preprocessing import OneHotEncoder
enc=OneHotEncoder(handle_unknown='ignore')
X=[['gender', 1], ['NationalITy', 2], ['PlaceofBirth', 3],['StageID', 4], ['GradeID', 5], ['SectionID', 6],['Topic', 7], ['Semester', 8], ['Relation', 9],['raisedhands', 1], ['VisITedR... | https://stackoverflow.com/questions/55606521/value-error-cannot-convert-string-to-float | python, scikit-learn | 1,554,879,594 |
se_79595277 | stackoverflow | MACHINE_LEARNING | Stratification fails in train_test_split | Stratification fails in train_test_split
Please consider the following code:
import pandas as pd
from sklearn.model_selection import train_test_split
# step 1
ids = list(range(1000))
label = 500 * [1.0] + 500 * [0.0]
df = pd.DataFrame({"id": ids, "label": label})
# step 2
train_p = 0.8
val_p = 0.1
test_p = 0.1
# st... | https://stackoverflow.com/questions/79595277/stratification-fails-in-train-test-split | python, scikit-learn | 1,745,774,231 |
se_30919454 | stackoverflow | MACHINE_LEARNING | How to make an ensemble for two binary classifiers? | How to make an ensemble for two binary classifiers?
I have two classifiers for a multimedia dataset. One for visual material and one for textual material. I want to combine the predictions of these classifiers to make a final prediction. I have been reading about bagging, boosting and stacking ensembles and all seem u... | https://stackoverflow.com/questions/30919454/how-to-make-an-ensemble-for-two-binary-classifiers | python, machine-learning, scikit-learn, classification | 1,434,640,776 |
se_79603404 | stackoverflow | MACHINE_LEARNING | Why does RandomizedSearchCV sometimes return worse results than manual tuning in scikit-learn? | Why does RandomizedSearchCV sometimes return worse results than manual tuning in scikit-learn?
I'm working on a classification problem using scikit-learn's RandomForestClassifier. I tried using RandomizedSearchCV for hyperparameter tuning, but the results were worse than when I manually set the parameters based on int... | https://stackoverflow.com/questions/79603404/why-does-randomizedsearchcv-sometimes-return-worse-results-than-manual-tuning-in | python, machine-learning, scikit-learn | 1,746,189,800 |
se_79810820 | stackoverflow | MACHINE_LEARNING | Machine Learning Project using Multidimensional Array Input/Outputs | Machine Learning Project using Multidimensional Array Input/Outputs
I am struggling to get my ML model to accept the input and outputs that I need.
My aim is to have it accept this as the input:
input_x = [
((4.11, 8.58, -2.2), (-1.27, -8.76, 2.23)),
((0.43, -6.53, 1.25), (7.91, -10.76, 0.06)),
...
]
and... | https://stackoverflow.com/questions/79810820/machine-learning-project-using-multidimensional-array-input-outputs | python, machine-learning, scikit-learn, advice | 1,762,400,686 |
se_79811225 | stackoverflow | MACHINE_LEARNING | Logging SVC/SVM training to log file | Logging SVC/SVM training to log file
I am trying to save the output from sklearn.smv.SVC training when verbose=True to a log-file. However, since it uses LibSVM in the back-end, I cannot figure out how this works. Copilot hasn't helped.
Here's a brief example. It isn't the exact problem I am trying to solve or the wor... | https://stackoverflow.com/questions/79811225/logging-svc-svm-training-to-log-file | python, scikit-learn | 1,762,429,453 |
se_19991445 | stackoverflow | MACHINE_LEARNING | Run an OLS regression with Pandas Data Frame | Run an OLS regression with Pandas Data Frame
I have a pandas data frame and I would like to able to predict the values of column A from the values in columns B and C. Here is a toy example:
import pandas as pd
df = pd.DataFrame({"A": [10,20,30,40,50],
"B": [20, 30, 10, 40, 50],
... | https://stackoverflow.com/questions/19991445/run-an-ols-regression-with-pandas-data-frame | python, pandas, scikit-learn, regression, statsmodels | 1,384,476,420 |
se_79794144 | stackoverflow | MACHINE_LEARNING | How to use sklearn imputation methods on numpy.void (record or structured array, I'm not sure) ndarray | How to use sklearn imputation methods on numpy.void (record or structured array, I'm not sure) ndarray
Code:
import numpy as np
import sklearn as skl
data = np.genfromtxt("water_potability.csv", delimiter = ",", names = True)
print(data)
print(data.shape)
print(type(data[0]))
imputer = skl.impute.SimpleImputer()
... | https://stackoverflow.com/questions/79794144/how-to-use-sklearn-imputation-methods-on-numpy-void-record-or-structured-array | python, numpy, scikit-learn | 1,760,859,061 |
se_53312464 | stackoverflow | MACHINE_LEARNING | Showing Error while using train_test_Split method to on Kaggle kernel | Showing Error while using train_test_Split method to on Kaggle kernel
What is the error here and how can I avoid it? The same code actually works in my Jupyter and Spider environment. Also I didn't understand why this isn't working on kaggle kernel.
Below is my code.
# Prepare X and y objects for sikitlearn
X = df.ilo... | https://stackoverflow.com/questions/53312464/showing-error-while-using-train-test-split-method-to-on-kaggle-kernel | python, python-3.x, scikit-learn, kernel | 1,542,256,210 |
se_68071291 | stackoverflow | MACHINE_LEARNING | How can I reuse a Transformer with inverse_transform in a scikit-learn Pipeline | How can I reuse a Transformer with inverse_transform in a scikit-learn Pipeline
I'm trying to make a scikit-learn Pipeline with the end goal of compressing my data. I am using mostly custom transformers. To explain my problem I will be using sklearn.decomposition.PCA, as it is very close to how my own transformer work... | https://stackoverflow.com/questions/68071291/how-can-i-reuse-a-transformer-with-inverse-transform-in-a-scikit-learn-pipeline | python, scikit-learn | 1,624,291,739 |
se_71854171 | stackoverflow | MACHINE_LEARNING | How can I use large hexadecimal values as training data in machine learning? | How can I use large hexadecimal values as training data in machine learning?
I am thinking of doing machine learning using sklearn. But the training data I have is a large hexadecimal value. How do I process this into training data? The code below is an example of a hexadecimal value
import sklearn
hex_train='0x504F1... | https://stackoverflow.com/questions/71854171/how-can-i-use-large-hexadecimal-values-as-training-data-in-machine-learning | python, machine-learning, scikit-learn | 1,649,838,001 |
se_77592347 | stackoverflow | MACHINE_LEARNING | Different PCA results in R and Python | Different PCA results in R and Python
I'm trying to get PCA done for my data, which is a dataframe with 16 observations in rows, and 11 features in columns.
In R, with prcomp, the matrix format consists of features in the rows and principal components in the columns. In Python, using sklearn, the format is reversed. T... | https://stackoverflow.com/questions/77592347/different-pca-results-in-r-and-python | python, r, scikit-learn, pca, prcomp | 1,701,554,576 |
se_79630857 | stackoverflow | MACHINE_LEARNING | Runtime warning in sklearn KMeans | Runtime warning in sklearn KMeans
I am running k-means using sklearn but has been getting runtime warning. Can you please explain what's happening? Below is a sample code for reproducibility:
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import KMeans
col... | https://stackoverflow.com/questions/79630857/runtime-warning-in-sklearn-kmeans | python, scikit-learn, k-means | 1,747,760,004 |
se_74337534 | stackoverflow | MACHINE_LEARNING | Can sklearn gridsearchcv rank candidates on median instead of mean_test_score? | Can sklearn gridsearchcv rank candidates on median instead of mean_test_score?
Main question:
In a certain model scenario it seems more robust to me, to judge on candidates tested in a sklearn.model_selection.GridSearchCV based on their median performance instead of mean. Is there a way to do this?
Some more context:
... | https://stackoverflow.com/questions/74337534/can-sklearn-gridsearchcv-rank-candidates-on-median-instead-of-mean-test-score | scikit-learn, gridsearchcv | 1,667,750,789 |
se_79796081 | stackoverflow | MACHINE_LEARNING | MLflow doesnβt log or show model artifacts after training run | MLflow doesnβt log or show model artifacts after training run
Iβm working on a machine learning project using MLflow for experiment tracking (on macOS, Python 3.12, scikit-learn, and DagsHub as the tracking server). The experiment runs successfully β I see the run, metrics, and parameters in the MLflow UI β but the mo... | https://stackoverflow.com/questions/79796081/mlflow-doesn-t-log-or-show-model-artifacts-after-training-run | python, logging, scikit-learn, mlflow, artifacts | 1,761,067,083 |
se_79020155 | stackoverflow | MACHINE_LEARNING | How to Apply LabelEncoder to a Polars DataFrame Column? | How to Apply LabelEncoder to a Polars DataFrame Column?
I'm trying to use scikit-learn's LabelEncoder with a Polars DataFrame to encode a categorical column. I am using the following code.
import polars as pl
from sklearn.preprocessing import LabelEncoder
df = pl.DataFrame({
"Color" : ["red","white","blue"]
})
... | https://stackoverflow.com/questions/79020155/how-to-apply-labelencoder-to-a-polars-dataframe-column | python, dataframe, scikit-learn, python-polars, label-encoding | 1,727,207,477 |
se_24745879 | stackoverflow | MACHINE_LEARNING | how to apply preprocessing methods on several columns at one time in sklearn | how to apply preprocessing methods on several columns at one time in sklearn
My question is I have so many columns in my pandas data frame and I am trying to apply the sklearn preprocessing using dataframe mapper from sklearn-pandas library such as
mapper= DataFrameMapper([
('gender',sklearn.preprocessing.LabelB... | https://stackoverflow.com/questions/24745879/how-to-apply-preprocessing-methods-on-several-columns-at-one-time-in-sklearn | python, pandas, scikit-learn, sklearn-pandas | 1,405,371,577 |
se_48856595 | stackoverflow | MACHINE_LEARNING | Concatenate encoded columns to original data frame using Scikit-learn and Pandas | Concatenate encoded columns to original data frame using Scikit-learn and Pandas
I am trying to encode all the textual data in a .csv file to numeric using Python's Scikit-learn. I am using LabelEncoder and OneHotEncoder on the columns which are of datatype object. I am wondering how to concatenate the new encoded col... | https://stackoverflow.com/questions/48856595/concatenate-encoded-columns-to-original-data-frame-using-scikit-learn-and-pandas | python, pandas, scikit-learn, one-hot-encoding | 1,518,988,146 |
se_61556766 | stackoverflow | MACHINE_LEARNING | scikit-learn: transformer to select columns by name | scikit-learn: transformer to select columns by name
Context
I am working with scikit-learn and seeking for a transformer that allows me to simply select which columns to keep or which columns to drop.
Problem
In practice, I would like to include in my pipeline an additional transformer step that allows me to choose... | https://stackoverflow.com/questions/61556766/scikit-learn-transformer-to-select-columns-by-name | python, scikit-learn | 1,588,409,738 |
se_62416223 | stackoverflow | MACHINE_LEARNING | How to select only few columns in scikit learn column selector pipeline? | How to select only few columns in scikit learn column selector pipeline?
I was reading the scikitlearn tutorial about column transformer. The given example (https://scikit-learn.org/stable/modules/generated/sklearn.compose.make_column_selector.html#sklearn.compose.make_column_selector) works, but when I tried to selec... | https://stackoverflow.com/questions/62416223/how-to-select-only-few-columns-in-scikit-learn-column-selector-pipeline | python, pandas, scikit-learn | 1,592,335,847 |
se_75454460 | stackoverflow | MACHINE_LEARNING | Does it make sense to use scikit-learn cross_val_predict() to (i)make predictions with unseen data in k-fold cross-validation and (ii)compare models? | Does it make sense to use scikit-learn cross_val_predict() to (i)make predictions with unseen data in k-fold cross-validation and (ii)compare models?
I'm training and evaluating a logistic regression and a XGBoost classifier.
With the XGBoost classifier, a training/validation/test split of the data and the subsequent ... | https://stackoverflow.com/questions/75454460/does-it-make-sense-to-use-scikit-learn-cross-val-predict-to-imake-prediction | scikit-learn, prediction, cross-validation, training-data, test-data | 1,676,420,346 |
se_75970695 | stackoverflow | MACHINE_LEARNING | How to Stacking ML models correctly - Sklearn | How to Stacking ML models correctly - Sklearn
I need some help to understand how to build the stack correctly.
I started building a Stack right now from only two models: RandomForestRegressor, XGBRegressor.
Each model is essentially an independent object.
But it is also possible to create a Stack object that consists ... | https://stackoverflow.com/questions/75970695/how-to-stacking-ml-models-correctly-sklearn | python, machine-learning, scikit-learn, deep-learning | 1,681,045,680 |
se_79783003 | stackoverflow | MACHINE_LEARNING | Shape of tree_.value | Shape of tree_.value
According to the sklearn docs the shape of tree_.value is [n_nodes, n_classes, n_outputs]. I just wanted to ask if this is still correct.
I think the correct shape is [n_nodes, n_outputs, n_classes] (for regression decision trees n_classes is 1).
Here is the code that proves it for regressor tre... | https://stackoverflow.com/questions/79783003/shape-of-tree-value | python, scikit-learn | 1,759,671,132 |
se_79779783 | stackoverflow | MACHINE_LEARNING | PCA with arpack returns different values when the order of observations change, but why? | PCA with arpack returns different values when the order of observations change, but why?
I have recently noticed that when I change the order of the observations in a sparse array, scikit-learn PCA with svd_solver="arpack" returns different floating point numbers. Is this an expected behavior? Thanks in advance!
I hav... | https://stackoverflow.com/questions/79779783/pca-with-arpack-returns-different-values-when-the-order-of-observations-change | python, scikit-learn, sparse-matrix, pca, arpack | 1,759,306,252 |
se_33679938 | stackoverflow | MACHINE_LEARNING | How to upgrade scikit-learn package in anaconda | How to upgrade scikit-learn package in anaconda
I am trying to upgrade package of scikit-learn from 0.16 to 0.17. For that I am trying to use binaries from this website: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn. I have Windows 7 x64 bit. I downloaded the relevant package locally and gave following comma... | https://stackoverflow.com/questions/33679938/how-to-upgrade-scikit-learn-package-in-anaconda | python, scikit-learn, anaconda | 1,447,357,350 |
se_49847493 | stackoverflow | MACHINE_LEARNING | Using chi2 test for feature selection with continuous features (Scikit Learn) | Using chi2 test for feature selection with continuous features (Scikit Learn)
I am trying to predict a binary (categorical) target from many continuous features, and would like to narrow your feature space before heading into model fitting. I noticed that the SelectKBest class from SKLearn's Feature Selection package ... | https://stackoverflow.com/questions/49847493/using-chi2-test-for-feature-selection-with-continuous-features-scikit-learn | python, scikit-learn, feature-selection, chi-squared | 1,523,832,242 |
se_48103301 | stackoverflow | MACHINE_LEARNING | Why is Random Search showing better results than Grid Search? | Why is Random Search showing better results than Grid Search?
I'm playing with RandomizedSearchCV function from scikit-learn. Some academic paper claims that Randomized Search can provide 'good enough' results comparing with a whole grid search, but saves a lot of time.
Surprisingly, on one occasion, the RandomizedSea... | https://stackoverflow.com/questions/48103301/why-is-random-search-showing-better-results-than-grid-search | python, python-3.x, machine-learning, scikit-learn, random-forest | 1,515,098,685 |
se_79622840 | stackoverflow | MACHINE_LEARNING | Is it possible to kill specific coeffients in polynomial regression model? | Is it possible to kill specific coeffients in polynomial regression model?
I need to make a multivariate polynomial regression. The code is based on https://saturncloud.io/blog/multivariate-polynomial-regression-with-python/.
So for my specific task I need to "kill" some coefficients. Is it possible to do so?
For exam... | https://stackoverflow.com/questions/79622840/is-it-possible-to-kill-specific-coeffients-in-polynomial-regression-model | python, machine-learning, scikit-learn, regression | 1,747,294,880 |
se_62002331 | stackoverflow | MACHINE_LEARNING | K-Means GridSearchCV hyperparameter tuning | K-Means GridSearchCV 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 pas... | https://stackoverflow.com/questions/62002331/k-means-gridsearchcv-hyperparameter-tuning | python-3.x, scikit-learn, k-means, grid-search, gridsearchcv | 1,590,409,342 |
se_79669783 | stackoverflow | MACHINE_LEARNING | Rancom Forest Classifier model returns all zeroes | Rancom Forest Classifier model returns all zeroes
I'm trying to train a RandomForestClassifier Model. However, when I train it, it gives me all zeroes. And, I really can't seem to understand why. The dataset is HUGE (close to like 75,0000 rows), so, I am a bit lost. Here is the code:
import pandas as pd
import matplot... | https://stackoverflow.com/questions/79669783/rancom-forest-classifier-model-returns-all-zeroes | python, machine-learning, scikit-learn, random-forest | 1,750,196,146 |
se_69783342 | stackoverflow | MACHINE_LEARNING | What does negative and positive value means in PCA final result? | What does negative and positive value means in PCA final result?
I am using PCA from sklearn for data reduction with 27 features and 3558 rows data and I got the following result
I have read a lot of articles but they just explain the correlation between variables and each principal component (loadings), but here I w... | https://stackoverflow.com/questions/69783342/what-does-negative-and-positive-value-means-in-pca-final-result | scikit-learn, pca | 1,635,644,092 |
se_41844311 | stackoverflow | MACHINE_LEARNING | List of all classification algorithms in scikit-learn? | List of all classification algorithms in scikit-learn?
I have a classification problem and I would like to test all the available algorithms in scikit-learn to test their performance in tackling the problem. | https://stackoverflow.com/questions/41844311/list-of-all-classification-algorithms-in-scikit-learn | python, algorithm, machine-learning, scikit-learn, classification | 1,485,323,330 |
se_54370065 | stackoverflow | MACHINE_LEARNING | displaying scikit decision tree figure in jupyter notebook | displaying scikit decision tree figure in jupyter notebook
I am currently creating a machine learning jupyter notebook as a small project and wanted to display my decision trees. However, all options I can find are to export the graphics and then load a picture, which is rather complicated.
Therefore, I wanted to as... | https://stackoverflow.com/questions/54370065/displaying-scikit-decision-tree-figure-in-jupyter-notebook | python, scikit-learn, jupyter-notebook, decision-tree | 1,548,437,064 |
se_79759086 | stackoverflow | MACHINE_LEARNING | n_jobs>=2 breaks reproducibility | n_jobs>=2 breaks reproducibility
I am facing a problem in maintaining the reproducibility in the ML project. I believe the core snippet of my issue is
clf = Clf(random_state=cfg.seed)
# instantiate the K-fold cross-validation object
cv = StratifiedKFold(
n_splits=cfg.train.n_folds,
shuffle=T... | https://stackoverflow.com/questions/79759086/n-jobs-2-breaks-reproducibility | python, tensorflow, machine-learning, scikit-learn, random-seed | 1,757,345,007 |
se_79767006 | stackoverflow | MACHINE_LEARNING | Qiskit Problem: Why does this not work with COBYLA and how do i optimize it? | Qiskit Problem: Why does this not work with COBYLA and how do i optimize it?
I'm doing a small program that is supposed to classify the data of the Wisconsin Breast Cancer database contained in sklearn.datasets using Quantum Neural Networks (specifically EstimatorQNN).
I think the code does the job just fine, but I ha... | https://stackoverflow.com/questions/79767006/qiskit-problem-why-does-this-not-work-with-cobyla-and-how-do-i-optimize-it | python, scikit-learn, quantum-computing, qiskit | 1,758,094,699 |
se_72579169 | stackoverflow | MACHINE_LEARNING | Scikit-learn: MAE criterion using mean (rather than median) | Scikit-learn: MAE criterion using mean (rather than median)
Scikit-learn's absolute_error criterion for decision trees and random forests (i.e., the MAE Criterion class: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/tree/_criterion.pyx) scales poorly compared to the default squared_error criterion.
Se... | https://stackoverflow.com/questions/72579169/scikit-learn-mae-criterion-using-mean-rather-than-median | python, machine-learning, scikit-learn, random-forest, decision-tree | 1,654,890,288 |
se_69326639 | stackoverflow | MACHINE_LEARNING | SKLearn warning "valid feature names" in version 1.0 | SKLearn warning "valid feature names" in version 1.0
I'm getting the following warning after upgrading to version 1.0 of scikit-learn:
UserWarning: X does not have valid feature names, but IsolationForest was
fitted with feature name
I cannot find in the docs on what is a "valid feature name". How do I dea... | https://stackoverflow.com/questions/69326639/sklearn-warning-valid-feature-names-in-version-1-0 | python-3.x, pandas, scikit-learn | 1,632,576,799 |
se_79748461 | stackoverflow | MACHINE_LEARNING | how to pass pre-computed folds to successiveHalving in sklearn | how to pass pre-computed folds to successiveHalving in sklearn
I want to undersample 3 cross-validation folds from a dataset, using say, RandomUnderSampler from imblearn, and then, optimize the hyperparameters of various gbms using those undersampled folds as input.
The code I have so far is:
def train_model_with_unde... | https://stackoverflow.com/questions/79748461/how-to-pass-pre-computed-folds-to-successivehalving-in-sklearn | python, scikit-learn, hyperparameters, imblearn | 1,756,327,318 |
se_78327535 | stackoverflow | MACHINE_LEARNING | scikit-learn 1.1.3. import cannot import name 'METRIC_MAPPING64' in python | scikit-learn 1.1.3. import cannot import name 'METRIC_MAPPING64' in python
I am trying to import linear_model from scikit-learn into my python code in vscode and get an unexpected error message.
import sklearn
from sklearn import linear_model
the error:
cannot import name 'METRIC_MAPPING64' from 'sklearn.metr... | https://stackoverflow.com/questions/78327535/scikit-learn-1-1-3-import-cannot-import-name-metric-mapping64-in-python | python, machine-learning, scikit-learn, linear-regression, scikits | 1,713,174,873 |
se_58101126 | stackoverflow | MACHINE_LEARNING | Using Scikit-Learn OneHotEncoder with a Pandas DataFrame | Using Scikit-Learn OneHotEncoder with a Pandas DataFrame
I'm trying to replace a column within a Pandas DataFrame containing strings into a one-hot encoded equivalent using Scikit-Learn's OneHotEncoder. My code below doesn't work:
from sklearn.preprocessing import OneHotEncoder
# data is a Pandas DataFrame
jobs_enco... | https://stackoverflow.com/questions/58101126/using-scikit-learn-onehotencoder-with-a-pandas-dataframe | python, pandas, machine-learning, scikit-learn, one-hot-encoding | 1,569,422,836 |
se_34857870 | stackoverflow | MACHINE_LEARNING | Scoring returning a numpy.core.memmap instead of a numpy.Number in grid search | Scoring returning a numpy.core.memmap instead of a numpy.Number in grid search
We are able (only within the context of our application atm) to reproduce on Ubuntu 15.04 and OS X with scikit 0.17 the following problem when using GridSearchCV with a LogisticRegression on larger data sets.
................................. | https://stackoverflow.com/questions/34857870/scoring-returning-a-numpy-core-memmap-instead-of-a-numpy-number-in-grid-search | numpy, scikit-learn, joblib | 1,453,129,540 |
se_76134348 | stackoverflow | MACHINE_LEARNING | What is the difference between "newton-cg" and "newton-cholesky" solvers in sklearn LogisticRegression? | What is the difference between "newton-cg" and "newton-cholesky" solvers in sklearn LogisticRegression?
I am confused about "newton-cg" and "newton-cholesky" explanations in different sources.
According to the sklearn documentation
the βnewton-choleskyβ solver is an exact Newton solver that calcul... | https://stackoverflow.com/questions/76134348/what-is-the-difference-between-newton-cg-and-newton-cholesky-solvers-in-skle | scikit-learn, logistic-regression, newtons-method | 1,682,737,634 |
se_78994944 | stackoverflow | MACHINE_LEARNING | Snowflake/ Snowpark "import sklearn" results in "no module found." | Snowflake/ Snowpark "import sklearn" results in "no module found."
I'm using a python worksheet in Snowflake.
When I got to information_schema.packages, scikit-learn is clearly there and installed.
But when I reference 'sklearn' (don't really understand where this full-name vs. shortened name comes... | https://stackoverflow.com/questions/78994944/snowflake-snowpark-import-sklearn-results-in-no-module-found | python, scikit-learn, snowflake-cloud-data-platform | 1,726,589,647 |
se_79748223 | stackoverflow | MACHINE_LEARNING | Evaluate transformations with the same model in scikit-learn | Evaluate transformations with the same model in scikit-learn
I would like to perform a regression analysis and test different transformations of the input variables for the same model. To accomplish this, I created a dictionary with the different pipelines, which I loop through:
import numpy as np
import pandas as pd
... | https://stackoverflow.com/questions/79748223/evaluate-transformations-with-the-same-model-in-scikit-learn | python, scikit-learn, pipeline, transformation | 1,756,311,387 |
se_79750977 | stackoverflow | MACHINE_LEARNING | Flask ML App Stuck on "Loading" Status Despite Successful Model Training | Flask ML App Stuck on "Loading" Status Despite Successful Model Training
I'm deploying a Flask ML application with book recommendations to Render, but I'm experiencing a persistent issue where my health endpoint always returns "model_loaded": false, "status": "loading", even though the logs clearly show that... | https://stackoverflow.com/questions/79750977/flask-ml-app-stuck-on-loading-status-despite-successful-model-training | python, machine-learning, flask, scikit-learn, gunicorn | 1,756,536,645 |
se_79749078 | stackoverflow | MACHINE_LEARNING | Brier Skill Score returns NaN in cross_val_score with imbalanced dataset | Brier Skill Score returns NaN in cross_val_score with imbalanced dataset
Iβm trying to evaluate classification models on a highly imbalanced fraud dataset using the Brier Skill Score (BSS) as the evaluation metric.
The dataset has ~2133 rows and the target Fraud_Flag is imbalanced:
Counter({0: 2067, 1: 66})
I impl... | https://stackoverflow.com/questions/79749078/brier-skill-score-returns-nan-in-cross-val-score-with-imbalanced-dataset | python, pandas, scikit-learn, imbalanced-data | 1,756,383,632 |
se_38250710 | stackoverflow | MACHINE_LEARNING | How to split data into 3 sets (train, validation and test)? | How to split data into 3 sets (train, validation and test)?
I have a pandas dataframe and I wish to divide it to 3 separate sets. I know that using train_test_split from sklearn.cross_validation, one can divide the data in two sets (train and test). However, I couldn't find any solution about splitting the data into t... | https://stackoverflow.com/questions/38250710/how-to-split-data-into-3-sets-train-validation-and-test | python, pandas, dataframe, scikit-learn | 1,467,908,786 |
se_67805826 | stackoverflow | MACHINE_LEARNING | Linear Regression Coefficients | Linear Regression Coefficients
I am currently using statsmodels (although I would also be happy to use Scikit) to create a linear regression. On this particular model I am finding that when adding more than one factor to the model, the OLS algorithm spits out wild coefficients. These coefficients are both extremely hi... | https://stackoverflow.com/questions/67805826/linear-regression-coefficients | python, machine-learning, scikit-learn, linear-regression, statsmodels | 1,622,639,607 |
se_79743297 | stackoverflow | MACHINE_LEARNING | Why am I getting ModuleNotFoundError: No module named 'numpy._utils' when importing scikit-learn or TensorFlow on Python 3.12? | Why am I getting ModuleNotFoundError: No module named 'numpy._utils' when importing scikit-learn or TensorFlow on Python 3.12?
Iβm trying to run Python scripts that import scikit-learn and TensorFlow, but I keep running into a NumPy-related error.
code example:
from packaging import version
import sklearn
as... | https://stackoverflow.com/questions/79743297/why-am-i-getting-modulenotfounderror-no-module-named-numpy-utils-when-import | numpy, tensorflow, scikit-learn | 1,755,859,320 |
se_16071449 | stackoverflow | MACHINE_LEARNING | How to set class weights for OneVsRestClassifier in scikit-learn? | How to set class weights for OneVsRestClassifier in scikit-learn?
I need an SVM working as multilabel classifier, so I decided to use OneVsRestClassifier wrapper. However the problem arises that the training set becomes highly unbalanced: for a given class there are much more negative examples than positive. This coul... | https://stackoverflow.com/questions/16071449/how-to-set-class-weights-for-onevsrestclassifier-in-scikit-learn | scikit-learn | 1,366,238,265 |
se_68595158 | stackoverflow | MACHINE_LEARNING | Export sklearn and/or xgboost model object for use in excel or vba? | Export sklearn and/or xgboost model object for use in excel or vba?
I've currently trained & tested several supervised models using sklearn and xgboost (using the same data). The xgboost model performs slightly better than sklearn's LassoCV.
I'm trying to find a way to export the model object so that it can be interac... | https://stackoverflow.com/questions/68595158/export-sklearn-and-or-xgboost-model-object-for-use-in-excel-or-vba | python, excel, scikit-learn, export, xgboost | 1,627,667,119 |
se_40704484 | stackoverflow | MACHINE_LEARNING | ImportError: No module named model_selection | ImportError: No module named model_selection
I am trying to use train_test_split function and write:
from sklearn.model_selection import train_test_split
and this causes
ImportError: No module named model_selection
Why? And how to overcome? | https://stackoverflow.com/questions/40704484/importerror-no-module-named-model-selection | python, scikit-learn | 1,479,648,102 |
se_51988030 | stackoverflow | MACHINE_LEARNING | sklearn StandardScaler, doesn't allow direct transform, we need to fit_transform | sklearn StandardScaler, doesn't allow direct transform, we need to fit_transform
What is the difference between fit_transform and transform?
Why doesn't transform directly works?
from sklearn.preprocessing import StandardScaler
X_scaler = StandardScaler()
X_train = X_scaler.fit_transform(X_train)
X_test = X_s... | https://stackoverflow.com/questions/51988030/sklearn-standardscaler-doesnt-allow-direct-transform-we-need-to-fit-transform | python-3.x, machine-learning, scikit-learn, data-science | 1,535,034,049 |
se_46728937 | stackoverflow | MACHINE_LEARNING | Retrieve final hidden activation layer output from sklearn's MLPClassifier | Retrieve final hidden activation layer output from sklearn's MLPClassifier
I would like to do some tests with neural network final hidden activation layer outputs using sklearn's MLPClassifier after fitting the data.
for example, If I create a classifier, assuming data X_train with labels y_train and two hidden l... | https://stackoverflow.com/questions/46728937/retrieve-final-hidden-activation-layer-output-from-sklearns-mlpclassifier | python, machine-learning, scikit-learn, classification, data-science | 1,507,894,282 |
se_79733937 | stackoverflow | MACHINE_LEARNING | ValueError when fitting model: Expected 2D array, got 1D array instead | ValueError when fitting model: Expected 2D array, got 1D array instead
import numpy as np
from sklearn.linear_model import LinearRegression
X = np.array([1, 2, 3, 4, 5]) # Features
y = np.array([2, 4, 6, 8, 10]) # Target
model = LinearRegression()
model.fit(X, y) # <-- Error occurs here
When I try to fit my Linea... | https://stackoverflow.com/questions/79733937/valueerror-when-fitting-model-expected-2d-array-got-1d-array-instead | numpy, machine-learning, scikit-learn | 1,755,065,781 |
se_55740220 | stackoverflow | MACHINE_LEARNING | Macro VS Micro VS Weighted VS Samples F1 Score | Macro VS Micro VS Weighted VS Samples F1 Score
In sklearn.metrics.f1_score, the f1 score has a parameter called "average". What does macro, micro, weighted, and samples mean? Please elaborate, because in the documentation, it was not explained properly. Or simply answer the following:
Why is "samples" best parameter... | https://stackoverflow.com/questions/55740220/macro-vs-micro-vs-weighted-vs-samples-f1-score | python, python-3.x, machine-learning, scikit-learn, metrics | 1,555,568,785 |
se_27822752 | stackoverflow | MACHINE_LEARNING | scikit-learn: Predicting new points with DBSCAN | scikit-learn: Predicting new points with DBSCAN
I am using DBSCAN to cluster some data using Scikit-Learn (Python 2.7):
from sklearn.cluster import DBSCAN
dbscan = DBSCAN(random_state=0)
dbscan.fit(X)
However, I found that there was no built-in function (aside from "fit_predict") that could assign the new data points... | https://stackoverflow.com/questions/27822752/scikit-learn-predicting-new-points-with-dbscan | machine-learning, scikit-learn, cluster-analysis, data-mining, dbscan | 1,420,644,479 |
se_49541671 | stackoverflow | MACHINE_LEARNING | How to save learned weights/parameters of PCA and T-SNE in Sklearn | How to save learned weights/parameters of PCA and T-SNE in Sklearn
I have two set of data let's say A and B.
I want to apply PCA and T-sne to A and fine tune the algo.
Once, I am satisfied with my tuning I want to save the learnt things to some pickle file.
Now I want to apply the same learnt PCA and t-sne to set B.
I... | https://stackoverflow.com/questions/49541671/how-to-save-learned-weights-parameters-of-pca-and-t-sne-in-sklearn | python, machine-learning, scikit-learn | 1,522,261,682 |
se_46299246 | stackoverflow | MACHINE_LEARNING | Sound digit classification | Sound digit classification
What I'm trying to do is conceptually similar to the famous MNIST classification example. Except that each digit is a computer generated sound wave.
I'll be adding some background noise to the data in order to improve real world accuracy.
My question is; considering the sequential data what ... | https://stackoverflow.com/questions/46299246/sound-digit-classification | python-3.x, machine-learning, scikit-learn, sound-recognition | 1,505,820,452 |
se_46638641 | stackoverflow | MACHINE_LEARNING | How can I fix "ValueError: Expected 2D array, got 1D array instead" in scikit-learn? | How can I fix "ValueError: Expected 2D array, got 1D array instead" in scikit-learn?
I want to classify the files in my disk based on the file type by making use of a classifier. The code I have written is,
import sklearn
import numpy as np
# Importing a local data set from the desktop
import pandas as pd
... | https://stackoverflow.com/questions/46638641/how-can-i-fix-valueerror-expected-2d-array-got-1d-array-instead-in-scikit-le | python, arrays, numpy, scikit-learn | 1,507,521,390 |
se_42449814 | stackoverflow | MACHINE_LEARNING | Running Jupyter notebook in a virtualenv: installed sklearn module not available | Running Jupyter notebook in a virtualenv: installed sklearn module not available
I have installed a created a virtualenv machinelearn and installed a few python modules (pandas, scipy and sklearn) in that environment.
When I run jupyter notebook, I can import pandas and scipy in my notebooks - however, when I try to ... | https://stackoverflow.com/questions/42449814/running-jupyter-notebook-in-a-virtualenv-installed-sklearn-module-not-available | python, scikit-learn, virtualenv, jupyter-notebook | 1,487,977,747 |
se_65975815 | stackoverflow | MACHINE_LEARNING | Plotting Threshold (precision_recall curve) matplotlib/sklearn.metrics | Plotting Threshold (precision_recall curve) matplotlib/sklearn.metrics
I am trying to plot the thresholds for my precision/recall curve. I am just using the MNIST data, with the example from the book Hands On Machine Learning with scikit-learn, keras, and TensorFlow. Trying to train the model to detect the image of 5'... | https://stackoverflow.com/questions/65975815/plotting-threshold-precision-recall-curve-matplotlib-sklearn-metrics | python, matplotlib, scikit-learn, precision-recall | 1,612,068,297 |
se_33623144 | stackoverflow | MACHINE_LEARNING | how can I make recommendation model using python's scikit-learn | how can I make recommendation model using python's scikit-learn
I'm learning statistical learning these days using python's pandas and scikit-learn library and they're fantastic tools for me.
I could have learned the way of classification, regression and also clustering with them of course.
But, I cannot find th... | https://stackoverflow.com/questions/33623144/how-can-i-make-recommendation-model-using-pythons-scikit-learn | python, machine-learning, scikit-learn, recommendation-engine, collaborative-filtering | 1,447,131,306 |
se_79678325 | stackoverflow | MACHINE_LEARNING | Building a sklearn compatible estimator: 'dict' object has no attribute 'requires_fit' | Building a sklearn compatible estimator: 'dict' object has no attribute 'requires_fit'
I am trying to build a scikit-learn compatible estimator. I have built a custom class that inherits from BaseEstimator and RegressorMixin. However, when I try to use this, I run into an AttributeError: 'dict' object ... | https://stackoverflow.com/questions/79678325/building-a-sklearn-compatible-estimator-dict-object-has-no-attribute-require | python, scikit-learn, regression | 1,750,807,658 |
se_79730533 | stackoverflow | MACHINE_LEARNING | Version unsupported imbalanced-learn | Version unsupported imbalanced-learn
I am trying to install scikit-learn and imbalanced-learn for ML project using poetry.
# File pyproject.toml
[project]
name = "hello"
version = "0.1.0"
description = ""
authors = [
{name = "",email = ""}
]
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
]
pyth... | https://stackoverflow.com/questions/79730533/version-unsupported-imbalanced-learn | python, scikit-learn | 1,754,732,918 |
se_75215672 | stackoverflow | MACHINE_LEARNING | TypeError: predict() got an unexpected keyword argument 'return_mean_grad' | TypeError: predict() got an unexpected keyword argument 'return_mean_grad'
Using scikit-optimize and scikit-learn, I get the following error on calling the gp_minimize function:
TypeError: predict() got an unexpected keyword argument
'return_mean_grad'
I think it may be some version incompatability but they ... | https://stackoverflow.com/questions/75215672/typeerror-predict-got-an-unexpected-keyword-argument-return-mean-grad | scikit-learn, scikit-optimize | 1,674,512,703 |
se_78338808 | stackoverflow | MACHINE_LEARNING | How to interpret the Coefficient of nonlinear regression in scikit learn? | How to interpret the Coefficient of nonlinear regression in scikit learn?
I am using the following code to do a nonlinear regression, and I am getting an intercept & 20 coefficients. How to interpret those coefficients to be able to construct a formula Y = intercept + coeff*feat_a + .....?
data = pd.read_csv("data.cs... | https://stackoverflow.com/questions/78338808/how-to-interpret-the-coefficient-of-nonlinear-regression-in-scikit-learn | python, scikit-learn, linear-regression, polynomial-approximations | 1,713,335,676 |
se_72922775 | stackoverflow | MACHINE_LEARNING | Missing cluster in k-means | Missing cluster in k-means
I'm trying to analyse a dataset with the k-means algorithm in python with scikit-learn.
Has anyone ever had the problem of getting less clusters than requested?
With the input
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=4)
my samples are only in cluster 0, 1 and 2. Cluster... | https://stackoverflow.com/questions/72922775/missing-cluster-in-k-means | python, scikit-learn, cluster-analysis, k-means | 1,657,381,822 |
se_74163700 | stackoverflow | MACHINE_LEARNING | K-Means Clustering Output seems wrong, how can it be explained? | K-Means Clustering Output seems wrong, how can it be explained?
I have a custom dataset that I want to partion using kmeans. This is my MCVE:
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
samples = np.array([[3.2736001e+03, 1.7453293e+00], [3.7256001e+03, 5.2359879e-02], [3.2960000e+03, 1.7366025e... | https://stackoverflow.com/questions/74163700/k-means-clustering-output-seems-wrong-how-can-it-be-explained | python, machine-learning, scikit-learn, k-means | 1,666,442,828 |
se_79473553 | stackoverflow | MACHINE_LEARNING | How to add Alpine scikit-learn to poetry environment on Alpine Docker container? | How to add Alpine scikit-learn to poetry environment on Alpine Docker container?
I have to use an python alpine docker image for my python project.
I use poetry for dependency management, and I need to add the scikit-learn package.
The scikit-learn within poetry is not working on alpine linux images, so I figured out ... | https://stackoverflow.com/questions/79473553/how-to-add-alpine-scikit-learn-to-poetry-environment-on-alpine-docker-container | python, docker, scikit-learn, alpine-linux, python-poetry | 1,740,679,353 |
se_67544370 | stackoverflow | MACHINE_LEARNING | KeyError while fetching MNIST data | KeyError while fetching MNIST data
I'm trying to play around MNIST dataset:
from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
x, y = mnist['data'], mnist['target']
digit = x[36001]
Here is the error I got at the very beginning:
Error screenshot to text:
KeyError ... | https://stackoverflow.com/questions/67544370/keyerror-while-fetching-mnist-data | python, scikit-learn, mnist | 1,621,064,369 |
se_79691953 | stackoverflow | MACHINE_LEARNING | Ridge Polynomial Regression: How to get parameters for equation found | Ridge Polynomial Regression: How to get parameters for equation found
I've used sklearn for polynomial ridge regression. Using grid search, I am happy with the results. Now I would like to render it as a simple polynomial equation to run in a small python module. The sklearn function returns the degree and alpha pa... | https://stackoverflow.com/questions/79691953/ridge-polynomial-regression-how-to-get-parameters-for-equation-found | python, scikit-learn, regression, polynomial-approximations | 1,751,821,614 |
se_36631163 | stackoverflow | MACHINE_LEARNING | What are the pros and cons between get_dummies (Pandas) and OneHotEncoder (Scikit-learn)? | What are the pros and cons between get_dummies (Pandas) and OneHotEncoder (Scikit-learn)?
I'm learning different methods to convert categorical variables to numeric for machine-learning classifiers. I came across the pd.get_dummies method and sklearn.preprocessing.OneHotEncoder() and I wanted to see how they differed... | https://stackoverflow.com/questions/36631163/what-are-the-pros-and-cons-between-get-dummies-pandas-and-onehotencoder-sciki | python, pandas, machine-learning, scikit-learn, dummy-variable | 1,460,658,517 |
se_65702949 | stackoverflow | MACHINE_LEARNING | Update scikit model so it is compatible with newest version | Update scikit model so it is compatible with newest version
I have a question about scikit models and (retro-)compatibility.
I have a model (saved using joblib) created in Python 3.5 from scikit-learn 0.21.2, which I then analyze with the package shap version 0.30. Since I upgraded to Ubuntu 20.04 I have Python 3.8 (a... | https://stackoverflow.com/questions/65702949/update-scikit-model-so-it-is-compatible-with-newest-version | python, scikit-learn, pickle, compatibility, joblib | 1,610,544,463 |
se_70434923 | stackoverflow | MACHINE_LEARNING | Get the clusters from agglomerative for a given truncation | Get the clusters from agglomerative for a given truncation
From the example of scikit-learn using scipy, (only changing the truncate_mode from 'level' to 'lastp'),
import numpy as np
from matplotlib import pyplot as plt
from scipy.cluster.hierarchy import dendrogram
from sklearn.datasets import load_iris
from sklearn... | https://stackoverflow.com/questions/70434923/get-the-clusters-from-agglomerative-for-a-given-truncation | python, pandas, scikit-learn, cluster-analysis, hierarchical-clustering | 1,640,087,153 |
se_77058057 | stackoverflow | MACHINE_LEARNING | I get multi-class error when trying to use roc_auc_score from scikit-learn even though both arrays are 1D | I get multi-class error when trying to use roc_auc_score from scikit-learn even though both arrays are 1D
Even if I put the multi class argument, the next error is about the dimension:
numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1
This is the original run:
Number of gates for each filt... | https://stackoverflow.com/questions/77058057/i-get-multi-class-error-when-trying-to-use-roc-auc-score-from-scikit-learn-even | python, machine-learning, scikit-learn | 1,694,076,922 |
se_58946738 | stackoverflow | MACHINE_LEARNING | scikit-learn not importing in jupyter notebook | scikit-learn not importing in jupyter notebook
I installed scikit-learn both using pip and conda commandas. Whenever I check the package, it shows that it is already installed but, whenever I try import it, it shows error.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
fr... | https://stackoverflow.com/questions/58946738/scikit-learn-not-importing-in-jupyter-notebook | python, python-3.x, machine-learning, scikit-learn, linear-regression | 1,574,224,341 |
se_29089246 | stackoverflow | MACHINE_LEARNING | How to use the OneVsRestClassifier in Scikit-learn to analyse the performance of predicting each individual class with multi-class classification? | How to use the OneVsRestClassifier in Scikit-learn to analyse the performance of predicting each individual class with multi-class classification?
In the OneVsRestClassifier documentation on the scikit-learn website it states the following:
"Since each class is represented by one and one classifier only, it is possib... | https://stackoverflow.com/questions/29089246/how-to-use-the-onevsrestclassifier-in-scikit-learn-to-analyse-the-performance-of | machine-learning, scikit-learn | 1,426,551,467 |
se_63405239 | stackoverflow | MACHINE_LEARNING | What happens if you use LinearRegression with OneVsRestClassifier | What happens if you use LinearRegression with OneVsRestClassifier
I'd like to understand what happens under the hood of scikitlearn OneVsRestClassifier when we use LinearRegression as estimator. Does it create one LinearRegressor per class and apply a softmax function to return an output class? Documentation is not cl... | https://stackoverflow.com/questions/63405239/what-happens-if-you-use-linearregression-with-onevsrestclassifier | python, machine-learning, scikit-learn, classification | 1,597,368,084 |
se_49409074 | stackoverflow | MACHINE_LEARNING | Java regex doesn't match outside of ascii range, behaves different than python regex | Java regex doesn't match outside of ascii range, behaves different than python regex
I want to filter Strings from documents the same way sklearn's CountVectorizer does. It uses the following RegEx: (?u)\b\w\w+\b.
This java code should behave the same way:
Pattern regex = Pattern.compile("(?u)\\b\\w\\w+\\b");
Matc... | https://stackoverflow.com/questions/49409074/java-regex-doesnt-match-outside-of-ascii-range-behaves-different-than-python-r | java, regex, scikit-learn, countvectorizer | 1,521,642,743 |
se_79696701 | stackoverflow | MACHINE_LEARNING | Reproduce a particular tree from the random forest using DecisionTreeRegressor | Reproduce a particular tree from the random forest using DecisionTreeRegressor
I am trying to replicate a specific decision tree trained by a RandomForestRegressor class, using DecisionTreeRegressor.
However, I cannot get the exact results, even with using the exact same bootstrapped samples and the same hyperparamete... | https://stackoverflow.com/questions/79696701/reproduce-a-particular-tree-from-the-random-forest-using-decisiontreeregressor | python, scikit-learn, random-forest, decision-tree | 1,752,134,220 |
se_76703386 | stackoverflow | MACHINE_LEARNING | How to Handle Imbalanced Data in a Classification Problem? | How to Handle Imbalanced Data in a Classification Problem?
I am working on a binary classification problem using machine learning, where my target classes are imbalanced. I have approximately 80% of data points in Class A and only 20% in Class B.
I have tried using various classifiers like Random Forest and Logistic R... | https://stackoverflow.com/questions/76703386/how-to-handle-imbalanced-data-in-a-classification-problem | machine-learning, scikit-learn, classification, imbalanced-data | 1,689,588,356 |
se_29980037 | stackoverflow | MACHINE_LEARNING | Tokenizing text with scikit-learn | Tokenizing text with scikit-learn
I have the following code to extract features from a set of files (folder name is the category name) for text classification.
import sklearn.datasets
from sklearn.feature_extraction.text import TfidfVectorizer
train = sklearn.datasets.load_files('./train', description=None, categori... | https://stackoverflow.com/questions/29980037/tokenizing-text-with-scikit-learn | python, machine-learning, scikit-learn, text-classification, scikits | 1,430,440,749 |
se_79696741 | stackoverflow | MACHINE_LEARNING | Plot confusion matrix in black and white | Plot confusion matrix in black and white
I currently have the following code:
disp = ConfusionMatrixDisplay(confusion_matrix=cm)
disp.plot()
plt.show()
This results into something like:
However, I want the diagonal to be depicted with a black background, and the off-diagonal with a white background, that is somethin... | https://stackoverflow.com/questions/79696741/plot-confusion-matrix-in-black-and-white | python, scikit-learn, confusion-matrix | 1,752,136,370 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.