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_69173159
stackoverflow
MACHINE_LEARNING
Error when trying to install imblearn package
Error when trying to install imblearn package After: pip install imblearn I get: ERROR: Could not find a version that satisfies the requirements imblearn (from version: none). Any ideas on how to fix this?
https://stackoverflow.com/questions/69173159/error-when-trying-to-install-imblearn-package
scikit-learn, imbalanced-data, imblearn
1,631,602,627
se_60179372
stackoverflow
MACHINE_LEARNING
Scikit-Learn Logistic Regression is Inaccurate
Scikit-Learn Logistic Regression is Inaccurate I was using scikit-learn.linear_model.LogisticRegression, but it didn't work so well. I started with an x and y list. X was integers between -10 and 10 inclusive. Y was the x value plugged into the logistic function 100/ (1 + e^-x). This means it should have been a per...
https://stackoverflow.com/questions/60179372/scikit-learn-logistic-regression-is-inaccurate
python, scikit-learn, regression, logistic-regression
1,581,467,364
se_78793796
stackoverflow
MACHINE_LEARNING
Leave one out encoding on test set with transform
Leave one out encoding on test set with transform Context: When preprocessing a data set using sklearn, you use fit_transform on the training set and transform on the test set, to avoid data leakage. Using leave one out (LOO) encoding, you need the target variable value to calculate the encoded value of a feature valu...
https://stackoverflow.com/questions/78793796/leave-one-out-encoding-on-test-set-with-transform
python, machine-learning, scikit-learn, encoding
1,721,916,344
se_78791738
stackoverflow
MACHINE_LEARNING
MultiLabelBinarizer: inverse_transform How can get a list of labels sorted according to their probability?
MultiLabelBinarizer: inverse_transform How can get a list of labels sorted according to their probability? I am doing a multi label classification and I use MultiLabelBinarizer to translate the list of labels into Zeros and Ones. I could get the Labels using inverse_transform which is super. However, in a case where I...
https://stackoverflow.com/questions/78791738/multilabelbinarizer-inverse-transform-how-can-get-a-list-of-labels-sorted-accor
python, sorting, scikit-learn, classification, multilabel-classification
1,721,888,768
se_56372324
stackoverflow
MACHINE_LEARNING
Getting counts in MultiLabelBinarizer
Getting counts in MultiLabelBinarizer How can I get counts of items in MultiLabelBinarizer? import pandas as pd from sklearn.preprocessing import MultiLabelBinarizer mlb = MultiLabelBinarizer() pd.DataFrame(mlb.fit_transform([(1,1,2), (3,3,2,5)]),columns=mlb.classes_) Out[0]: 1 2 3 5 0 1 1 0 0 1 0 1 1...
https://stackoverflow.com/questions/56372324/getting-counts-in-multilabelbinarizer
python-3.x, machine-learning, scikit-learn, data-manipulation
1,559,195,234
se_78701495
stackoverflow
MACHINE_LEARNING
What is the default accuracy scoring in cross_val_score() in sklearn?
What is the default accuracy scoring in cross_val_score() in sklearn? I have a regression model made using random-Forest. I made pipelines using scikit-learn to process data and now have used RandomForestRegressor to predict. I want to get the accuracy of model. because of the problem of over-fitting I decided to use ...
https://stackoverflow.com/questions/78701495/what-is-the-default-accuracy-scoring-in-cross-val-score-in-sklearn
python, scikit-learn
1,720,002,592
se_59807511
stackoverflow
MACHINE_LEARNING
Decoding using MultiLabelBinarizer python
Decoding using MultiLabelBinarizer python My target is a data frame that looks like the one below, using MultiLabelBinarizer to encode the my data frame (each row at once) works well, while decoding always outputs data in wrong order. Here is a simple data frame (my target y): index col2 col2 col3 0 ...
https://stackoverflow.com/questions/59807511/decoding-using-multilabelbinarizer-python
python, scikit-learn, multilabel-classification
1,579,412,949
se_71490086
stackoverflow
MACHINE_LEARNING
Python annotate variable as sklearn model
Python annotate variable as sklearn model I have a function that takes in an sklearn model as an argument. I would like to annotate the parameter to indicate that it is an sklearn model. What I've tried: def foo(model: 'Model'): pass this returns the error Name "Model" is not defined mypy(error). I then tried: fr...
https://stackoverflow.com/questions/71490086/python-annotate-variable-as-sklearn-model
python, scikit-learn, python-typing
1,647,386,385
se_59439096
stackoverflow
MACHINE_LEARNING
ImportError: cannnot import name 'Imputer' from 'sklearn.preprocessing'
ImportError: cannnot import name 'Imputer' from 'sklearn.preprocessing' Trying to import Imputer from sklearn.preprocessing, from sklearn.preprocessing import Imputer Shows ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (/home/codeknight13/anaconda3/lib/python3.7/site-packages/...
https://stackoverflow.com/questions/59439096/importerror-cannnot-import-name-imputer-from-sklearn-preprocessing
python, python-3.x, scikit-learn
1,576,955,229
se_73132252
stackoverflow
MACHINE_LEARNING
ValueError: X has 1 features, but LinearRegression is expecting 2 features as input
ValueError: X has 1 features, but LinearRegression is expecting 2 features as input I am using pywebio to create a small script-run user interface for my machine learning program. When not using the small UI, I don't have any errors when running the linear regression predict() function. The UI is retrieving two number...
https://stackoverflow.com/questions/73132252/valueerror-x-has-1-features-but-linearregression-is-expecting-2-features-as-in
python, numpy, machine-learning, scikit-learn, valueerror
1,658,896,147
se_69005052
stackoverflow
MACHINE_LEARNING
How do I fix: "FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan?"
How do I fix: "FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan?" from sklearn.model_selection import GridSearchCV, KFold param_grid = {'select__k': np.arange(1, data_x_numeric.shape[1] + 1)} cv = KFold(n_splits=3, random_state=1, shuffle...
https://stackoverflow.com/questions/69005052/how-do-i-fix-fitfailedwarning-estimator-fit-failed-the-score-on-this-train-t
python, scikit-learn, pipeline, feature-selection, gridsearchcv
1,630,442,282
se_49061575
stackoverflow
MACHINE_LEARNING
Why when I use GridSearchCV with roc_auc scoring, the score is different for grid_search.score(X,y) and roc_auc_score(y, y_predict)?
Why when I use GridSearchCV with roc_auc scoring, the score is different for grid_search.score(X,y) and roc_auc_score(y, y_predict)? I am using stratified 10-fold cross validation to find model that predicts y (binary outcome) from X (X has 34 labels) with the highest auc. I set the GridSearchCV: log_reg = LogisticRe...
https://stackoverflow.com/questions/49061575/why-when-i-use-gridsearchcv-with-roc-auc-scoring-the-score-is-different-for-gri
python, scikit-learn, cross-validation, auc
1,519,955,327
se_37106983
stackoverflow
MACHINE_LEARNING
scikit-learn clustering: predict(X) vs. fit_predict(X)
scikit-learn clustering: predict(X) vs. fit_predict(X) In scikit-learn, some clustering algorithms have both predict(X) and fit_predict(X) methods, like KMeans and MeanShift, while others only have the latter, like SpectralClustering. According to the doc: fit_predict(X[, y]): Performs clustering on X and returns ...
https://stackoverflow.com/questions/37106983/scikit-learn-clustering-predictx-vs-fit-predictx
python-3.x, machine-learning, scikit-learn
1,462,760,729
se_78767192
stackoverflow
MACHINE_LEARNING
KNNImputer drops columns despite of numeric datatypes and right shape
KNNImputer drops columns despite of numeric datatypes and right shape I am using KNNImputer to impute np.nan values in several pd.DataFrame. I checked that all the datatypes of each one of the dataframes are numeric. However, KNNImputer drops some columns in some dataframes: >>>input_df.shape (816, 216) >>> input...
https://stackoverflow.com/questions/78767192/knnimputer-drops-columns-despite-of-numeric-datatypes-and-right-shape
pandas, machine-learning, scikit-learn, imputation
1,721,351,855
se_74628090
stackoverflow
MACHINE_LEARNING
How to solve ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' in Google Colaboratory?
How to solve ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' in Google Colaboratory? I am trying to design a decision surface of decision trees trained on pairs of features in my dataset in Google Colaboratory. Example Code: import matplotlib.pyplot as plt from sklea...
https://stackoverflow.com/questions/74628090/how-to-solve-importerror-cannot-import-name-decisionboundarydisplay-from-skl
machine-learning, scikit-learn, google-colaboratory, python-3.6
1,669,812,714
se_20927368
stackoverflow
MACHINE_LEARNING
How to normalize a confusion matrix?
How to normalize a confusion matrix? I calculated a confusion matrix for my classifier using confusion_matrix() from scikit-learn. The diagonal elements of the confusion matrix represent the number of points for which the predicted label is equal to the true label, while off-diagonal elements are those that are mislab...
https://stackoverflow.com/questions/20927368/how-to-normalize-a-confusion-matrix
python, machine-learning, scikit-learn, normalization, confusion-matrix
1,388,873,434
se_78621593
stackoverflow
MACHINE_LEARNING
PCA in Python: Reproducing pca.fit_transform() results using pca.fit()?
PCA in Python: Reproducing pca.fit_transform() results using pca.fit()? I have a data frame called data_principal_components with dimensions (306x21154), so 306 observations and 21154 features. Using PCA, I want to project the data into 10 dimensions. As far as I understand, the following code does this. The resulting...
https://stackoverflow.com/questions/78621593/pca-in-python-reproducing-pca-fit-transform-results-using-pca-fit
python, scikit-learn, pca
1,718,349,689
se_73418424
stackoverflow
MACHINE_LEARNING
How to add type hints to scikit-learn functions?
How to add type hints to scikit-learn functions? I have the following simple function: def f1(y_true, y_pred): return {"f1": 100 * sklearn.metrics.f1_score(y_true, y_pred)} According to the scikit-learn documentation, the arguments to f1_score can have the following types: y_true: 1d array-like, or label indicat...
https://stackoverflow.com/questions/73418424/how-to-add-type-hints-to-scikit-learn-functions
python, scikit-learn, mypy, python-typing
1,660,919,873
se_78742216
stackoverflow
MACHINE_LEARNING
How to Encode Non-Ordinal Categorical Variables for RandomForest without Using Label Encoding?
How to Encode Non-Ordinal Categorical Variables for RandomForest without Using Label Encoding? I need to predict different types of exploitation using a RandomForestClassifier. My dataset contains several categorical variables such as gender, citizenship, and CountryOfExploitation. These variables are not ordinal, mea...
https://stackoverflow.com/questions/78742216/how-to-encode-non-ordinal-categorical-variables-for-randomforest-without-using-l
python, machine-learning, scikit-learn, random-forest, label-encoding
1,720,818,711
se_78743465
stackoverflow
MACHINE_LEARNING
Python 3.10.4 scikit-learn import hangs when executing via CPP
Python 3.10.4 scikit-learn import hangs when executing via CPP Python 3.10.4 is embedded into cpp application. I'm trying to import sklearn library which is installed at custom location using pip --target. sklearn custom path (--target path) is appended to sys.path. Below is a function from the script which just print...
https://stackoverflow.com/questions/78743465/python-3-10-4-scikit-learn-import-hangs-when-executing-via-cpp
python, python-3.x, scikit-learn
1,720,864,084
se_78752527
stackoverflow
MACHINE_LEARNING
How to visualize random forest plot using graphviz, in characters outside of UTF-8 (Chinese)
How to visualize random forest plot using graphviz, in characters outside of UTF-8 (Chinese) I am doing a random forest model on PC orders data, which is mostly in Chinese. I have done the model and accuracy checks. However, I can't seem to generate the image due to a UnicodeEncodeError, which most likely is because o...
https://stackoverflow.com/questions/78752527/how-to-visualize-random-forest-plot-using-graphviz-in-characters-outside-of-utf
python, plot, scikit-learn, ipython, random-forest
1,721,098,498
se_78745963
stackoverflow
MACHINE_LEARNING
I keep getting errors with my machine learning model
I keep getting errors with my machine learning model It's just a version of a model i made which predicts stocks, when I run it, it works fine, but returns errors with the output, note indentations were messed up but its self explanatory This is the code: import yfinance as yf from sklearn.linear_model import LinearRe...
https://stackoverflow.com/questions/78745963/i-keep-getting-errors-with-my-machine-learning-model
python, scikit-learn
1,720,947,647
se_78744294
stackoverflow
MACHINE_LEARNING
Scikit-Learn's feature_names_in Method
Scikit-Learn's feature_names_in Method A number of scikit-learn's classes have a feature_names_in method, which would be a real time saver if I could understand it better. Specifically, assume your X is a nested list of strings [['A', 'B', 'C'], ['A', 'B', 'D']] and your y is a list of labels ['Blue', 'Green']. ...
https://stackoverflow.com/questions/78744294/scikit-learns-feature-names-in-method
numpy, scikit-learn, tf-idf
1,720,885,212
se_78539430
stackoverflow
MACHINE_LEARNING
Nearest neighbor for list of arrays
Nearest neighbor for list of arrays `I have a list of arrays like this (in x, y coordinates): coordinates= array([[ 300, 2300], [ 670, 2360], [ 400, 2300]]), array([[1500, 1960], [1620, 2200], [1505, 1975]]), array([[ 980, 1965], [1060, 2240], [1100, 2250], [ 980, 1975]]), arr...
https://stackoverflow.com/questions/78539430/nearest-neighbor-for-list-of-arrays
python, arrays, numpy, scikit-learn, nearest-neighbor
1,716,817,314
se_78735242
stackoverflow
MACHINE_LEARNING
Cannot pip install scikit-learn, pkgutil and ImpImporter
Cannot pip install scikit-learn, pkgutil and ImpImporter I just went to Python 3.12.3. I cannot pip3 install scikit_learn==1.1.3. I get the following error: File "C:\Users\myuser\AppData\Local\Temp\pip-build-env-2zt7oob5\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module> register_fin...
https://stackoverflow.com/questions/78735242/cannot-pip-install-scikit-learn-pkgutil-and-impimporter
python, scikit-learn, pip
1,720,697,222
se_78737138
stackoverflow
MACHINE_LEARNING
sklearn importing standard scaler
sklearn importing standard scaler I imported standardscaler for a code: from sklearn.preprocessing import standardscaler It shows like cannot import name 'standardscaler' from 'sklearn.preprocessing' How to solve the error?
https://stackoverflow.com/questions/78737138/sklearn-importing-standard-scaler
python, scikit-learn
1,720,721,725
se_78609915
stackoverflow
MACHINE_LEARNING
How to set a lower priority for scikit-learn parallel processes spawned by n_jobs?
How to set a lower priority for scikit-learn parallel processes spawned by n_jobs? When using the n_jobs parameter to parallelize scikit-learn routines (like GridSeachCV), is there a way to set the parallel processes to a below-normal priority? Often I would like to take maximum advantage of parallelization while stil...
https://stackoverflow.com/questions/78609915/how-to-set-a-lower-priority-for-scikit-learn-parallel-processes-spawned-by-n-job
scikit-learn, parallel-processing, joblib, psutil
1,718,143,620
se_78738850
stackoverflow
MACHINE_LEARNING
Convert trained and pickled sklearn ColumnTransformer from sklearn 1.1.2 to 1.5.1
Convert trained and pickled sklearn ColumnTransformer from sklearn 1.1.2 to 1.5.1 I have a Scikit Learn ColumnTransformer containing a number of other transformers (passthrough, a custom transformer and a OneHotEncoder) that has been "trained" (transformer.fit() has been run on data) and stored in a Pickle file, creat...
https://stackoverflow.com/questions/78738850/convert-trained-and-pickled-sklearn-columntransformer-from-sklearn-1-1-2-to-1-5
python, scikit-learn, migration, pickle
1,720,765,003
se_67753454
stackoverflow
MACHINE_LEARNING
Sklearn ROC AUC Score : ValueError: y should be a 1d array, got an array of shape (15, 2) instead
Sklearn ROC AUC Score : ValueError: y should be a 1d array, got an array of shape (15, 2) instead I have this dataset with target LULUS, it's an imbalance dataset. I'm trying to print roc auc score if I could for each fold of my data but in every fold somehow it's always raise error saying ValueError: y should be a 1d...
https://stackoverflow.com/questions/67753454/sklearn-roc-auc-score-valueerror-y-should-be-a-1d-array-got-an-array-of-shap
python, scikit-learn
1,622,304,463
se_23687247
stackoverflow
MACHINE_LEARNING
Efficient k-means evaluation with silhouette score in sklearn
Efficient k-means evaluation with silhouette score in sklearn I am running k-means clustering on a dataset with around 1 million items and around 100 attributes. I applied clustering for various k, and I want to evaluate the different groupings with the silhouette score from sklearn library. Running it with no samplin...
https://stackoverflow.com/questions/23687247/efficient-k-means-evaluation-with-silhouette-score-in-sklearn
python, scikit-learn, cluster-analysis
1,400,182,867
se_78731369
stackoverflow
MACHINE_LEARNING
How to optimise hyperparameterss for RandomForestClassifier in Python for large datasets?
How to optimise hyperparameterss for RandomForestClassifier in Python for large datasets? I'm just working on this problem where I thought RandomForestClassifier from scikit-learn would be better solution for a large dataset. Only after trying with it for this, I found it to be not accurate. The model is either overfi...
https://stackoverflow.com/questions/78731369/how-to-optimise-hyperparameterss-for-randomforestclassifier-in-python-for-large
scikit-learn, dataset, data-science, random-forest
1,720,624,011
se_66440742
stackoverflow
MACHINE_LEARNING
Why do predict_proba and probA_ / probB_ not match in sklearn SVC?
Why do predict_proba and probA_ / probB_ not match in sklearn SVC? According to the SVC documentation: Platt scaling uses the logistic function 1 / (1 + exp(decision_value * probA_ + probB_)) where probA_ and probB_ are learned from the dataset. now, if I try a simple SVC example import numpy as np from sklearn.data...
https://stackoverflow.com/questions/66440742/why-do-predict-proba-and-proba-probb-not-match-in-sklearn-svc
python, scikit-learn, svm
1,614,693,138
se_78176260
stackoverflow
MACHINE_LEARNING
ModuleNotFoundError: No module named &#39;sklearn.ensemble._gb_losses&#39;
ModuleNotFoundError: No module named &#39;sklearn.ensemble._gb_losses&#39; i have install the scikit_learn and tried to install multiple version but not able to download not able to find answer for sklearn.ensemble._gb_losses from flask import Flask, render_template, request import pickle import numpy as np model = p...
https://stackoverflow.com/questions/78176260/modulenotfounderror-no-module-named-sklearn-ensemble-gb-losses
python, python-3.x, scikit-learn
1,710,696,878
se_78722250
stackoverflow
MACHINE_LEARNING
Scikit learn cross validation score negative value
Scikit learn cross validation score negative value I was trying to build a linear regression model to predict the price of houses to begin with machine learning but come accross negative values of score when using cross validation in this code: from sklearn.linear_model import LinearRegression from sklearn.model_selec...
https://stackoverflow.com/questions/78722250/scikit-learn-cross-validation-score-negative-value
python, machine-learning, scikit-learn, linear-regression
1,720,460,402
se_71311014
stackoverflow
MACHINE_LEARNING
ModuleNotFoundError: No module named &#39;sagemaker&#39;
ModuleNotFoundError: No module named &#39;sagemaker&#39; I am attempting to perform pre-processing using sklearn in sagemaker. As a pre-requisite I am trying to import sagemaker module: %pip install -qU 'sagemaker>=2.15.0' import boto3 import sagemaker but I get error as: An error was encountered: No module named 'sa...
https://stackoverflow.com/questions/71311014/modulenotfounderror-no-module-named-sagemaker
python, scikit-learn, amazon-sagemaker
1,646,149,226
se_78725061
stackoverflow
MACHINE_LEARNING
What does the attribute x_loadings_ represent?
What does the attribute x_loadings_ represent? I'm doing a canonical correlation analysis using scikit-learn's CCA. After doing the usual steps and calling ca.x_loadings_, I see that I get values bigger than 1. How I intepret the explanation of what the attribute x_loadings_ should represent however, this contradicts ...
https://stackoverflow.com/questions/78725061/what-does-the-attribute-x-loadings-represent
python, scikit-learn, statistics
1,720,520,956
se_59594653
stackoverflow
MACHINE_LEARNING
what does the gamma parameter in SVM.SVC() actually do
what does the gamma parameter in SVM.SVC() actually do I am trying to tune my SVM model which I built with different values of gamma and C. Also, I have used scaled input data for my model training. After trying with multiple combinations I did find a combination of gamma and C which gave the best accuracy,though w/o...
https://stackoverflow.com/questions/59594653/what-does-the-gamma-parameter-in-svm-svc-actually-do
machine-learning, scikit-learn, svm, data-science, svc
1,578,170,418
se_66432634
stackoverflow
MACHINE_LEARNING
sklearn.feature_selection.mutual_info_regression not found
sklearn.feature_selection.mutual_info_regression not found I have been trying to utilise mutual_info_regression method from sklearn, I have updated sklearn to latest build which is 0.24.1 and when I checked the source code inside my conda env path there is folder and files for feature_selection.mutual_info_regression,...
https://stackoverflow.com/questions/66432634/sklearn-feature-selection-mutual-info-regression-not-found
python, scikit-learn, pip, anaconda
1,614,653,558
se_78715879
stackoverflow
MACHINE_LEARNING
how to adjust cutoff in a logistic regression model?
how to adjust cutoff in a logistic regression model? example contrived for this question. I am training a binary classifier utilizing sklearn package. I have a balanced dataset, half positive and half negative samples. I split the train/test data (sample code below). I want to train this, such that I have good enough ...
https://stackoverflow.com/questions/78715879/how-to-adjust-cutoff-in-a-logistic-regression-model
python, scikit-learn
1,720,298,882
se_78692707
stackoverflow
MACHINE_LEARNING
ValueError: The filepath provided must end in `.keras` (Keras model format). Received: filepath=model/keypoint_classifier/keypoint_classifier.hdf5
ValueError: The filepath provided must end in `.keras` (Keras model format). Received: filepath=model/keypoint_classifier/keypoint_classifier.hdf5 PYTHON version : 3.12.4 PIP version : 24.1.1 KERAS version : 3.4.1 TENSORFLOW version : 2.16.1 i've been trying to run a code on jupyter notebook in order to train a model:...
https://stackoverflow.com/questions/78692707/valueerror-the-filepath-provided-must-end-in-keras-keras-model-format-rec
python, tensorflow, keras, scikit-learn, jupyter-notebook
1,719,843,082
se_40708077
stackoverflow
MACHINE_LEARNING
What is the difference between pipeline and make_pipeline in scikit-learn?
What is the difference between pipeline and make_pipeline in scikit-learn? I got this from the sklearn webpage: Pipeline: Pipeline of transforms with a final estimator Make_pipeline: Construct a Pipeline from the given estimators. This is a shorthand for the Pipeline constructor. But I still do not understand when...
https://stackoverflow.com/questions/40708077/what-is-the-difference-between-pipeline-and-make-pipeline-in-scikit-learn
python, machine-learning, scikit-learn, pipeline
1,479,668,176
se_78717924
stackoverflow
MACHINE_LEARNING
ValuerError: Found input variables with inconsistent numbers of samples
ValuerError: Found input variables with inconsistent numbers of samples I wrote the following code to learn the score in the machine learning methods. but I get the following error. what would be the reason?? ValueError: Found input variables with inconsistent numbers of samples: [6396, 1599] import pandas as pd impo...
https://stackoverflow.com/questions/78717924/valuererror-found-input-variables-with-inconsistent-numbers-of-samples
python, machine-learning, scikit-learn, linear-regression
1,720,372,143
se_54264452
stackoverflow
MACHINE_LEARNING
What value should we use for random_state in train_test_split() and in which scenario?
What value should we use for random_state in train_test_split() and in which scenario? X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=0) In above code, random_state is used 0. Why we are not using 1?
https://stackoverflow.com/questions/54264452/what-value-should-we-use-for-random-state-in-train-test-split-and-in-which-sce
python, machine-learning, scikit-learn
1,547,877,121
se_62263903
stackoverflow
MACHINE_LEARNING
How to decide the best pair of random_state value and class labels?
How to decide the best pair of random_state value and class labels? For the last few days, I was trying to implement the KMeans algorithm using SciKit Learn, But I came across a very confusing problem. I have a dataset that has two class labels ['ALL', 'AML'] where ALL has 47 and AML has 25 samples and 100 attributes ...
https://stackoverflow.com/questions/62263903/how-to-decide-the-best-pair-of-random-state-value-and-class-labels
python, scikit-learn, cluster-analysis, k-means
1,591,625,048
se_26097921
stackoverflow
MACHINE_LEARNING
Choosing random_state for sklearn algorithms
Choosing random_state for sklearn algorithms I understand that random_state is used in various sklearn algorithms to break tie between different predictors (trees) with same metric value (say for example in GradientBoosting). But the documentation does not clarify or detail on this. Like 1 ) where else are these see...
https://stackoverflow.com/questions/26097921/choosing-random-state-for-sklearn-algorithms
machine-learning, scikit-learn, random-forest
1,411,987,102
se_22117692
stackoverflow
MACHINE_LEARNING
Using ranking data in Logistic Regression
Using ranking data in Logistic Regression I am trying to use some ranking data in a logistic regression. I want to use machine learning to make a simple classifier as to whether a webpage is "good" or not. It's just a learning exercise so I don't expect great results; just hoping to learn the "process" and coding tech...
https://stackoverflow.com/questions/22117692/using-ranking-data-in-logistic-regression
python, algorithm, machine-learning, artificial-intelligence, scikit-learn
1,393,694,719
se_54060208
stackoverflow
MACHINE_LEARNING
Python K-Means clustering and maximum distance
Python K-Means clustering and maximum distance I would like to start by saying that my knowledge of clustering techniques is extremely limited, please don’t shoot me down too harshly. I have a sizable set of 3D points (around 8,000) - think of a X, Y, Z triplets, for which the Z coordinate represents a point in the e...
https://stackoverflow.com/questions/54060208/python-k-means-clustering-and-maximum-distance
python, scikit-learn, cluster-analysis
1,546,766,721
se_78705074
stackoverflow
MACHINE_LEARNING
Describing the data points with arc-shaped graph
Describing the data points with arc-shaped graph I would like to fit a graph that closely follow the characteristics of a scatterplot using Python. I have searched many curve-fitting techniques, and I have tried many different polynomial and linear regression approach powered by Scikit-Learn library. However, the best...
https://stackoverflow.com/questions/78705074/describing-the-data-points-with-arc-shaped-graph
python-3.x, math, scikit-learn, regression, curve-fitting
1,720,068,698
se_78690204
stackoverflow
MACHINE_LEARNING
How to Fix &quot;TypeError: getattr(): attribute name must be string&quot; when multiple optimizers are GridSearched for GaussianProcessRegressor?
How to Fix &quot;TypeError: getattr(): attribute name must be string&quot; when multiple optimizers are GridSearched for GaussianProcessRegressor? Here is my script to predict targets on the final date of a timeseries dataset. I am trying to incorporate a GaussianProcessRegressor model to find the best hyperparameters...
https://stackoverflow.com/questions/78690204/how-to-fix-typeerror-getattr-attribute-name-must-be-string-when-multiple-o
python, optimization, scikit-learn, kernel-density, gaussian-process
1,719,798,033
se_78706921
stackoverflow
MACHINE_LEARNING
Why does plotting errors vs actual via PredictionErrorDisplay result in a value error?
Why does plotting errors vs actual via PredictionErrorDisplay result in a value error? I have trained a random forest regression model using sklearn, and used it to make some predictions on a test dataset. Naturally there are errors where the values predicted by the model are not the same as the actual values; in this...
https://stackoverflow.com/questions/78706921/why-does-plotting-errors-vs-actual-via-predictionerrordisplay-result-in-a-value
python, matplotlib, scikit-learn
1,720,093,456
se_78707320
stackoverflow
MACHINE_LEARNING
sklearn machine learning to classify the rows of a excel sheet containing text, date and float columns, unsupervised
sklearn machine learning to classify the rows of a excel sheet containing text, date and float columns, unsupervised i am just starting with machine learning. I am trying to deal with simple examples. i have a *.csv file with columns containing text, numbers and dates. My goal, for learning purposes, is to classify th...
https://stackoverflow.com/questions/78707320/sklearn-machine-learning-to-classify-the-rows-of-a-excel-sheet-containing-text
csv, scikit-learn, unsupervised-learning
1,720,098,675
se_77462667
stackoverflow
MACHINE_LEARNING
reshape problem in LogisticRegression code
reshape problem in LogisticRegression code I try to make a LogisticRegression. import pandas import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression import numpy as np df = pd.read_csv("tested.csv") df.dropna(inplace=True) x = df["Age"] y = df["Survived"] x_re = x.values.reshape(-1, 1) reg...
https://stackoverflow.com/questions/77462667/reshape-problem-in-logisticregression-code
python, arrays, pandas, scikit-learn, reshape
1,699,647,576
se_74001472
stackoverflow
MACHINE_LEARNING
Pycaret setup for one hot encoding
Pycaret setup for one hot encoding I'm stuck in a problem with one hot encoding for categorical variables in Pycaret. The problem is that even setting my categorical variables, the pipeline apply normalization to categorical variables, and I have no idea what I'm doing wrong. At first, using the code below everything ...
https://stackoverflow.com/questions/74001472/pycaret-setup-for-one-hot-encoding
python, python-3.x, machine-learning, scikit-learn, pycaret
1,665,277,188
se_78699259
stackoverflow
MACHINE_LEARNING
Sklearn NMF match input category order
Sklearn NMF match input category order I'm using Non-Negative Matrix Factorization (NMF) in sklearn for unsupervised category prediction (with labels for checking accuracy), but am running into the problem where I don't have a clear map between input categories and transformed categories. For example, if my categories...
https://stackoverflow.com/questions/78699259/sklearn-nmf-match-input-category-order
python, scikit-learn, matrix-factorization
1,719,954,811
se_78698399
stackoverflow
MACHINE_LEARNING
Difference in My perceptron and sklearn Perceptron
Difference in My perceptron and sklearn Perceptron I coded the perceptron algorithm form scratch and compared the weights I obtained after training with the weights I obtained after training the sklearn perceptron model. I believe even the sklearn model initializes the weights and biases as a zero vector and I chose t...
https://stackoverflow.com/questions/78698399/difference-in-my-perceptron-and-sklearn-perceptron
python, machine-learning, scikit-learn, neural-network, perceptron
1,719,939,886
se_73071466
stackoverflow
MACHINE_LEARNING
Allow multi-scoring and return a list at the same time in sklearn cross_validate
Allow multi-scoring and return a list at the same time in sklearn cross_validate I want to return multiple-scoring and, at the same time, the probabilities scores of each prediction to build the ROC curve. The problem is that I can't return something different to a number because the error "scoring must return a numbe...
https://stackoverflow.com/questions/73071466/allow-multi-scoring-and-return-a-list-at-the-same-time-in-sklearn-cross-validate
python, scikit-learn, pipeline, cross-validation
1,658,430,287
se_78697544
stackoverflow
MACHINE_LEARNING
Kmean get good group separation
Kmean get good group separation I have a basic code for use Kmeans with sklearn scaled = MinMaxScaler().fit_transform(points) kmeans = KMeans(n_clusters=nb_clusters) # , random_state=42 , init='random', algorithm='elkan' kmeans.fit(scaled) labels = kmeans.labels_ centroids = kmeans.cluster_centers...
https://stackoverflow.com/questions/78697544/kmean-get-good-group-separation
python, scikit-learn, k-means
1,719,928,760
se_50392783
stackoverflow
MACHINE_LEARNING
Training Linear Models with MAE using sklearn in Python
Training Linear Models with MAE using sklearn in Python I'm currently trying to train a linear model using sklearn in python but not with mean squared error (MSE) as error measure - but with mean absolute error (MAE). I specificially need a linear model with MAE as requirement from my professor at university. I've lo...
https://stackoverflow.com/questions/50392783/training-linear-models-with-mae-using-sklearn-in-python
python, scikit-learn, data-science
1,526,563,902
se_49188159
stackoverflow
MACHINE_LEARNING
How to create a custom Kernel for a Gaussian Process Regressor in scikit-learn?
How to create a custom Kernel for a Gaussian Process Regressor in scikit-learn? I am looking into using a GPR for a rather peculiar context, where I need to write my own Kernel. However I found out there's no documentation about how to do this. Trying to simply inherit from Kernel and implementing the methods __call__...
https://stackoverflow.com/questions/49188159/how-to-create-a-custom-kernel-for-a-gaussian-process-regressor-in-scikit-learn
scikit-learn
1,520,528,461
se_78689386
stackoverflow
MACHINE_LEARNING
AttributeError: &#39;MLPClassifier&#39; object has no attribute &#39;best_validation_score_&#39;
AttributeError: &#39;MLPClassifier&#39; object has no attribute &#39;best_validation_score_&#39; When fitting an MLP neural network with scikit-learn's MLPCLassifier to the dataset iris this super-classic way: import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn impo...
https://stackoverflow.com/questions/78689386/attributeerror-mlpclassifier-object-has-no-attribute-best-validation-score
python, scikit-learn, mlp
1,719,770,262
se_78685188
stackoverflow
MACHINE_LEARNING
How to resolve TypeError: &#39;numpy.float64&#39; object is not callable when calculating r2_score?
How to resolve TypeError: &#39;numpy.float64&#39; object is not callable when calculating r2_score? I am encountering the following error: TypeError: 'numpy.float64' object is not callable when I try to calculate the R2 score using scikit-learn's r2_score function. Below is the relevant portion of my code: from sklea...
https://stackoverflow.com/questions/78685188/how-to-resolve-typeerror-numpy-float64-object-is-not-callable-when-calculatin
python, scikit-learn, regression, data-science
1,719,640,960
se_30317119
stackoverflow
MACHINE_LEARNING
classifiers in scikit-learn that handle nan/null
classifiers in scikit-learn that handle nan/null I was wondering if there are classifiers that handle nan/null values in scikit-learn. I thought random forest regressor handles this but I got an error when I call predict. X_train = np.array([[1, np.nan, 3],[np.nan, 5, 6]]) y_train = np.array([1, 2]) clf = RandomFore...
https://stackoverflow.com/questions/30317119/classifiers-in-scikit-learn-that-handle-nan-null
python, pandas, machine-learning, scikit-learn, nan
1,432,011,755
se_78687908
stackoverflow
MACHINE_LEARNING
how can i make my sklearn prediction model better?
how can i make my sklearn prediction model better? So basically, I have this model in sklearn that predicts the survival rate of titanic. its accuracy is around 0.77. How can I make it better and more accurate? import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler, LabelEncoder, MinMa...
https://stackoverflow.com/questions/78687908/how-can-i-make-my-sklearn-prediction-model-better
python, pandas, algorithm, scikit-learn
1,719,732,225
se_78687487
stackoverflow
MACHINE_LEARNING
scikit-learn: ValueError: Input contains NaN, infinity or a value too large for dtype(&#39;float64&#39;) while predicting with GP
scikit-learn: ValueError: Input contains NaN, infinity or a value too large for dtype(&#39;float64&#39;) while predicting with GP I've been using scikit-learn for Gaussian process regressors for a while, working with adaptively constructed models where the existing GP is used to select new datapoints for the GP. Recen...
https://stackoverflow.com/questions/78687487/scikit-learn-valueerror-input-contains-nan-infinity-or-a-value-too-large-for
python, numpy, scikit-learn, nan, gaussian-process
1,719,712,901
se_78686328
stackoverflow
MACHINE_LEARNING
Why do the sensitivity (recall) values differ between classification_report and precision_recall_fscore_support in a loop?
Why do the sensitivity (recall) values differ between classification_report and precision_recall_fscore_support in a loop? I am working with a synthetic dataset generated using make_classification from sklearn.datasets with 5 classes. I have trained a RandomForestClassifier on this data and am evaluating its performan...
https://stackoverflow.com/questions/78686328/why-do-the-sensitivity-recall-values-differ-between-classification-report-and
python, machine-learning, scikit-learn, classification, evaluation
1,719,673,055
se_78676517
stackoverflow
MACHINE_LEARNING
Unexpected coefficient behaviour of sklearn Lasso for small alpha values
Unexpected coefficient behaviour of sklearn Lasso for small alpha values Here is some basic code generating a regression problem. import numpy as np import pandas as pd from sklearn.linear_model import Lasso, LinearRegression n = 100 np.random.seed(42) X = np.random.normal(size=n) eps = np.random.normal(size=n) b_0,...
https://stackoverflow.com/questions/78676517/unexpected-coefficient-behaviour-of-sklearn-lasso-for-small-alpha-values
python, scikit-learn, linear-regression, lasso-regression, regularized
1,719,477,935
se_67290933
stackoverflow
MACHINE_LEARNING
How can I do a stratified downsampling?
How can I do a stratified downsampling? I need to build a classification model for protein sequences using machine learning techniques. Each observation can either be classified as either a 0 or a 1. However, I noticed that my training set contains a total of 170 000 observations, of which only 5000 are labeled as 1. ...
https://stackoverflow.com/questions/67290933/how-can-i-do-a-stratified-downsampling
machine-learning, scikit-learn, downsampling
1,619,559,085
se_42193893
stackoverflow
MACHINE_LEARNING
SelectKBest with GaussianNB not precise/consistent results
SelectKBest with GaussianNB not precise/consistent results I want to select top K features using SelectKBest and run GaussianNB: selection = SelectKBest(mutual_info_classif, k=300) data_transformed = selection.fit_transform(data, labels) new_data_transformed = selection.transform(new_data) classifier = GaussianNB()...
https://stackoverflow.com/questions/42193893/selectkbest-with-gaussiannb-not-precise-consistent-results
python, machine-learning, scikit-learn, feature-extraction, feature-selection
1,486,937,489
se_47793569
stackoverflow
MACHINE_LEARNING
Choosing top k models using GridSearchCV in scikit-learn
Choosing top k models using GridSearchCV in scikit-learn Is there an easy/pre-existing way to perform a Grid Search in scikit-learn and then automatically return the top k best performing models or automatically average their outputs? I intend to try and reduce overfitting this way. I have not yet found anything relat...
https://stackoverflow.com/questions/47793569/choosing-top-k-models-using-gridsearchcv-in-scikit-learn
python, machine-learning, scikit-learn
1,513,169,718
se_59493873
stackoverflow
MACHINE_LEARNING
Cannot cast array data from dtype(&#39;float64&#39;) to dtype(&#39;int32&#39;) according to &#39;safe&#39;
Cannot cast array data from dtype(&#39;float64&#39;) to dtype(&#39;int32&#39;) according to &#39;safe&#39; I've got a dataset with 6 columns 'Weight'(float), 'Gender'(0 or 1 (int)), 'Height'(float), 'Metabolism'(0,1,2,3 (int)), 'Psychology'(0,1,2,3,4,5,6 (int)) and the column we have to predict is 'Age'(int). I have t...
https://stackoverflow.com/questions/59493873/cannot-cast-array-data-from-dtypefloat64-to-dtypeint32-according-to-saf
python, pandas, numpy, scikit-learn
1,577,397,494
se_41804937
stackoverflow
MACHINE_LEARNING
decreasing accuracy of scikit learn classifier after initializing weight
decreasing accuracy of scikit learn classifier after initializing weight I want to implement adaboost classifier base on sklearn classifier, in first step of alg classifier I should initialize weight to " 1 / # train data " but it will decrease the accuracy of classifier, I can't figured it out why? (I set the same we...
https://stackoverflow.com/questions/41804937/decreasing-accuracy-of-scikit-learn-classifier-after-initializing-weight
python, machine-learning, scikit-learn, pattern-recognition, adaboost
1,485,169,761
se_78655385
stackoverflow
MACHINE_LEARNING
The DiffPrivLib version of Decision Tree is giving me the wrong accuracy
The DiffPrivLib version of Decision Tree is giving me the wrong accuracy IBM specifically designed their differential privacy library, DiffPrivLib, to work exactly like scikitlearn for ease of use. The tutorials on their github site state that if using epsilon = infinity (and, presumably, the same random state) with D...
https://stackoverflow.com/questions/78655385/the-diffprivlib-version-of-decision-tree-is-giving-me-the-wrong-accuracy
python, scikit-learn, decisiontreeclassifier
1,719,041,557
se_36997619
stackoverflow
MACHINE_LEARNING
sklearn stratified sampling based on a column
sklearn stratified sampling based on a column I have a fairly large CSV file containing amazon review data which I read into a pandas data frame. I want to split the data 80-20(train-test) but while doing so I want to ensure that the split data is proportionally representing the values of one column (Categories), i.e ...
https://stackoverflow.com/questions/36997619/sklearn-stratified-sampling-based-on-a-column
python, pandas, scikit-learn, sklearn-pandas
1,462,258,577
se_78671295
stackoverflow
MACHINE_LEARNING
ElasticNetCV in Python: Get full grid of hyperparameters with corresponding MSE?
ElasticNetCV in Python: Get full grid of hyperparameters with corresponding MSE? I have fitted a ElasticNetCV in Python with three splits: import numpy as np from sklearn.linear_model import LinearRegression #Sample data: num_samples = 100 # Number of samples num_features = 1000 # Number of features X = np.random....
https://stackoverflow.com/questions/78671295/elasticnetcv-in-python-get-full-grid-of-hyperparameters-with-corresponding-mse
python, machine-learning, scikit-learn, sklearn-pandas
1,719,391,791
se_25752444
stackoverflow
MACHINE_LEARNING
Scipy error: numpy.dtype size changed, may indicate binary incompatibility (and associated strange behavior)
Scipy error: numpy.dtype size changed, may indicate binary incompatibility (and associated strange behavior) I am installing numpy/scipy/scikit-learn on OS X 10.9.4, and am getting errors about "numpy.dtype size changed, may indicate binary incompatibility". Here's what I did to construct the repo: mkvirtualenv thm ...
https://stackoverflow.com/questions/25752444/scipy-error-numpy-dtype-size-changed-may-indicate-binary-incompatibility-and
python, macos, numpy, scipy, scikit-learn
1,410,291,946
se_40485285
stackoverflow
MACHINE_LEARNING
Retrieve list of training features names from classifier
Retrieve list of training features names from classifier Is there a way to retrieve the list of feature names used for training of a classifier, once it has been trained with the fit method? I would like to get this information before applying to unseen data. The data used for training is a pandas DataFrame and in my ...
https://stackoverflow.com/questions/40485285/retrieve-list-of-training-features-names-from-classifier
python, pandas, scikit-learn, random-forest
1,478,603,185
se_78650882
stackoverflow
MACHINE_LEARNING
GridSearchCV runs smoothly when scoring=&#39;accuracy&#39;, but not when scoring=accuracy_score
GridSearchCV runs smoothly when scoring=&#39;accuracy&#39;, but not when scoring=accuracy_score When I run the following piece of code in a Jupyter notebook inside Visual Studio Code, it runs smoothly. from sklearn.datasets import load_iris from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import...
https://stackoverflow.com/questions/78650882/gridsearchcv-runs-smoothly-when-scoring-accuracy-but-not-when-scoring-accurac
python, scikit-learn, gridsearchcv
1,718,953,493
se_66060487
stackoverflow
MACHINE_LEARNING
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject Importing from pyxdameraulevenshtein gives the following error, I have pyxdameraulevenshtein==1.5.3 pandas==1.1.4 scikit-learn==0.20.2. Numpy is 1.16.1. Works well in Python 3.6, Issue in Pyth...
https://stackoverflow.com/questions/66060487/valueerror-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-exp
python, pandas, numpy, scikit-learn, python-3.7
1,612,516,308
se_41939144
stackoverflow
MACHINE_LEARNING
GridSearchCV does not give the same results as expected when compared to xgboost.cv
GridSearchCV does not give the same results as expected when compared to xgboost.cv when comparing sklearn.GridSearchCV with xgboost.cv I get different results... below I explain what I would like to do: import libraries import numpy as np from sklearn import datasets import xgboost as xgb from sklea...
https://stackoverflow.com/questions/41939144/gridsearchcv-does-not-give-the-same-results-as-expected-when-compared-to-xgboost
python, scikit-learn, xgboost, grid-search
1,485,788,840
se_78655668
stackoverflow
MACHINE_LEARNING
The features selected by SelectKBest do not match those transformed by ColumnTransformer
The features selected by SelectKBest do not match those transformed by ColumnTransformer I am in the process of deploying a machine learning model for study purposes and I have some questions about it: My POST method will send to the API my original features (without transformations applied) untransformed data I'm ...
https://stackoverflow.com/questions/78655668/the-features-selected-by-selectkbest-do-not-match-those-transformed-by-columntra
python, machine-learning, scikit-learn, pipeline, mlops
1,719,049,645
se_78653994
stackoverflow
MACHINE_LEARNING
Polynomial Multivariate Regression Analysis 2
Polynomial Multivariate Regression Analysis 2 I'm new to regression analysis in python and greatly appreciate your help: I have a formula (Y = x1 + Ax1^2 + Bx2^2 + Cx3^2 + Constant), and a dataset to train the model. The dataset includes a column for each Y, x1, x2, x3, and the Month. See example dataset here I'd like...
https://stackoverflow.com/questions/78653994/polynomial-multivariate-regression-analysis-2
python, scikit-learn, regression
1,718,995,267
se_78649151
stackoverflow
MACHINE_LEARNING
Polynomial Multivariate Regression Setup
Polynomial Multivariate Regression Setup I have a formula (Y = x1 + Ax1^2 + Bx2^2 + Cx3^2 + Constant), and a dataset to train the model. The dataset includes a column for each Y, x1, x2, x3, and the Month. I'd like the regression analysis to run 12 times, once for each Month - such that I'll be able to see a table of ...
https://stackoverflow.com/questions/78649151/polynomial-multivariate-regression-setup
python, scikit-learn, regression
1,718,909,327
se_67585809
stackoverflow
MACHINE_LEARNING
How to map the results of Principal Component Analysis back to the actual features that were fed into the model?
How to map the results of Principal Component Analysis back to the actual features that were fed into the model? When I run the code below, I see the 'pca.explained_variance_ratio_' and a histogram, which shows the proportion of variance explained for each feature. import statsmodels.api as sm import numpy as np impor...
https://stackoverflow.com/questions/67585809/how-to-map-the-results-of-principal-component-analysis-back-to-the-actual-featur
python, machine-learning, scikit-learn, pca
1,621,339,465
se_29528628
stackoverflow
MACHINE_LEARNING
How to specify a variable in pandas as ordinal/categorical?
How to specify a variable in pandas as ordinal/categorical? I am trying to run some Machine learning algo on a dataset using scikit-learn. My dataset has some features which are like categories. Like one feature is A, which has values 1,2,3 specifying the quality of something. 1:Upper, 2: Second, 3: Third class. So it...
https://stackoverflow.com/questions/29528628/how-to-specify-a-variable-in-pandas-as-ordinal-categorical
python, pandas, scikit-learn, categorical-data, nominal-data
1,428,545,885
se_78545402
stackoverflow
MACHINE_LEARNING
Confused with Isolation Forest
Confused with Isolation Forest Let say, I have the anomaly detection (unsupervised learning) dataset with 10 observations (two features). The datasets is like below: After executing the model, following are the results (anomalies scores): The observations which have score as -1 are anomalies. I have a question about...
https://stackoverflow.com/questions/78545402/confused-with-isolation-forest
scikit-learn, outliers, anomaly-detection, isolation-forest
1,716,913,932
se_78649554
stackoverflow
MACHINE_LEARNING
Decision Tree Regressor Output
Decision Tree Regressor Output I have a very simple dataset of employee age and years of experience as features and income as label. The ask is to predict the income level using various regressors and I am using 4: Decision Trees (DT), Random Forest (RF), K-Nearest Neighbor (KNN) and Linear Regression (LR). The follow...
https://stackoverflow.com/questions/78649554/decision-tree-regressor-output
machine-learning, scikit-learn, regression, decision-tree
1,718,917,154
se_78647145
stackoverflow
MACHINE_LEARNING
Inconsistent covariance estimates from sklearn.covariance.MinCovDet vs numpy.cov
Inconsistent covariance estimates from sklearn.covariance.MinCovDet vs numpy.cov I would expect that when considering a large sample from a bivariate Gaussian population, covariance estimates from sklearn.covariance.MinCovDet should be equivalent to those from numpy.cov ? Yet when I test this using the following code,...
https://stackoverflow.com/questions/78647145/inconsistent-covariance-estimates-from-sklearn-covariance-mincovdet-vs-numpy-cov
python, scikit-learn
1,718,882,356
se_78461828
stackoverflow
MACHINE_LEARNING
Is it possible to train a neural network to feed into a Random Forest Classifier or any other type of classifier like XGBoost or Decision Tree?
Is it possible to train a neural network to feed into a Random Forest Classifier or any other type of classifier like XGBoost or Decision Tree? I want to create a model architecture to predict future stock price movement as such: The Goal of this model is to predict if the price will go UP or DOWN within the next 3 m...
https://stackoverflow.com/questions/78461828/is-it-possible-to-train-a-neural-network-to-feed-into-a-random-forest-classifier
python, machine-learning, keras, scikit-learn, deep-learning
1,715,363,616
se_64433329
stackoverflow
MACHINE_LEARNING
cannot import name &#39;parse_version&#39; from &#39;sklearn.utils.fixes&#39;
cannot import name &#39;parse_version&#39; from &#39;sklearn.utils.fixes&#39; I am having serious problems with sklearn. In particular, when doing: from sklearn.linear_model import LinearRegression I get the following error: --------------------------------------------------------------------------- ImportError ...
https://stackoverflow.com/questions/64433329/cannot-import-name-parse-version-from-sklearn-utils-fixes
python, scikit-learn
1,603,132,798
se_46873381
stackoverflow
MACHINE_LEARNING
How to handle categorical features in neural network?
How to handle categorical features in neural network? I am currently having a dataset for the location of stores and name of item to predict sales of a particular product. I wanted to use binary encoding or pandas get_dummies(), but there are 5000 names for items and it causes memory error, is there any alternative o...
https://stackoverflow.com/questions/46873381/how-to-handle-categorical-features-in-neural-network
pandas, numpy, scikit-learn, neural-network
1,508,670,673
se_43162506
stackoverflow
MACHINE_LEARNING
UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples
UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples I'm getting this weird error: classification.py:1113: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for)` but the...
https://stackoverflow.com/questions/43162506/undefinedmetricwarning-f-score-is-ill-defined-and-being-set-to-0-0-in-labels-wi
python, scikit-learn
1,491,084,341
se_58663739
stackoverflow
MACHINE_LEARNING
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample While I am predicting the one sample from my data, it gives reshape error but my model has equal number of rows. Here is my code: import pandas as pd from sklearn.linear_model im...
https://stackoverflow.com/questions/58663739/reshape-your-data-either-using-array-reshape-1-1-if-your-data-has-a-single-fe
python, python-3.x, machine-learning, scikit-learn, linear-regression
1,572,630,976
se_60321389
stackoverflow
MACHINE_LEARNING
sklearn ImportError: cannot import name plot_roc_curve
sklearn ImportError: cannot import name plot_roc_curve I am trying to plot a Receiver Operating Characteristics (ROC) curve with cross validation, following the example provided in sklearn's documentation. However, the following import gives an ImportError, in both python2 and python3. from sklearn.metrics import plo...
https://stackoverflow.com/questions/60321389/sklearn-importerror-cannot-import-name-plot-roc-curve
python, machine-learning, scikit-learn, roc
1,582,206,281
se_78625589
stackoverflow
MACHINE_LEARNING
How to implement hierarchical clustering in Python with scikit-learn for unlabeled data?
How to implement hierarchical clustering in Python with scikit-learn for unlabeled data? I'm learning clustering and had some problems trying to find databases with data labeled to work with, this was a limitation for me because I found very interesting unlabeled data sets. I have read about various unsupervised clust...
https://stackoverflow.com/questions/78625589/how-to-implement-hierarchical-clustering-in-python-with-scikit-learn-for-unlabel
python, machine-learning, scikit-learn, cluster-analysis, unsupervised-learning
1,718,424,239
se_78641097
stackoverflow
MACHINE_LEARNING
sklearn LeaveOneOut with cross_validate/GridSearchCV: how can I use confusion matrix-based scores as the custom scoring functions?
sklearn LeaveOneOut with cross_validate/GridSearchCV: how can I use confusion matrix-based scores as the custom scoring functions? I’m using LeaveOneOut from sklearn, along with GridSesrchCV and cross_validate. I’m working on a medical problem so I’m interested in finding sensitivity and specificity. However, because ...
https://stackoverflow.com/questions/78641097/sklearn-leaveoneout-with-cross-validate-gridsearchcv-how-can-i-use-confusion-ma
scikit-learn, cross-validation, grid-search, gridsearchcv, leave-one-out
1,718,782,814
se_48239242
stackoverflow
MACHINE_LEARNING
Why is Random Forest with a single tree much better than a Decision Tree classifier?
Why is Random Forest with a single tree much better than a Decision Tree classifier? I apply the decision tree classifier and the random forest classifier to my data with the following code: def decision_tree(train_X, train_Y, test_X, test_Y): clf = tree.DecisionTreeClassifier() clf.fit(train_X, train_Y) ...
https://stackoverflow.com/questions/48239242/why-is-random-forest-with-a-single-tree-much-better-than-a-decision-tree-classif
python, machine-learning, scikit-learn, random-forest, decision-tree
1,515,841,479
se_78630417
stackoverflow
MACHINE_LEARNING
Evaluating scikit-learn metrics in Keras
Evaluating scikit-learn metrics in Keras I want to evaluate 3 metrics in a Keras model using scikit-learn metrics like this: from sklearn.metrics import coverage_error def coverage(Y_train, y_score): err = coverage_error(Y_train.numpy(), y_score.numpy()) return tf.convert_to_tensor(err) I encounter the error:...
https://stackoverflow.com/questions/78630417/evaluating-scikit-learn-metrics-in-keras
keras, scikit-learn, gpu, metrics, tf.keras
1,718,577,740
se_78633851
stackoverflow
MACHINE_LEARNING
Pytorch DataLoader index out of bounds
Pytorch DataLoader index out of bounds I have a dataset with high class imbalance. So to create proper training and testing sets, I have decided to use StratifiedShuffleSplit and a weighted sampler to improve training. dataset = ImageFolder(root='/path/to/directory', transform=transform) #stratified split ss = Strat...
https://stackoverflow.com/questions/78633851/pytorch-dataloader-index-out-of-bounds
python, scikit-learn, pytorch, pytorch-dataloader
1,718,643,845
se_59573235
stackoverflow
MACHINE_LEARNING
NameError: name &#39;predictions&#39; is not defined
NameError: name &#39;predictions&#39; is not defined i am running the below code and getting this error. Please help: Error: NameError: name 'predictions' is not defined Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.metric...
https://stackoverflow.com/questions/59573235/nameerror-name-predictions-is-not-defined
python, scikit-learn, linear-regression
1,577,990,542
se_63060367
stackoverflow
MACHINE_LEARNING
XGBoost get feature importance as a list of columns instead of plot
XGBoost get feature importance as a list of columns instead of plot I am wondering if you we can get the feature importance as a list of columns instead of a plot. This is what I have xg_reg = xgb.train(params=params, dtrain=data_dmatrix, num_boost_round=10) import matplotlib.pyplot as plt xgb.plot_importance(xg_reg)...
https://stackoverflow.com/questions/63060367/xgboost-get-feature-importance-as-a-list-of-columns-instead-of-plot
machine-learning, scikit-learn, xgboost
1,595,527,051