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_78619966 | stackoverflow | MACHINE_LEARNING | The same XGBClassifier model trained in different python environment made noticeably different predictions | The same XGBClassifier model trained in different python environment made noticeably different predictions
I tried to transfer an XGBClassifier model trained in old python environment to a new environment.
Below are the version info for key packages in old and new environments.
Old environment
python=3.6.0
scikit-lea... | https://stackoverflow.com/questions/78619966/the-same-xgbclassifier-model-trained-in-different-python-environment-made-notice | python, machine-learning, scikit-learn, xgboost, xgbclassifier | 1,718,309,238 |
se_78623778 | stackoverflow | MACHINE_LEARNING | Is Additional Bootstrapping Useful Before Training a Random Forest? | Is Additional Bootstrapping Useful Before Training a Random Forest?
I am reviewing a codebase that uses a Random Forest (RF) Regressor, and I've noticed that bootstrapping is applied before creating each RF model. However, RF inherently uses bootstrapping to train each Decision Tree (DT).
Does it make sense and is it ... | https://stackoverflow.com/questions/78623778/is-additional-bootstrapping-useful-before-training-a-random-forest | python, machine-learning, scikit-learn, random-forest | 1,718,378,111 |
se_77898119 | stackoverflow | MACHINE_LEARNING | how to properly incorporate early stopping validation in sklearn Pipeline with ColumnTransformer | how to properly incorporate early stopping validation in sklearn Pipeline with ColumnTransformer
I want to setup a lightGBM model with early stop validation. I also want to follow the best practice of using Pipeline to combine preprocessing and model fitting and prediction. Code below:
coltransformer = ColumnTransform... | https://stackoverflow.com/questions/77898119/how-to-properly-incorporate-early-stopping-validation-in-sklearn-pipeline-with-c | python, scikit-learn, pipeline | 1,706,514,604 |
se_72338941 | stackoverflow | MACHINE_LEARNING | Multiclass classification per class recall equals per class accuracy? | Multiclass classification per class recall equals per class accuracy?
I've got a multiclass problem. I'm using sklearn.metrics to calculate the confusion matrix, overall accuracy, per class precision, per class recall and per class F1-score.
Now I wanted to calculate the per class accuracy. Since there is no method in... | https://stackoverflow.com/questions/72338941/multiclass-classification-per-class-recall-equals-per-class-accuracy | scikit-learn | 1,653,233,413 |
se_78571485 | stackoverflow | MACHINE_LEARNING | ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 247, 15), found shape=(None, 15) | ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 247, 15), found shape=(None, 15)
This is my code
import pandas as pd
import tensorflow as tf
from sklearn.model_selection import train_test_split
dataset = pd.read_csv('/content/survey lung cancer.csv')
x = datas... | https://stackoverflow.com/questions/78571485/valueerror-input-0-of-layer-sequential-is-incompatible-with-the-layer-expect | python, keras, scikit-learn, tf.keras | 1,717,431,530 |
se_78610040 | stackoverflow | MACHINE_LEARNING | sklearn OneHotEncoder - create new dataframe with certain rows that have value = 1 | sklearn OneHotEncoder - create new dataframe with certain rows that have value = 1
I have a dataframe with 20 columns and 10000 rows. I applied OneHotEncoder (drop='first') to the entire dataframe which gave me 79 columns. I am trying to grab specific rows and create a new dataframe from these new rows by doing:
df_ne... | https://stackoverflow.com/questions/78610040/sklearn-onehotencoder-create-new-dataframe-with-certain-rows-that-have-value | python, scikit-learn, one-hot-encoding | 1,718,147,202 |
se_67266153 | stackoverflow | MACHINE_LEARNING | how to convert generated data into pandas dataframe | how to convert generated data into pandas dataframe
from sklearn.datasets import make_classification
df = make_classification(n_samples=10000, n_features=9, n_classes=1, random_state = 18,
class_sep=2, n_informative=4)
after creating the data. it is tuple and after conver... | https://stackoverflow.com/questions/67266153/how-to-convert-generated-data-into-pandas-dataframe | python, pandas, dataframe, machine-learning, scikit-learn | 1,619,438,064 |
se_78606850 | stackoverflow | MACHINE_LEARNING | Issues running LinearRegression() from scikit-learn on multiple cores | Issues running LinearRegression() from scikit-learn on multiple cores
I want to run LinearRegression() from sklearn library on 5 cores. As the documentation says that the n_jobs parameter does not cause multiprocessing unless n_targets > 1, I created random data with two y values and attempted to run the program. How... | https://stackoverflow.com/questions/78606850/issues-running-linearregression-from-scikit-learn-on-multiple-cores | python, scikit-learn, multiprocessing, linear-regression, joblib | 1,718,101,168 |
se_78611893 | stackoverflow | MACHINE_LEARNING | Drawing hierarchical clustering in scikit-learn | Drawing hierarchical clustering in scikit-learn
I have an embedding matrix of shape (4312, 1024) (corresponding to 1024-dimensional embedding vectors of 4312 English sentences). I want to perform a clustering of these vectors and to visualize the results (in order to see if the distance threshold that I chose was good... | https://stackoverflow.com/questions/78611893/drawing-hierarchical-clustering-in-scikit-learn | python, scikit-learn, scipy | 1,718,186,050 |
se_78610497 | stackoverflow | MACHINE_LEARNING | Which hyperparameters should I adjust to improve accuracy? | Which hyperparameters should I adjust to improve accuracy?
I would like to know how to increase the accuracy score and lower the loss in a multilabel classification problem.
If you look at the sklearn reference, there is a mention of multilabel in Multiclass and multioutput algorithms and I am testing it now.
(https:/... | https://stackoverflow.com/questions/78610497/which-hyperparameters-should-i-adjust-to-improve-accuracy | machine-learning, scikit-learn, multilabel-classification | 1,718,162,687 |
se_78608874 | stackoverflow | MACHINE_LEARNING | How to write a FunctionTransformer that outputs a DataFrame with a different number of columns than of the input DataFrame? | How to write a FunctionTransformer that outputs a DataFrame with a different number of columns than of the input DataFrame?
Is it possible to use FunctionTransformer to emulate OneHotEncoder? More generally, is it possible to write a FunctionTransformer such that the number of columns in the output DataFrame is differ... | https://stackoverflow.com/questions/78608874/how-to-write-a-functiontransformer-that-outputs-a-dataframe-with-a-different-num | python, scikit-learn | 1,718,125,012 |
se_78592454 | stackoverflow | MACHINE_LEARNING | How does gbrt_minimize from scikit decide how many parameter splits to try | How does gbrt_minimize from scikit decide how many parameter splits to try
From my understanding of https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html and gradient boosting decision trees in general, I assume that for N parameters, the regressor picks a bunch of splits al... | https://stackoverflow.com/questions/78592454/how-does-gbrt-minimize-from-scikit-decide-how-many-parameter-splits-to-try | machine-learning, scikit-learn, boosting, scikit-optimize | 1,717,769,642 |
se_36966019 | stackoverflow | MACHINE_LEARNING | How areTF-IDF calculated by the scikit-learn TfidfVectorizer | How areTF-IDF calculated by the scikit-learn TfidfVectorizer
I run the following code to convert the text matrix to TF-IDF matrix.
text = ['This is a string','This is another string','TFIDF computation calculation','TfIDF is the product of TF and IDF']
from sklearn.feature_extraction.text import TfidfVectorizer
vecto... | https://stackoverflow.com/questions/36966019/how-aretf-idf-calculated-by-the-scikit-learn-tfidfvectorizer | nlp, scikit-learn, tf-idf | 1,462,101,384 |
se_39163354 | stackoverflow | MACHINE_LEARNING | Evaluating Logistic regression with cross validation | Evaluating Logistic regression with cross validation
I would like to use cross validation to test/train my dataset and evaluate the performance of the logistic regression model on the entire dataset and not only on the test set (e.g. 25%).
These concepts are totally new to me and am not very sure if am doing it righ... | https://stackoverflow.com/questions/39163354/evaluating-logistic-regression-with-cross-validation | python, scikit-learn, logistic-regression, cross-validation | 1,472,204,812 |
se_78003515 | stackoverflow | MACHINE_LEARNING | Finding rectangle vertices from a parametrized plane | Finding rectangle vertices from a parametrized plane
I have a set of points from an .xyz file and I need to parametrize the vertices of an identified plane. I tried using the Convex Hull function but that only returned the perimeter.
My code starts like this:
#importing data
data = np.loadtxt("Asm.xyz", dtype=float, c... | https://stackoverflow.com/questions/78003515/finding-rectangle-vertices-from-a-parametrized-plane | python, scikit-learn, jupyter-notebook, convex-hull | 1,708,025,708 |
se_44889508 | stackoverflow | MACHINE_LEARNING | Remove highly correlated columns from a pandas dataframe | Remove highly correlated columns from a pandas dataframe
I have a dataframe name data whose correlation matrix I computed by using
corr = data.corr()
If the correlation between two columns is greater than 0.75, I want to remove one of them from dataframe data. I tried some option
raw =corr[(corr.abs()>0.75) & (corr.a... | https://stackoverflow.com/questions/44889508/remove-highly-correlated-columns-from-a-pandas-dataframe | python, r, pandas, machine-learning, scikit-learn | 1,499,096,365 |
se_31324218 | stackoverflow | MACHINE_LEARNING | Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative | Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative
My problem:
I have a dataset which is a large JSON file. I read it and store it in the trainList variable.
Next, I pre-process it - in order to be able to work with it.
Once I have done that I start the classification:
I u... | https://stackoverflow.com/questions/31324218/scikit-learn-how-to-obtain-true-positive-true-negative-false-positive-and-fal | python, machine-learning, scikit-learn, classification, supervised-learning | 1,436,462,342 |
se_78581162 | stackoverflow | MACHINE_LEARNING | Python Kmeans consistently label clusters | Python Kmeans consistently label clusters
I have a high dimension variable dataset which I want to classify into different groups. The data within can be confidently classified into 5 distinct groups.
I want to use the result of this clusterization process to create visual charts showcasing the difference within the r... | https://stackoverflow.com/questions/78581162/python-kmeans-consistently-label-clusters | python, scikit-learn | 1,717,592,380 |
se_60942564 | stackoverflow | MACHINE_LEARNING | How to grid search parameter for XGBoost with MultiOutputRegressor wrapper | How to grid search parameter for XGBoost with MultiOutputRegressor wrapper
I'm trying to build a regressor to predict from a 6D input to a 6D output using XGBoost with the MultiOutputRegressor wrapper. I'm not sure how to do the parameter search. My code looks like this:
gsc = GridSearchCV(
estimator=xgb.X... | https://stackoverflow.com/questions/60942564/how-to-grid-search-parameter-for-xgboost-with-multioutputregressor-wrapper | python, scikit-learn, xgboost | 1,585,622,002 |
se_53556359 | stackoverflow | MACHINE_LEARNING | Selecting kernel and hyperparameters for kernel PCA reduction | Selecting kernel and hyperparameters for kernel PCA reduction
I'm reading Hands-On Machine Learning with Scikit-Learn and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems
I'm trying to optimize an unsupervised kernel PCA algorithm.
Here is some context:
Another approach, this time entirely... | https://stackoverflow.com/questions/53556359/selecting-kernel-and-hyperparameters-for-kernel-pca-reduction | python, scikit-learn | 1,543,576,111 |
se_77615883 | stackoverflow | MACHINE_LEARNING | AttributeError: 'Flags' object has no attribute 'c_contiguous' | AttributeError: 'Flags' object has no attribute 'c_contiguous'
I am following Hands On Machine Learning Book by Aurélien Géron and running in to the following error.
Code:
y_train_large = (y_train.astype("int") >= 7)
y_train_odd = (y_train.astype("int") % 2 == 1)
y_multilabel = np.c_[y_train_large, y_t... | https://stackoverflow.com/questions/77615883/attributeerror-flags-object-has-no-attribute-c-contiguous | python, machine-learning, scikit-learn, classification, knn | 1,701,891,767 |
se_76949978 | stackoverflow | MACHINE_LEARNING | Pycaret - Setting n_jobs in model_tune() | Pycaret - Setting n_jobs in model_tune()
I would like to use multiprocessing by specifying the n_jobs parameter in sklearn.model_selection.RandomizedSearchCV
I would like to specify this through the pycaret wrapper in pycaret.classification.tune_model.
I have tried passing the n_jobs as **kwargs, but a TypeError: ABCM... | https://stackoverflow.com/questions/76949978/pycaret-setting-n-jobs-in-model-tune | python, python-3.x, scikit-learn, joblib, pycaret | 1,692,676,118 |
se_78565961 | stackoverflow | MACHINE_LEARNING | Error in sklearn’s cross_val_score with ‘f1’ scoring for categorical target in LightGBM | Error in sklearn’s cross_val_score with ‘f1’ scoring for categorical target in LightGBM
My code receives a dataset and runs a classification on it with lightgbm. The problem is when I try to do fine-tuning with sklearn's cross_val_score, the target column contains categorical values, not numerical ones.
It works when ... | https://stackoverflow.com/questions/78565961/error-in-sklearn-s-cross-val-score-with-f1-scoring-for-categorical-target-in-l | python, scikit-learn, cross-validation, multiclass-classification, lightgbm | 1,717,319,807 |
se_68558565 | stackoverflow | MACHINE_LEARNING | Scale columns in dataframe based on another column | Scale columns in dataframe based on another column
I have the dataframe shown below :
column1
column2
column3
1
0.01
0.001
2
0.02
0.002
3
0.03
0.003
I want to scale column 2 and column 3 based on the min and max scaler of column 1, in order to obtain the following :
column1
column2
column3
1
1
... | https://stackoverflow.com/questions/68558565/scale-columns-in-dataframe-based-on-another-column | pandas, scikit-learn, scale, minmax | 1,627,467,578 |
se_77125999 | stackoverflow | MACHINE_LEARNING | Google Colab TensorFlow 'DistributedDatasetInterface' Error | Google Colab TensorFlow 'DistributedDatasetInterface' Error
Found a solution.
Uninstalled the lastest version of tensorflow and reverted to a previous model
# Uninstall the current version of TensorFlow.
!pip uninstall tensorflow -2.13.0
# Install TensorFlow 1.15.0.
!pip install tensorflow==2.12.0
# Verify t... | https://stackoverflow.com/questions/77125999/google-colab-tensorflow-distributeddatasetinterface-error | python, tensorflow, scikit-learn, google-colaboratory, attributeerror | 1,695,029,316 |
se_71618530 | stackoverflow | MACHINE_LEARNING | How come you can get a permutation feature importance greater than 1? | How come you can get a permutation feature importance greater than 1?
Take this simple code:
import lightgbm as lgb
from sklearn.inspection import permutation_importance
X_train, X_test, y_train, y_test = train_test_split(X, y)
lgbr = lgb.LGBMRegressor(n_estimators=500, learning_rate=0.15)
model_lgb = lgbr.fit(X_train... | https://stackoverflow.com/questions/71618530/how-come-you-can-get-a-permutation-feature-importance-greater-than-1 | python, scikit-learn | 1,648,218,238 |
se_67235806 | stackoverflow | MACHINE_LEARNING | getting an issue in sklearn.linear_model._logistic in ml | getting an issue in sklearn.linear_model._logistic in ml
Can anyone tell me how to fix this Error?
ModuleNotFoundError: No module named 'sklearn.linear_model._logistic
File "c:\users\chintan\appdata\local\programs\python\python37\lib\site-packages\streamlit\script_runner.py", line 332, in _run_script
exec(code, m... | https://stackoverflow.com/questions/67235806/getting-an-issue-in-sklearn-linear-model-logistic-in-ml | python, scikit-learn | 1,619,205,865 |
se_78559070 | stackoverflow | MACHINE_LEARNING | Pandas takes all columns of a dataframe even when some columns are specified | Pandas takes all columns of a dataframe even when some columns are specified
I am trying to train KMeans model using Scikit-Learn.
I am stuck on this issue for 2 days.
Pandas is selecting all columns of a dataframe even though I specified 2 columns.
Here is the dataframe in the form of .to_dict():
{'area': {0: 15.26, ... | https://stackoverflow.com/questions/78559070/pandas-takes-all-columns-of-a-dataframe-even-when-some-columns-are-specified | pandas, machine-learning, scikit-learn, artificial-intelligence, sklearn-pandas | 1,717,145,978 |
se_41127976 | stackoverflow | MACHINE_LEARNING | Confusing example of nested cross validation in scikit-learn | Confusing example of nested cross validation in scikit-learn
I'm looking at this example from scikit-learn documentation: http://scikit-learn.org/0.18/auto_examples/model_selection/plot_nested_cross_validation_iris.html
It seems to me that crossvalidation is not performed in an unbiased way here. Both GridSearchCV (s... | https://stackoverflow.com/questions/41127976/confusing-example-of-nested-cross-validation-in-scikit-learn | scikit-learn, cross-validation | 1,481,653,246 |
se_50942553 | stackoverflow | MACHINE_LEARNING | How do I know which features are selected with SelectKBest? | How do I know which features are selected with SelectKBest?
Some features are selected after running SelectKBest and the result is returned as an array, so I have no idea which features they are since my training set has thousands of features.
I want to locate and pick out these features in my test set and remove the... | https://stackoverflow.com/questions/50942553/how-do-i-know-which-features-are-selected-with-selectkbest | python, machine-learning, scikit-learn, feature-extraction, feature-selection | 1,529,479,542 |
se_78561502 | stackoverflow | MACHINE_LEARNING | ImportError: cannot import name 'check_pandas_support' from 'sklearn.utils' | ImportError: cannot import name 'check_pandas_support' from 'sklearn.utils'
These are the versions of packages I have:
Python dependencies:
sklearn: 1.5.0
pip: 24.0
setuptools: 70.0.0
numpy: 1.23.1
scipy: 1.13.1
Cython: None
pandas: 2.2.2
matplotlib: 3.8.2
joblib: 1.4.2
threadpoolctl: 3.5.0
I've tried ... | https://stackoverflow.com/questions/78561502/importerror-cannot-import-name-check-pandas-support-from-sklearn-utils | python, pandas, scikit-learn, anaconda, conda | 1,717,177,553 |
se_78559061 | stackoverflow | MACHINE_LEARNING | How to implement class weight sampling in multi label classification? | How to implement class weight sampling in multi label classification?
I am working on a multi label classification problem and need some guidance on computing class weights using Scikit-Learn.
Problem Context:
I have a dataset with 9973 training samples.The labels are one-hot encoded, representing 13 different classes... | https://stackoverflow.com/questions/78559061/how-to-implement-class-weight-sampling-in-multi-label-classification | python, machine-learning, scikit-learn | 1,717,145,837 |
se_60786220 | stackoverflow | MACHINE_LEARNING | AttributeError: 'GridSearchCV' object has no attribute 'best_params_' | AttributeError: 'GridSearchCV' object has no attribute 'best_params_'
Grid search is a way to find the best parameters for any model out of the combinations we specify. I have formed a grid search on my model in the below manner and wish to find best parameters identified using this gridsearch.
from sk... | https://stackoverflow.com/questions/60786220/attributeerror-gridsearchcv-object-has-no-attribute-best-params | python, python-3.x, scikit-learn, attributeerror, gridsearchcv | 1,584,782,477 |
se_42471570 | stackoverflow | MACHINE_LEARNING | How can I split documents into training set and test set? | How can I split documents into training set and test set?
I am trying to build a classification model. I have 1000 text documents in local folder. I want to divide them into training set and test set with a split ratio of 70:30(70 → Training and 30 → Test). What is the better approach to do so? I am using Python.
I w... | https://stackoverflow.com/questions/42471570/how-can-i-split-documents-into-training-set-and-test-set | machine-learning, scikit-learn, text-classification | 1,488,128,909 |
se_78554352 | stackoverflow | MACHINE_LEARNING | How to use ndcg_score to calculate NDCG if there is no real label in the recall result? | How to use ndcg_score to calculate NDCG if there is no real label in the recall result?
I encountered some confusion when using 'sklearn. metrics. ndcg_score' to calculate NDCG. Specifically, suppose I have the following situations:
-Related documents: a, b. C (Their correlation score is 1)
-Search result: a, d, e, f,... | https://stackoverflow.com/questions/78554352/how-to-use-ndcg-score-to-calculate-ndcg-if-there-is-no-real-label-in-the-recall | scikit-learn | 1,717,064,356 |
se_78554157 | stackoverflow | MACHINE_LEARNING | I was loading the iris dataset, but there is an error where it says duplicate names are not allowed, i even tried changing the name but another error | I was loading the iris dataset, but there is an error where it says duplicate names are not allowed, i even tried changing the name but another error
url= "https://archive.ics.uci.edu/ml/machine-learning-databases/iris.data"
names = ['sepal-length','sepal-width','petal-length','petal-width','petal-width','class']
dat... | https://stackoverflow.com/questions/78554157/i-was-loading-the-iris-dataset-but-there-is-an-error-where-it-says-duplicate-na | python, machine-learning, scikit-learn, iris-dataset | 1,717,062,153 |
se_78551780 | stackoverflow | MACHINE_LEARNING | sklearn transformer for dropping features | sklearn transformer for dropping features
I have a dataset with a large number of features, some of which I'd like to simply discard. I'd like to do this as part of a scikit-learn pipeline, whose first step drops the unwanted features. This requires an object which drops the features in a manner consistent with scikit... | https://stackoverflow.com/questions/78551780/sklearn-transformer-for-dropping-features | python, scikit-learn | 1,717,013,646 |
se_65898399 | stackoverflow | MACHINE_LEARNING | No module named 'sklearn.datasets.samples_generator' | No module named 'sklearn.datasets.samples_generator'
When trying to create 4 clusters of random data, I am getting the following error message:
# Generate 4 clusters of random data.
from sklearn.datasets.samples_generator import make_blobs
data, _ = make_blobs(n_samples=300, centers=4,
cl... | https://stackoverflow.com/questions/65898399/no-module-named-sklearn-datasets-samples-generator | python, python-3.x, scikit-learn, python-3.6 | 1,611,651,561 |
se_62225230 | stackoverflow | MACHINE_LEARNING | Consistent ColumnTransformer for intersecting lists of columns | Consistent ColumnTransformer for intersecting lists of columns
I want to use sklearn.compose.ColumnTransformer consistently (not parallel, so, the second transformer should be executed only after the first) for intersecting lists of columns in this way:
log_transformer = p.FunctionTransformer(lambda x: np.log(x))
df ... | https://stackoverflow.com/questions/62225230/consistent-columntransformer-for-intersecting-lists-of-columns | python, pandas, scikit-learn, scipy, sklearn-pandas | 1,591,397,647 |
se_54511542 | stackoverflow | MACHINE_LEARNING | What is the use of predict() method in kmeans implementation of scikit learn? | What is the use of predict() method in kmeans implementation of scikit learn?
Can someone explain what is the use of predict() method in kmeans implementation of scikit learn? The official documentation states its use as:
Predict the closest cluster each sample in X belongs to.
But I can get the cluster number/l... | https://stackoverflow.com/questions/54511542/what-is-the-use-of-predict-method-in-kmeans-implementation-of-scikit-learn | python, scikit-learn, k-means | 1,549,264,326 |
se_78545256 | stackoverflow | MACHINE_LEARNING | i got ValueError: np.nan is an invalid document, expected byte or unicode string | i got ValueError: np.nan is an invalid document, expected byte or unicode string
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
# Read the first Excel file with Business codes and descriptions
df1 = pd.read_excel("E:/file1.xlsx")
... | https://stackoverflow.com/questions/78545256/i-got-valueerror-np-nan-is-an-invalid-document-expected-byte-or-unicode-string | pandas, machine-learning, scikit-learn | 1,716,911,871 |
se_78522799 | stackoverflow | MACHINE_LEARNING | plotting only points that are stable from a time series and perform linear regression | plotting only points that are stable from a time series and perform linear regression
I have two questions that I put in one help request. so I hope it will not make this overcrowded.
I spend quite some time figuring this out but not successful so far. I am trying to plot only points from a series of data that are clo... | https://stackoverflow.com/questions/78522799/plotting-only-points-that-are-stable-from-a-time-series-and-perform-linear-regre | python, matplotlib, datetime, scikit-learn, time-series | 1,716,463,698 |
se_58823264 | stackoverflow | MACHINE_LEARNING | How to scale train, validation and test sets properly using StandardScaler? | How to scale train, validation and test sets properly using StandardScaler?
Some articles says that in case of having only train and test sets, first, we need to use fit_transform() to scale training set and then only transform() for test set, in order to prevent data leakage.
In my case, I have also validation set.... | https://stackoverflow.com/questions/58823264/how-to-scale-train-validation-and-test-sets-properly-using-standardscaler | python, machine-learning, scikit-learn | 1,573,577,692 |
se_32764991 | stackoverflow | MACHINE_LEARNING | How do I store a TfidfVectorizer for future use in scikit-learn? | How do I store a TfidfVectorizer for future use in scikit-learn?
I have a TfidfVectorizer that vectorizes collection of articles followed by feature selection.
vectorizer = TfidfVectorizer()
X_train = vectorizer.fit_transform(corpus)
selector = SelectKBest(chi2, k = 5000 )
X_train_sel = selector.fit_transform(X_train,... | https://stackoverflow.com/questions/32764991/how-do-i-store-a-tfidfvectorizer-for-future-use-in-scikit-learn | python, python-3.x, scikit-learn, tf-idf, joblib | 1,443,107,648 |
se_65357481 | stackoverflow | MACHINE_LEARNING | How to do multiple inferencing on onnx(onnxruntime) similar to sklearn | How to do multiple inferencing on onnx(onnxruntime) similar to sklearn
I want to infer outputs against many inputs from an onnx model using onnxruntime in python. One way is to use the for loop but it seems a very trivial and a slow method. Is there a way to do the same way as sklearn?
Single prediction on onnxruntime... | https://stackoverflow.com/questions/65357481/how-to-do-multiple-inferencing-on-onnxonnxruntime-similar-to-sklearn | python, scikit-learn, onnx, onnxruntime | 1,608,296,314 |
se_43544888 | stackoverflow | MACHINE_LEARNING | Find Columns that are Linear Combinations of Other Columns | Find Columns that are Linear Combinations of Other Columns
I'm fairly new to statistics and sklearn, so please forgive me if this is a very basic question. I have a m x n matrix (thousands of rows, hundreds of columns) and I'm trying to find the columns within the matrix that are linear combinations of other columns i... | https://stackoverflow.com/questions/43544888/find-columns-that-are-linear-combinations-of-other-columns | r, pandas, numpy, scipy, scikit-learn | 1,492,783,849 |
se_29204005 | stackoverflow | MACHINE_LEARNING | How to perform under sampling in scikit learn? | How to perform under sampling in scikit learn?
We have a retinal dataset wherein the diseased eye information constitutes 70 percent of the information whereas the non diseased eye constitutes the remaining 30 percent.We want a dataset wherein the diseased as well as the non diseased samples should be equal in number.... | https://stackoverflow.com/questions/29204005/how-to-perform-under-sampling-in-scikit-learn | python, python-2.7, dataset, scikit-learn, sampling | 1,427,089,988 |
se_78537242 | stackoverflow | MACHINE_LEARNING | Why does the DecisionTreeClassifiers accuracy change when we do these changes? | Why does the DecisionTreeClassifiers accuracy change when we do these changes?
I was training a model using DecisionTreeClassifier and just like the LinearRegression / LogisticRegression algorithms testing and training datasets I use the 2D array for X values and 1D array for y values[y.values] but the accuracy [using... | https://stackoverflow.com/questions/78537242/why-does-the-decisiontreeclassifiers-accuracy-change-when-we-do-these-changes | machine-learning, scikit-learn, decision-tree | 1,716,785,695 |
se_49561882 | stackoverflow | MACHINE_LEARNING | How to choose RandomState in train_test_split? | How to choose RandomState in train_test_split?
I understand that the random state parameter in data splitting leads to different accuracies each time it is changed. Consequently, my algorithm’s performance varies with each run. For my university report, I need to determine the most appropriate way to report the final ... | https://stackoverflow.com/questions/49561882/how-to-choose-randomstate-in-train-test-split | python, pandas, machine-learning, scikit-learn, svm | 1,522,344,113 |
se_78532981 | stackoverflow | MACHINE_LEARNING | TypeError: Singleton array array(1) cannot be considered a valid collection | TypeError: Singleton array array(1) cannot be considered a valid collection
I have a dataset where my target variable is a number between 1 and 8.
Now I am going to implement Cubic SVM.
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score... | https://stackoverflow.com/questions/78532981/typeerror-singleton-array-array1-cannot-be-considered-a-valid-collection | machine-learning, scikit-learn, svm, roc, auc | 1,716,652,843 |
se_78524575 | stackoverflow | MACHINE_LEARNING | ImportError: cannot import name '_get_column_indices' from 'sklearn.utils' | ImportError: cannot import name '_get_column_indices' from 'sklearn.utils'
I am getting an import Error when trying to import imblearn.over_sampling for RandomOverSampler. I believe the issue is not with my code but with the libraries clashing, I'm not sure though.
import pandas as pd
import matplotlib... | https://stackoverflow.com/questions/78524575/importerror-cannot-import-name-get-column-indices-from-sklearn-utils | python, machine-learning, scikit-learn, imblearn | 1,716,483,286 |
se_34734645 | stackoverflow | MACHINE_LEARNING | Pandas - replace categorical text with numpy arrays for machine learning | Pandas - replace categorical text with numpy arrays for machine learning
I have a file:
data = pd.read('data.csv')
And that file contains categorical text data about digital users such as: (source = 'google', 'facebook', 'twitter') and (country = 'US', 'FR', 'GER').
Using the sklearn.feature_extraction.DictVector... | https://stackoverflow.com/questions/34734645/pandas-replace-categorical-text-with-numpy-arrays-for-machine-learning | python, pandas, scikit-learn, categorical-data, one-hot-encoding | 1,452,565,876 |
se_72850242 | stackoverflow | MACHINE_LEARNING | Calculating TPR, FPR by hand vs scikit-learn via ROC curve | Calculating TPR, FPR by hand vs scikit-learn via ROC curve
So, giving the scikit-learn function roc_curve two arrays of True and False values
fpr, tpr, thresholds = roc_curve(self.real_values_discrete, self.predictions_discrete)
I receive values like this:
>>> [0. 0.63888889 1. ]
>>> [0. 0.5433... | https://stackoverflow.com/questions/72850242/calculating-tpr-fpr-by-hand-vs-scikit-learn-via-roc-curve | python, scikit-learn | 1,656,886,418 |
se_66884609 | stackoverflow | MACHINE_LEARNING | How to generate an API reference like sklearn? | How to generate an API reference like sklearn?
To make a python package I am writing easier to use, I am thinking of making a detailed API documentation.
The API reference of machine learning package sklearn is the one I am trying to emulate.
So what is the right tool to make such a documentation? | https://stackoverflow.com/questions/66884609/how-to-generate-an-api-reference-like-sklearn | scikit-learn, reference, documentation | 1,617,181,265 |
se_78530448 | stackoverflow | MACHINE_LEARNING | _fit_method for KNN gives KD-tree even though I'm working in a high dimensional spce | _fit_method for KNN gives KD-tree even though I'm working in a high dimensional spce
so since KNeighborsClassifier class in sklearn find the best algorithm depending on the values from fit method when using auto (which is the default), when accessing the algorithm using ._fit_method I get kd tree which makes no se... | https://stackoverflow.com/questions/78530448/fit-method-for-knn-gives-kd-tree-even-though-im-working-in-a-high-dimensional | machine-learning, scikit-learn, sklearn-pandas | 1,716,580,413 |
se_78486471 | stackoverflow | MACHINE_LEARNING | How to add a .transform Nystroem method to project new observations into an existing space? (Diffusion Maps in Python) | How to add a .transform Nystroem method to project new observations into an existing space? (Diffusion Maps in Python)
I am copying over some code from mapalign for calculating diffusion maps using the sklearn api. Currently, there is no .transform method so I've forked the repo and I'm trying to add it myself but I'... | https://stackoverflow.com/questions/78486471/how-to-add-a-transform-nystroem-method-to-project-new-observations-into-an-exis | python, numpy, scikit-learn, transform, dimensionality-reduction | 1,715,806,477 |
se_78526695 | stackoverflow | MACHINE_LEARNING | Need help validating custom AUPRC scorer implementation in GridSearchCV | Need help validating custom AUPRC scorer implementation in GridSearchCV
I have the following custom scorer code that I'm using in a grid search:
def custom_auprc_scorer(y_true, y_pred):
pos_label = 'positive'
y_true_mapped = np.where(y_true == pos_label, 1, 0)
y_pred_numeric = np.where(y_pred == pos_label,... | https://stackoverflow.com/questions/78526695/need-help-validating-custom-auprc-scorer-implementation-in-gridsearchcv | python, scikit-learn, grid-search, precision-recall | 1,716,530,133 |
se_54870799 | stackoverflow | MACHINE_LEARNING | Multi-label compute class weight - unhashable type | Multi-label compute class weight - unhashable type
Working in a multi-label classification problem with 13 possibles outputs in my neural network with Keras, sklearn, etc...
Each output can be an array like [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1 ,0].
I have an imbalance dataset and i trying to apply compute_class_weigh... | https://stackoverflow.com/questions/54870799/multi-label-compute-class-weight-unhashable-type | python, keras, scikit-learn, neural-network | 1,551,112,580 |
se_30696741 | stackoverflow | MACHINE_LEARNING | How to implement Kernel density estimation in multivariate/3D | How to implement Kernel density estimation in multivariate/3D
I have dataset like the following fromat and im trying to find out the Kernel density estimation with optimal bandwidth.
data = np.array([[1, 4, 3], [2, .6, 1.2], [2, 1, 1.2],
[2, 0.5, 1.4], [5, .5, 0], [0, 0, 0],
[1, 4, 3], [5, .5, 0], ... | https://stackoverflow.com/questions/30696741/how-to-implement-kernel-density-estimation-in-multivariate-3d | python, numpy, machine-learning, scikit-learn, kernel-density | 1,433,700,035 |
se_46257627 | stackoverflow | MACHINE_LEARNING | Scikit-learn: preprocessing.scale() vs preprocessing.StandardScalar() | Scikit-learn: preprocessing.scale() vs preprocessing.StandardScalar()
I understand that scaling means centering the mean(mean=0) and making unit variance(variance=1).
But, What is the difference between preprocessing.scale(x)and preprocessing.StandardScalar() in scikit-learn? | https://stackoverflow.com/questions/46257627/scikit-learn-preprocessing-scale-vs-preprocessing-standardscalar | python, scikit-learn, scale | 1,505,589,677 |
se_78520659 | stackoverflow | MACHINE_LEARNING | How to combine two scikit-learn sub-models into an ensemble using an if condition and save it to a pickle file? | How to combine two scikit-learn sub-models into an ensemble using an if condition and save it to a pickle file?
I have trained two scikit-learn models using an IF condition (resulting in two training sets based on defined criteria on the X1 feature). How can I integrate this if condition with these two trained models ... | https://stackoverflow.com/questions/78520659/how-to-combine-two-scikit-learn-sub-models-into-an-ensemble-using-an-if-conditio | python, machine-learning, scikit-learn, pickle, ensemble-learning | 1,716,430,358 |
se_74398563 | stackoverflow | MACHINE_LEARNING | How to use polars dataframes with scikit-learn? | How to use polars dataframes with scikit-learn?
I'm unable to use polars dataframes with scikit-learn for ML training.
Currently, I'm preprocessing all dataframes in polars and convert them to pandas for model training in order for it to work.
Is there any method to directly use polars dataframes with the scikit-learn... | https://stackoverflow.com/questions/74398563/how-to-use-polars-dataframes-with-scikit-learn | python, machine-learning, scikit-learn, python-polars | 1,668,146,395 |
se_66668873 | stackoverflow | MACHINE_LEARNING | Pandas dataframe: Synthetic data generation | Pandas dataframe: Synthetic data generation
I have a data frame df that contains 3 classes( classification Problem). The data contains most of the columns as categorical and the dataset is imbalanced. I am trying to generate a synthetic dataset that replicates the characteristics and features of the original data fram... | https://stackoverflow.com/questions/66668873/pandas-dataframe-synthetic-data-generation | python, python-3.x, pandas, dataframe, scikit-learn | 1,615,967,209 |
se_78519137 | stackoverflow | MACHINE_LEARNING | SKLearn different approaches to using metric functions | SKLearn different approaches to using metric functions
I want to make clear one question that bothers me.
from sklearn.metrics import r2_score, mean_absolute_error, mean_squared_error
from sklearn.ensemble import RandomForestRegressor
###
Rest of the preparation
###
mean_sqrd_error = cross_val_score(rfr,
... | https://stackoverflow.com/questions/78519137/sklearn-different-approaches-to-using-metric-functions | python, scikit-learn, metrics | 1,716,398,436 |
se_67666417 | stackoverflow | MACHINE_LEARNING | GridSearchCV returns worse accuracy than default | GridSearchCV returns worse accuracy than default
I was working with the Heart Disease Prediction dataset from Kaggle and came up with something odd that I couldn't find an answer.
With default Logistic Regression with 'liblinear' solver (C = 1) I get an accuracy on the train set of 87.26% and 86.81% on the test set. P... | https://stackoverflow.com/questions/67666417/gridsearchcv-returns-worse-accuracy-than-default | python, machine-learning, scikit-learn, cross-validation | 1,621,827,739 |
se_57015499 | stackoverflow | MACHINE_LEARNING | How to use Dynamic Time warping with kNN in python | How to use Dynamic Time warping with kNN in python
I have a time-series dataset with two lables (0 and 1). I am using Dynamic Time Warping (DTW) as a similarity measure for classification using k-nearest neighbour (kNN) as described in these two wonderful blog posts:
https://nbviewer.jupyter.org/github/markdregan/K-... | https://stackoverflow.com/questions/57015499/how-to-use-dynamic-time-warping-with-knn-in-python | python, scikit-learn, time-series, classification, knn | 1,562,981,407 |
se_63969194 | stackoverflow | MACHINE_LEARNING | How to calculate pairwise Mutual Information for entire pandas dataset? | How to calculate pairwise Mutual Information for entire pandas dataset?
I have 50 variables in my dataframe. 46 are dependent variables and 4 are independent variables (precipitation, temperature, dew, snow). I want to calculate the mutual information of my dependent variables against my independent.
So in the end I w... | https://stackoverflow.com/questions/63969194/how-to-calculate-pairwise-mutual-information-for-entire-pandas-dataset | python, pandas, dataframe, scikit-learn, mutual-information | 1,600,521,037 |
se_78516326 | stackoverflow | MACHINE_LEARNING | Using sklearn for hierarchical classification | Using sklearn for hierarchical classification
I was wondering if hierarchical classifications are supported by the sciki-learn library. I am dealing with the 3 classes divided by 6 subclasses each, such as:
import numpy as np
from sklearn.tree import DecisionTreeClassifier
X = np.random.randn(5, 1)
number, rows, col... | https://stackoverflow.com/questions/78516326/using-sklearn-for-hierarchical-classification | python, numpy, scikit-learn, classification, multiclass-classification | 1,716,367,981 |
se_56741689 | stackoverflow | MACHINE_LEARNING | How to make user-defined callable weight function for sklearn knn? | How to make user-defined callable weight function for sklearn knn?
I am trying to make custom weights for Sklearn KNN classifier, similar as here.
In documentation is just briefly mentioned that you can set custom weights as a user-defined function which accepts an array of distances, and returns an array of the same... | https://stackoverflow.com/questions/56741689/how-to-make-user-defined-callable-weight-function-for-sklearn-knn | python, scikit-learn, knn, callable, weighted | 1,561,398,985 |
se_66421637 | stackoverflow | MACHINE_LEARNING | sklearn GridSearchCV gives questionable results | sklearn GridSearchCV gives questionable results
I have input data X_train with dimension (477 x 200) and y_train with length 477.
I want to use a support vector machine regressor and I am doing grid search.
param_grid = {'kernel': ['poly', 'rbf', 'linear','sigmoid'], 'degree': [2,3,4,5], 'C':[0.01,0.1,0.3,0.5,0.7,1,1.... | https://stackoverflow.com/questions/66421637/sklearn-gridsearchcv-gives-questionable-results | python, scikit-learn, regression, grid-search, gridsearchcv | 1,614,599,472 |
se_76071626 | stackoverflow | MACHINE_LEARNING | Why do I get different results every time I run parameter tuning? | Why do I get different results every time I run parameter tuning?
Can anyone explain to me why, every time I run the model and tune hyperparameters using RandomSearch, I get good parameters and apply them, it yields a good result. But when I run it all again, tuning parameters, even though they are the same as before,... | https://stackoverflow.com/questions/76071626/why-do-i-get-different-results-every-time-i-run-parameter-tuning | python, scikit-learn, xgboost, parameter-tuning | 1,682,068,020 |
se_40475548 | stackoverflow | MACHINE_LEARNING | sklearn Pipeline with NaN values | sklearn Pipeline with NaN values
For good reasons, most ( all ? ) of the sklearn methods that implement fit and transform ( transformers or estimators ) don't play nice with data that contains NaN values. Because most machine learning algorithms can't handle these out of the box, and various transforms are ambiguous w... | https://stackoverflow.com/questions/40475548/sklearn-pipeline-with-nan-values | scikit-learn | 1,478,556,469 |
se_71076322 | stackoverflow | MACHINE_LEARNING | "Trying to unpickle estimator LinearRegression from version X when using version Y" - But I have only the Y version on my .venv, what takes? | "Trying to unpickle estimator LinearRegression from version X when using version Y" - But I have only the Y version on my .venv, what takes?
The exact warning is
....\.venv\lib\site-packages\sklearn\base.py:329: UserWarning: Trying to unpickle estimator LinearRegression from version 0.24.1 when using version... | https://stackoverflow.com/questions/71076322/trying-to-unpickle-estimator-linearregression-from-version-x-when-using-version | python, scikit-learn | 1,644,563,470 |
se_78507382 | stackoverflow | MACHINE_LEARNING | sklearn PolynomialFeatures: Is the bias required if LinearRegression generates a y intercept | sklearn PolynomialFeatures: Is the bias required if LinearRegression generates a y intercept
I'm new to machine learning so I have been playing around with some of the models trying to get a better understanding.
When I create a matrix of features:
X_Poly3 (X_Poly3 = PolynomialFeatures(3))
where X was a matrix with 2... | https://stackoverflow.com/questions/78507382/sklearn-polynomialfeatures-is-the-bias-required-if-linearregression-generates-a | python, machine-learning, scikit-learn, linear-regression | 1,716,217,848 |
se_78503271 | stackoverflow | MACHINE_LEARNING | Sklearn : how to keep NaN values through OneHotEncoder? | Sklearn : how to keep NaN values through OneHotEncoder?
INPUT
I have the following data:
import pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from sklearn.impute import SimpleImputer
test_df = pd.DataFrame({'sex': ['female', 'male', np.nan], 'eye_color': ['blue', np.nan, 'brown']})
t... | https://stackoverflow.com/questions/78503271/sklearn-how-to-keep-nan-values-through-onehotencoder | python, scikit-learn, one-hot-encoding | 1,716,136,949 |
se_67735216 | stackoverflow | MACHINE_LEARNING | After using pip, I get the error "Scikit-learn has not been built correctly" | After using pip, I get the error "Scikit-learn has not been built correctly"
I'm using a Jetson Nano and I already tried reinstalling tensorflow (tried different versions) and numpy (also different versions). I'm using the pip3 commands, since I'm using python3 (version 3.6.9).
Downgrading everything didn't ... | https://stackoverflow.com/questions/67735216/after-using-pip-i-get-the-error-scikit-learn-has-not-been-built-correctly | python, python-3.x, tensorflow, scikit-learn | 1,622,189,546 |
se_78499525 | stackoverflow | MACHINE_LEARNING | Is there a difference in the underlying sklearn 'entropy' and 'log_loss' criteria for decision tree classifiers? | Is there a difference in the underlying sklearn 'entropy' and 'log_loss' criteria for decision tree classifiers?
I'm implementing an decision tree classifier using sklearn and testing out different criteria, but I can't seem to find what the difference is between the 'entropy' and 'log_loss' criteria. ... | https://stackoverflow.com/questions/78499525/is-there-a-difference-in-the-underlying-sklearn-entropy-and-log-loss-criteri | python, scikit-learn, decision-tree | 1,716,030,689 |
se_78499706 | stackoverflow | MACHINE_LEARNING | MSD Algorithm output producing a 'mirrored' output | MSD Algorithm output producing a 'mirrored' output
I am using the MSD algorithm to reduce 3D datapoints to 2D.
There are situations where the algorithm will return results which appear to mirror the original data on the y-axis or x-axis. I would like to preserve the original x-y view perspective.
In the plot b... | https://stackoverflow.com/questions/78499706/msd-algorithm-output-producing-a-mirrored-output | python, scikit-learn | 1,716,034,918 |
se_57507584 | stackoverflow | MACHINE_LEARNING | Feature scaling for Kmeans algorithm | Feature scaling for Kmeans algorithm
I know feature scaling is required for KMeans algorithm defined under
sklearn.cluster.KMeans
My question is whether it needs to be done manually before using KMeans or KMeans does automatically perform feature scaling? If automatic, please show me where is it specified in KMeans a... | https://stackoverflow.com/questions/57507584/feature-scaling-for-kmeans-algorithm | python, python-3.x, machine-learning, scikit-learn, deep-learning | 1,565,861,266 |
se_78493179 | stackoverflow | MACHINE_LEARNING | Gridsearch CV using more cpus than requested | Gridsearch CV using more cpus than requested
Hi I cannot figure out why Gridsearch is using more cpu than requested. It stays within the requested resources when GridSearchCV(.., n_job=1) but this takes ages to run. What I understand is that OMP_NUM_THREADS limit the CPU each job uses and n_job is the number of jobs t... | https://stackoverflow.com/questions/78493179/gridsearch-cv-using-more-cpus-than-requested | scikit-learn, parallel-processing, openmp, gridsearchcv, pbs | 1,715,911,941 |
se_78496068 | stackoverflow | MACHINE_LEARNING | Passing Sample Weights to Sklearn Pipeline object with XGBoost | Passing Sample Weights to Sklearn Pipeline object with XGBoost
There are some good questions on this topic, however, I haven't found any solution to this error involving using XGBoost models with sample_weight in sklearn's Pipeline framework.
Here is my example and the subsequent error:
from xgboost_distribution impor... | https://stackoverflow.com/questions/78496068/passing-sample-weights-to-sklearn-pipeline-object-with-xgboost | python, scikit-learn, pipeline, xgboost | 1,715,953,526 |
se_78493562 | stackoverflow | MACHINE_LEARNING | Python data filtering to remove outliers around a density plot | Python data filtering to remove outliers around a density plot
Referring to the below plot, I would like to remove all the outliers outside the density region marked in black color oval shape. I can use simple horizontal filters, like, -4 < data < 4. But outliers still remain. I am looking for any technique that preci... | https://stackoverflow.com/questions/78493562/python-data-filtering-to-remove-outliers-around-a-density-plot | python, dataframe, scikit-learn, cluster-analysis, outliers | 1,715,922,326 |
se_60846849 | stackoverflow | MACHINE_LEARNING | SVM prediction (SVC vs SVR ) | SVM prediction (SVC vs SVR )
I'm trying to predict values in my dataset with SKlearn SVM.
On the Sklearn website, I have more models:
My dataset is full numeric (like the Iris dataset), without labels.
I tried to apply the model in this way :
svclassifier = SVC(kernel='linear')
and the computation is very long (... | https://stackoverflow.com/questions/60846849/svm-prediction-svc-vs-svr | python, scikit-learn, svm, prediction, svc | 1,585,131,826 |
se_78490063 | stackoverflow | MACHINE_LEARNING | Label encoder the target in Pipeline | Label encoder the target in Pipeline
I want to create a pipeline to do preprocessing in both training features and target, then train the model. Dataset would be something like:
v1 v2 target
0 1 a yes
1 5 c no
2 3 f yes
I have a pipeline like
num_cols = ['v1']
cat_cols = ['v2']
clf = DecisionTreeC... | https://stackoverflow.com/questions/78490063/label-encoder-the-target-in-pipeline | python, pandas, scikit-learn, pipeline, encode | 1,715,864,367 |
se_77125797 | stackoverflow | MACHINE_LEARNING | LogisticRegression(solver='liblinear') output error | LogisticRegression(solver='liblinear') output error
I am using the logistic regression but no output is produced can you help me
this my code
from sklearn.linear_model import LogisticRegression
loj = LogisticRegression( solver = 'liblinear')
loj_model = loj.fit(X,y)
loj_model
this is output
LogisticRegression... | https://stackoverflow.com/questions/77125797/logisticregressionsolver-liblinear-output-error | python, python-3.x, scikit-learn, logistic-regression | 1,695,027,690 |
se_73629817 | stackoverflow | MACHINE_LEARNING | Got memory error while performing cosine similarity on a huge vector | Got memory error while performing cosine similarity on a huge vector
I was trying to build a content based recommendation system using bag of words model. The tutorial which I am following uses cosine similarity from sklearn library on a vector of size (4000,5000) where 4000 is the number of rows in dataset and 5000 ... | https://stackoverflow.com/questions/73629817/got-memory-error-while-performing-cosine-similarity-on-a-huge-vector | python, machine-learning, scikit-learn, nlp, cosine-similarity | 1,662,521,625 |
se_51921142 | stackoverflow | MACHINE_LEARNING | How to load a model saved in joblib file from Google Cloud Storage bucket | How to load a model saved in joblib file from Google Cloud Storage bucket
I want to load a model which is saved as a joblib file from Google Cloud Storage bucket. When it is in local path, we can load it as follows (considering model_file is the full path in system):
loaded_model = joblib.load(model_file)
How can w... | https://stackoverflow.com/questions/51921142/how-to-load-a-model-saved-in-joblib-file-from-google-cloud-storage-bucket | python, scikit-learn, google-cloud-storage, joblib | 1,534,707,015 |
se_78485024 | stackoverflow | MACHINE_LEARNING | AttributeError: can't set attribute: How do I fix this this class to work well? | AttributeError: can't set attribute: How do I fix this this class to work well?
Given the following SMOTEBoost class implementeation in smoteboost.py file:
import numbers
import numpy as np
from collections import Counter
from sklearn.base import (clone,
is_regressor)
from sklearn.ensembl... | https://stackoverflow.com/questions/78485024/attributeerror-cant-set-attribute-how-do-i-fix-this-this-class-to-work-well | python, numpy, scikit-learn | 1,715,787,300 |
se_58274700 | stackoverflow | MACHINE_LEARNING | Difference Between Sklearn's DecisionTreeClassifier and CART | Difference Between Sklearn's DecisionTreeClassifier and CART
Understand the difference between CART and DecisionTreeClassifier of Sklearn.
In Sklearn's documentation, it says that "scikit-learn uses an optimised version of the CART algorithm". However, I couldn't find what this optimisation was anywhere!
It woul... | https://stackoverflow.com/questions/58274700/difference-between-sklearns-decisiontreeclassifier-and-cart | python, scikit-learn, decision-tree, cart-analysis | 1,570,470,533 |
se_78479265 | stackoverflow | MACHINE_LEARNING | Cross validation on XGBoost using callback of optuna | Cross validation on XGBoost using callback of optuna
I am trying yo use optuna and cross_validate from sklearn also using the callback function from optuna. My code is below.
It seems that the callback does not work here and I do not know why ... I don't see the intermediate value when printing it.
The code works but ... | https://stackoverflow.com/questions/78479265/cross-validation-on-xgboost-using-callback-of-optuna | scikit-learn, callback, xgboost, cross-validation, optuna | 1,715,701,917 |
se_78481612 | stackoverflow | MACHINE_LEARNING | model.compile loss TypeError: Missing required positional argument | model.compile loss TypeError: Missing required positional argument
The minimum example is
import numpy as np
import tensorflow as tf
from tensorflow import keras
from keras.losses import huber
# create dataset
x = np.random.rand(10, 1)
y = 2 * x + np.random.randn(10, 1) * 0.1
# define model
model = keras.Sequential(... | https://stackoverflow.com/questions/78481612/model-compile-loss-typeerror-missing-required-positional-argument | python, python-3.x, machine-learning, scikit-learn | 1,715,747,384 |
se_51456932 | stackoverflow | MACHINE_LEARNING | Custom Naive Bayes Implementation vs sklearn.naive_bayes for multimodal data | Custom Naive Bayes Implementation vs sklearn.naive_bayes for multimodal data
I am currently playing around with some classifications using the Naive Bayes algorithm.
For this it is normally assumed that p(x|C_i) is Gaussian. Under this assumption I would assume that this approach does not perform well when this assump... | https://stackoverflow.com/questions/51456932/custom-naive-bayes-implementation-vs-sklearn-naive-bayes-for-multimodal-data | python, scikit-learn, naivebayes | 1,532,182,869 |
se_43163959 | stackoverflow | MACHINE_LEARNING | Text classification. TFIDF and Naive Bayes? | Text classification. TFIDF and Naive Bayes?
I'm attempting a text classification task, where I have training data of around 500 restaurant reviews that are labelled across 12 categories. I spent longer than I should have implementing TF.IDF and cosine similarity for the classification of test data, only to get some ve... | https://stackoverflow.com/questions/43163959/text-classification-tfidf-and-naive-bayes | python, machine-learning, scikit-learn, nlp | 1,491,099,683 |
se_78395786 | stackoverflow | MACHINE_LEARNING | Error installing scikit-fda in Github Codespace (fdasrsf build issue) | Error installing scikit-fda in Github Codespace (fdasrsf build issue)
I am trying to import a library in a script on a github codespace, namely skfda.
the package wasn't present so I I tried to pip install, I tried conda and I tried to clone the the repo from github but the result is always the same:
note: This error ... | https://stackoverflow.com/questions/78395786/error-installing-scikit-fda-in-github-codespace-fdasrsf-build-issue | python, scikit-learn, datagrid, github-codespaces | 1,714,238,054 |
se_78474076 | stackoverflow | MACHINE_LEARNING | Sklearn preprocessors work sequentially but produce NAs when used in Pipeline | Sklearn preprocessors work sequentially but produce NAs when used in Pipeline
Here's the context:
I'm working with a dataset containing various feature types (numerical, categorical).
My task is the binary prediction of startup success dependent on a target variable defined earlier.
I have several preprocessing steps ... | https://stackoverflow.com/questions/78474076/sklearn-preprocessors-work-sequentially-but-produce-nas-when-used-in-pipeline | python, pandas, scikit-learn, pipeline, missing-data | 1,715,623,626 |
se_78473294 | stackoverflow | MACHINE_LEARNING | ValueError: Sequential model 'sequential' has no defined outputs yet | ValueError: Sequential model 'sequential' has no defined outputs yet
i want to wrap the model with akerasClassifier and run model_prediction = model.fit i get an error that i never got before a few months ago
this is the model i built
def create_model(embed_dim = 16, hidden_unit = 16, dropout_rate = 0.2,optimi... | https://stackoverflow.com/questions/78473294/valueerror-sequential-model-sequential-has-no-defined-outputs-yet | keras, scikit-learn, lstm, tf.keras | 1,715,613,963 |
se_28716241 | stackoverflow | MACHINE_LEARNING | Controlling the threshold in Logistic Regression in Scikit Learn | Controlling the threshold in Logistic Regression in Scikit Learn
I am using the LogisticRegression() method in scikit-learn on a highly unbalanced data set. I have even turned the class_weight feature to auto.
I know that in Logistic Regression it should be possible to know what is the threshold value for a particul... | https://stackoverflow.com/questions/28716241/controlling-the-threshold-in-logistic-regression-in-scikit-learn | python, machine-learning, scikit-learn, classification, logistic-regression | 1,424,859,093 |
se_43010225 | stackoverflow | MACHINE_LEARNING | Logistic Regression with just ONE numeric feature | Logistic Regression with just ONE numeric feature
What is the right way to use scikit-learn's LogisticRegression solver when you have just one numeric feature?
I ran a simple example that I found hard to explain. Can anyone please explain what I am doing wrong here?
import pandas
import numpy as np
from sklearn.line... | https://stackoverflow.com/questions/43010225/logistic-regression-with-just-one-numeric-feature | python, machine-learning, scikit-learn, logistic-regression | 1,490,394,972 |
se_77673134 | stackoverflow | MACHINE_LEARNING | AttributeError: 'numpy.ndarray' object has no attribute 'head' | AttributeError: 'numpy.ndarray' object has no attribute 'head'
I've been trying to use StandarScaler() for scaling data using csv dataset
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
%matplotlib inline
data = pd.read_csv('data.csv', nrows=50000)
data.hea... | https://stackoverflow.com/questions/77673134/attributeerror-numpy-ndarray-object-has-no-attribute-head | python, numpy, scikit-learn | 1,702,779,965 |
se_57752264 | stackoverflow | MACHINE_LEARNING | Encode a categorical feature with multiple categories per example | Encode a categorical feature with multiple categories per example
I am working on a dataset which has a feature that has multiple categories for a single example.
The feature looks like this:-
Feature
0 [Category1, Category2, Category2, Category4, Category5]
1 [Cat... | https://stackoverflow.com/questions/57752264/encode-a-categorical-feature-with-multiple-categories-per-example | machine-learning, scikit-learn, feature-extraction, categorical-data | 1,567,405,501 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.