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_79403541 | stackoverflow | MACHINE_LEARNING | sklearn plot_tree function does not show the class when the tree has only one node | sklearn plot_tree function does not show the class when the tree has only one node
I use the following code to plot a decisions trees:
plt.figure(figsize=(12, 12))
plot_tree(estimator,
feature_names=feature_names,
label= 'all',
class_names=[f'Class {k}' for k in range(2)],... | https://stackoverflow.com/questions/79403541/sklearn-plot-tree-function-does-not-show-the-class-when-the-tree-has-only-one-no | scikit-learn, decision-tree | 1,738,344,228 |
se_65318931 | stackoverflow | MACHINE_LEARNING | StratifiedKFold vs KFold in scikit-learn | StratifiedKFold vs KFold in scikit-learn
I use this code to test KFold and StratifiedKFold.
import numpy as np
from sklearn.model_selection import KFold,StratifiedKFold
X = np.array([
[1,2,3,4],
[11,12,13,14],
[21,22,23,24],
[31,32,33,34],
[41,42,43,44],
[51,52,53,54],
[61,62,63,64],
[... | https://stackoverflow.com/questions/65318931/stratifiedkfold-vs-kfold-in-scikit-learn | python, machine-learning, scikit-learn, cross-validation, k-fold | 1,608,103,844 |
se_45516424 | stackoverflow | MACHINE_LEARNING | sklearn train_test_split on pandas stratify by multiple columns | sklearn train_test_split on pandas stratify by multiple columns
I'm a relatively new user to sklearn and have run into some unexpected behavior in train_test_split from sklearn.model_selection. I have a pandas dataframe that I would like to split into a training and test set. I would like to stratify my data by at lea... | https://stackoverflow.com/questions/45516424/sklearn-train-test-split-on-pandas-stratify-by-multiple-columns | python, pandas, scikit-learn | 1,501,886,537 |
se_68650610 | stackoverflow | MACHINE_LEARNING | parameters of make_classification function in sklearn | parameters of make_classification function in sklearn
I am trying to generate synthetic data using make_classification function:
import sklearn.datasets as sk
X, y = sk.make_classification(n_samples=10,
n_features=3, n_informative=2, n_redundant=0, n_classes=2,
... | https://stackoverflow.com/questions/68650610/parameters-of-make-classification-function-in-sklearn | python, scikit-learn | 1,628,077,182 |
se_76934142 | stackoverflow | MACHINE_LEARNING | How to pass only necessary features to pipeline after SelectKBest | How to pass only necessary features to pipeline after SelectKBest
I have a regular tabular dataset, 100 features from the database are added
I want to push it into a regular sklearn.pipeline in which there will be preprocessing, encoding, some custom transformers, etc.
Penultimate estimator would be SelectKBest(k=10)
... | https://stackoverflow.com/questions/76934142/how-to-pass-only-necessary-features-to-pipeline-after-selectkbest | python, scikit-learn, feature-engineering, mlops | 1,692,432,393 |
se_58404293 | stackoverflow | MACHINE_LEARNING | Python DBSCAN clustering with periodic boundary conditions | Python DBSCAN clustering with periodic boundary conditions
Im a noob, probably im doing things too big for me, but i need this for my tesis, please forgive my ignorance.
My goal is to do clustering on 3D points, using sklearn.cluster.DBSCAN, and implement periodic boundary condition only on x,y.
The easiest way that I... | https://stackoverflow.com/questions/58404293/python-dbscan-clustering-with-periodic-boundary-conditions | python, numpy, scikit-learn, cluster-analysis, dbscan | 1,571,186,751 |
se_31851132 | stackoverflow | MACHINE_LEARNING | DBSCAN python with periodic boundary conditions | DBSCAN python with periodic boundary conditions
I'm trying to use sklearn.cluster.DBSCAN sklearn.cluster.DBSCAN for analysis of clusters in a 2D grid.
http://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html#sklearn.cluster.DBSCAN
But I have encountered the problem, that clustering across periodic ... | https://stackoverflow.com/questions/31851132/dbscan-python-with-periodic-boundary-conditions | python, scikit-learn, cluster-analysis, dbscan | 1,438,851,279 |
se_76557111 | stackoverflow | MACHINE_LEARNING | sklearn OrdinalEncoder default ordering (categories='auto') | sklearn OrdinalEncoder default ordering (categories='auto')
What is the default rule used by sklearn OrdinaleEcoder to determine the order of the categories when categories='auto'?
Is it just sorted lexicographically? couldn't find it in the docs | https://stackoverflow.com/questions/76557111/sklearn-ordinalencoder-default-ordering-categories-auto | scikit-learn, data-science | 1,687,785,731 |
se_79270292 | stackoverflow | MACHINE_LEARNING | cannot access free variable 'fig' where it is not associated with a value in enclosing scope | cannot access free variable 'fig' where it is not associated with a value in enclosing scope
I got this error for any way I tried to fix this bug
--------------------------------------------------------------------------- NameError Traceback (most recent call last) File /Library... | https://stackoverflow.com/questions/79270292/cannot-access-free-variable-fig-where-it-is-not-associated-with-a-value-in-enc | python-3.x, machine-learning, scikit-learn, pca | 1,733,882,650 |
se_79391368 | stackoverflow | MACHINE_LEARNING | How to correctly use Sklearn | How to correctly use Sklearn
I've Python 3.12 interpreter in PyCharm.
I used in my code
from sklearn.preprocessing import MinMaxScaler
but when I tried to install sklearn package in PyCharm It told me that it was deprecated and to install "scikit learn"
I did it but when I ran it gave me this error "ModuleNotFoundEr... | https://stackoverflow.com/questions/79391368/how-to-correctly-use-sklearn | python, scikit-learn, pycharm | 1,737,992,971 |
se_79375192 | stackoverflow | MACHINE_LEARNING | How to define the search space for a simple equation optimization | How to define the search space for a simple equation optimization
I'm trying to learn skopt, but I'm struggling to get even a simple multivariate minimization to run.
import skopt
def black_box_function(some_x, some_y):
return -some_x + 2 - (some_y - 1) ** 2 + 1
BOUNDS = [(0, 100.0), (0, 100.0)]
result = skopt.... | https://stackoverflow.com/questions/79375192/how-to-define-the-search-space-for-a-simple-equation-optimization | python, scikit-learn, scikit-optimize | 1,737,477,334 |
se_79381220 | stackoverflow | MACHINE_LEARNING | Does GAFeatureSelectionCV support StratifiedGroupKFold cross validation? | Does GAFeatureSelectionCV support StratifiedGroupKFold cross validation?
I am attempting to use GAFeatureSelectionCV() from sklearn-genetic-opt to do feature selection.
On their GitHub, they show an example of how to specify a cross-validation strategy (e.g., StratifiedKFold) for GASearchCV(), which should also apply ... | https://stackoverflow.com/questions/79381220/does-gafeatureselectioncv-support-stratifiedgroupkfold-cross-validation | scikit-learn, feature-selection | 1,737,638,729 |
se_79385002 | stackoverflow | MACHINE_LEARNING | sklearn Gassian process with multiple targets vs gpytorch | sklearn Gassian process with multiple targets vs gpytorch
I am performing GaussianProcess regression of a function-to-function relationship. I have N different functions sampled at discrete points p to build an input X whose shape is N by p and these map row by row to a training output Y of the same shape. In scikit-l... | https://stackoverflow.com/questions/79385002/sklearn-gassian-process-with-multiple-targets-vs-gpytorch | scikit-learn, gaussian-process, gpytorch | 1,737,736,433 |
se_79387529 | stackoverflow | MACHINE_LEARNING | Function Calling Google GEMINI AI- TypeError: Invalid input type. Expected an instance of `genai.FunctionDeclarationType` | Function Calling Google GEMINI AI- TypeError: Invalid input type. Expected an instance of `genai.FunctionDeclarationType`
I am trying to run a simple Random Forest Classification Model using the iris dataset and integrate it into Gemini AI
Here is my code:
import google.generativeai as genai
from vertexai.preview.gene... | https://stackoverflow.com/questions/79387529/function-calling-google-gemini-ai-typeerror-invalid-input-type-expected-an-in | machine-learning, scikit-learn, artificial-intelligence, google-gemini | 1,737,839,231 |
se_76412782 | stackoverflow | MACHINE_LEARNING | TypeError: Feature names are only supported if all input features have string names, but your input has ['str', 'str_'] as column name types | TypeError: Feature names are only supported if all input features have string names, but your input has ['str', 'str_'] as column name types
When I try to fit the scikit-learn's StandardScaler into my pandas dataframe I get the following error:
TypeError: Feature names are only supported if all input ... | https://stackoverflow.com/questions/76412782/typeerror-feature-names-are-only-supported-if-all-input-features-have-string-na | python, pandas, scikit-learn | 1,686,040,217 |
se_65317685 | stackoverflow | MACHINE_LEARNING | How to create image of confusion matrix in Python | How to create image of confusion matrix in Python
I am new to Python and Machine Learning. I am working about multi-class classification (3 classes). I want to save confusion matrix as an image. Now, sklearn.metrics.confusion_matrix() helps me to find the confusion matrix like:
array([[35, 0, 6],
[0, 0, 3],
[5, ... | https://stackoverflow.com/questions/65317685/how-to-create-image-of-confusion-matrix-in-python | python, machine-learning, scikit-learn, confusion-matrix, multiclass-classification | 1,608,095,460 |
se_79372602 | stackoverflow | MACHINE_LEARNING | Pass parameters to custom transformer in sklearn | Pass parameters to custom transformer in sklearn
I am trying to pass a parameter DummyTransformer__feature_index_sec to my sklearn custom transformer via a pipeline. It seems like I need to implement metadata routing in order to do this. However, I cannot successfully create a working dummy example:
from sklearn.base... | https://stackoverflow.com/questions/79372602/pass-parameters-to-custom-transformer-in-sklearn | python, scikit-learn, scikit-learn-pipeline | 1,737,405,491 |
se_37659970 | stackoverflow | MACHINE_LEARNING | How does sklearn compute the precision_score metric? | How does sklearn compute the precision_score metric?
Hello I am working with sklearn and in order to understand better the metrics, I followed the following example of precision_score:
from sklearn.metrics import precision_score
y_true = [0, 1, 2, 0, 1, 2]
y_pred = [0, 2, 1, 0, 0, 1]
print(precision_scor... | https://stackoverflow.com/questions/37659970/how-does-sklearn-compute-the-precision-score-metric | scikit-learn | 1,465,223,127 |
se_20554074 | stackoverflow | MACHINE_LEARNING | sklearn OMP: Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models | sklearn OMP: Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models
I have recently uninstalled a nicely working copy of Enthought Canopy 32-bit and installed Canopy version 1.1.0 (64 bit). When I try to use sklearn to fit a model my kernel crashes, and I... | https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-initializing-libiomp5md-dll-but-found-mk2iomp5md-dll-a | python, scikit-learn, enthought, canopy | 1,386,881,770 |
se_31639016 | stackoverflow | MACHINE_LEARNING | In scikit's precision_recall_curve, why does thresholds have a different dimension from recall and precision? | In scikit's precision_recall_curve, why does thresholds have a different dimension from recall and precision?
I want to see how precision and recall vary with the threshold (not just with each other)
model = RandomForestClassifier(500, n_jobs = -1);
model.fit(X_train, y_train);
probas = model.predict_proba(X... | https://stackoverflow.com/questions/31639016/in-scikits-precision-recall-curve-why-does-thresholds-have-a-different-dimensi | python, python-2.7, scikit-learn, precision-recall | 1,437,926,369 |
se_70981876 | stackoverflow | MACHINE_LEARNING | Why does OvO and OvR return the same result? | Why does OvO and OvR return the same result?
I'm using scikit-learn's roc_auc_score() function for a multiclass classification problem. With iris which has three labels (and another dataset), I'm getting the exact same output when I use one-vs-one and one-vs-rest. Does anyone know why this is the case? Here's my code:... | https://stackoverflow.com/questions/70981876/why-does-ovo-and-ovr-return-the-same-result | python, machine-learning, scikit-learn, roc, multiclass-classification | 1,643,952,938 |
se_30355159 | stackoverflow | MACHINE_LEARNING | python: How to get real feature name from feature_importances | python: How to get real feature name from feature_importances
I am using Python's sklearn random forest (ensemble.RandomForestClassifier) to do classification and am using feature_importances_ to find significant feature for the classifier. Now my code is:
for trip in database:
venue_feature_start.append(Counter(... | https://stackoverflow.com/questions/30355159/python-how-to-get-real-feature-name-from-feature-importances | python, scikit-learn, classification, feature-selection | 1,432,138,561 |
se_79367571 | stackoverflow | MACHINE_LEARNING | Kernel-stop error occurred during shap-value calculation | Kernel-stop error occurred during shap-value calculation
I am trying to predict the occurrence of a certain phenomenon using about 9500 persons’ data with 36-37 predictor items using sklearn. It is a binary classification problem (occur or not-occur). Ultimately I want to predict whether this will happen to that perso... | https://stackoverflow.com/questions/79367571/kernel-stop-error-occurred-during-shap-value-calculation | python, scikit-learn, shap | 1,737,218,712 |
se_79370006 | stackoverflow | MACHINE_LEARNING | Error when performing ForecastingGridSearchCV | Error when performing ForecastingGridSearchCV
I'm trying to perform scaling on both y and X before fitting the forecast model. I want to make the scaling transformation optional. However, I encountered an error when performing the grid search above.
from sklearn.preprocessing import MinMaxScaler, PowerTransformer, Rob... | https://stackoverflow.com/questions/79370006/error-when-performing-forecastinggridsearchcv | python, scikit-learn | 1,737,332,491 |
se_79369299 | stackoverflow | MACHINE_LEARNING | Need help understanding different ways to calculate mean error in regression models | Need help understanding different ways to calculate mean error in regression models
New to python here, and have a series of questions on a Keras Sequential model build, getting different means, depending on how I calculate them.
Pasting below the relevant code, and questions follow.
def regression_model():
model ... | https://stackoverflow.com/questions/79369299/need-help-understanding-different-ways-to-calculate-mean-error-in-regression-mod | python, scikit-learn, mean | 1,737,303,851 |
se_79369011 | stackoverflow | MACHINE_LEARNING | Error in Pipeline code in ScikitLearn using Python | Error in Pipeline code in ScikitLearn using Python
In below code of pipeline. Even though i have encoded the sex column, i am getting string to float error.
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import One... | https://stackoverflow.com/questions/79369011/error-in-pipeline-code-in-scikitlearn-using-python | python, pandas, scikit-learn, scikit-learn-pipeline | 1,737,292,203 |
se_68731496 | stackoverflow | MACHINE_LEARNING | multiprocessing hangs xgboost scoring | multiprocessing hangs xgboost scoring
I am trying to score multiple datasets at the same time using multiprocessing. The following code hangs on run, yet when I run score on the base_model outside of the pool it executes instantly.
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_s... | https://stackoverflow.com/questions/68731496/multiprocessing-hangs-xgboost-scoring | python, scikit-learn, multiprocessing, xgboost | 1,628,618,054 |
se_79362356 | stackoverflow | MACHINE_LEARNING | use scikeras and scikit_learn | use scikeras and scikit_learn
After doing the data preprocessing, with the following code:
import tensorflow
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from scikeras.wrappers import KerasClassifier
from sklearn.model_selection import cross_val_score
from sklearn.mod... | https://stackoverflow.com/questions/79362356/use-scikeras-and-scikit-learn | python, scikit-learn, scikeras | 1,737,044,518 |
se_41925157 | stackoverflow | MACHINE_LEARNING | LogisticRegression: Unknown label type: 'continuous' using sklearn in python | LogisticRegression: Unknown label type: 'continuous' using sklearn in python
I have the following code to test some of most popular ML algorithms of sklearn python library:
import numpy as np
from sklearn import metrics, svm
from sklearn.linear_model import LinearRegression
fr... | https://stackoverflow.com/questions/41925157/logisticregression-unknown-label-type-continuous-using-sklearn-in-python | python, numpy, scikit-learn | 1,485,718,998 |
se_45532355 | stackoverflow | MACHINE_LEARNING | fit() Missing 1 Required Positional 'y' | fit() Missing 1 Required Positional 'y'
I am practicing a sklearn modeling on load_iris data. When I initiate LogisticRegression from sklearn.linear_model I receive an error when I try to fit the data:
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
logreg = Logisti... | https://stackoverflow.com/questions/45532355/fit-missing-1-required-positional-y | python, scikit-learn | 1,502,024,960 |
se_34727919 | stackoverflow | MACHINE_LEARNING | fit method in sklearn | fit method in sklearn
I am asking myself various questions about the fit method in sklearn.
Question 1: when I do:
from sklearn.decomposition import TruncatedSVD
model = TruncatedSVD()
svd_1 = model.fit(X1)
svd_2 = model.fit(X2)
Is the content of the variable model changing whatsoever during the process?
Question... | https://stackoverflow.com/questions/34727919/fit-method-in-sklearn | python, machine-learning, scikit-learn | 1,452,534,555 |
se_35585927 | stackoverflow | MACHINE_LEARNING | Calibration with xgboost | Calibration with xgboost
I'm wondering if I can do calibration in xgboost. To be more specific, does xgboost come with an existing calibration implementation like in scikit-learn, or are there some ways to put the model from xgboost into a scikit-learn's CalibratedClassifierCV?
As far as I know in sklearn this is the ... | https://stackoverflow.com/questions/35585927/calibration-with-xgboost | scikit-learn, xgboost | 1,456,254,016 |
se_79358955 | stackoverflow | MACHINE_LEARNING | Why lightgbm .predict function has probabilities not between 0 and 1? | Why lightgbm .predict function has probabilities not between 0 and 1?
I wanna understand why in this code, I get the following results:
# Import necessary libraries
import pandas as pd
from sklearn.metrics import f1_score
from sklearn.model_selection import train_test_split
from sklearn.metrics import f1_score, confus... | https://stackoverflow.com/questions/79358955/why-lightgbm-predict-function-has-probabilities-not-between-0-and-1 | python, scikit-learn, lightgbm | 1,736,957,478 |
se_79360038 | stackoverflow | MACHINE_LEARNING | Use cases for the .fit() method in Scikit-learn? | Use cases for the .fit() method in Scikit-learn?
Are there any instances/use cases where .fit() would be more practical than using .fit_transform()? For example, when label encoding:
encoder = LabelEncoder()
title = data['title']
encoder.fit(title)
title_encoded = encoder.transform(title)
vs
encoder = LabelEncoder()
... | https://stackoverflow.com/questions/79360038/use-cases-for-the-fit-method-in-scikit-learn | python, machine-learning, scikit-learn | 1,736,985,844 |
se_39839112 | stackoverflow | MACHINE_LEARNING | The easiest way for getting feature names after running SelectKBest in Scikit Learn | The easiest way for getting feature names after running SelectKBest in Scikit Learn
I'm trying to conduct a supervised machine-learning experiment using the SelectKBest feature of scikit-learn, but I'm not sure how to create a new dataframe after finding the best features:
Let's assume I would like to conduct the expe... | https://stackoverflow.com/questions/39839112/the-easiest-way-for-getting-feature-names-after-running-selectkbest-in-scikit-le | python, pandas, scikit-learn, feature-extraction, feature-selection | 1,475,523,315 |
se_54309849 | stackoverflow | MACHINE_LEARNING | Which estimators in scikit-learn support `partial_fit` API? | Which estimators in scikit-learn support `partial_fit` API?
Only examples of estimators that implement the partial_fit API that I can find are SGDRegressor and SGDClassifier. Are there others? Is there a list of estimators that implement the partial_fit API? | https://stackoverflow.com/questions/54309849/which-estimators-in-scikit-learn-support-partial-fit-api | python-3.x, scikit-learn | 1,548,165,250 |
se_58373488 | stackoverflow | MACHINE_LEARNING | Why does my sklearn.metrics confusion_matrix output look transposed? | Why does my sklearn.metrics confusion_matrix output look transposed?
It's my understanding that confusion matrices should show the TRUE classes in the columns and the PREDICTED classes in the rows. Therefore the sum of the columns should be equal to the value_counts() of the TRUE series.
I have provided an example he... | https://stackoverflow.com/questions/58373488/why-does-my-sklearn-metrics-confusion-matrix-output-look-transposed | python, scikit-learn, confusion-matrix | 1,571,044,156 |
se_79346376 | stackoverflow | MACHINE_LEARNING | sklearn.cluster KMeans creates a status heap memory corruption error 0xC0000374 | sklearn.cluster KMeans creates a status heap memory corruption error 0xC0000374
I have Windows 11 Home 24.2 Python 3.12.8 PyCharm Community Edition 2024.3 venv with pip 24.3.1 Numpy 2.2.1 Scikit-learn 1.6.1 Scipy 1.15.1 threadpoolctl 3.5.0 joblib 1.4.2
Python installation is fresh and new and other files run well (exc... | https://stackoverflow.com/questions/79346376/sklearn-cluster-kmeans-creates-a-status-heap-memory-corruption-error-0xc0000374 | python, scikit-learn, heap-corruption, python-3.12 | 1,736,527,057 |
se_69228024 | stackoverflow | MACHINE_LEARNING | How to retrieve the mapping generated from a category_encoder in python? | How to retrieve the mapping generated from a category_encoder in python?
I'm using the category encoder package in Python to use the Weight of Evidence encoder.
After I define an encoder object and fit it to data, the columns I wanted to encode are correctly replaced by their Weight of Evidence (WoE) values, according... | https://stackoverflow.com/questions/69228024/how-to-retrieve-the-mapping-generated-from-a-category-encoder-in-python | python, scikit-learn | 1,631,903,263 |
se_68456619 | stackoverflow | MACHINE_LEARNING | How can sklearn.linear_model.LinearRegression still find a solution in the multi-collinear dataset? | How can sklearn.linear_model.LinearRegression still find a solution in the multi-collinear dataset?
I tried to train a LinearRegression model using the extended_boston dataset:
from mglearn.datasets import load_extended_boston
X, y = load_extended_boston()
from sklearn.linear_model import LinearRegression
linearReg =... | https://stackoverflow.com/questions/68456619/how-can-sklearn-linear-model-linearregression-still-find-a-solution-in-the-multi | python, scikit-learn | 1,626,791,193 |
se_62376164 | stackoverflow | MACHINE_LEARNING | How to change max_iter in optimize function used by sklearn gaussian process regression? | How to change max_iter in optimize function used by sklearn gaussian process regression?
I am using sklearn's GPR library, but occasionally run into this annoying warning:
ConvergenceWarning: lbfgs failed to converge (status=2):
ABNORMAL_TERMINATION_IN_LNSRCH.
Increase the number of iterations (max_iter) or scale th... | https://stackoverflow.com/questions/62376164/how-to-change-max-iter-in-optimize-function-used-by-sklearn-gaussian-process-reg | python, scikit-learn, gaussian-process | 1,592,156,756 |
se_43210970 | stackoverflow | MACHINE_LEARNING | Predict training data in sklearn | Predict training data in sklearn
I use scikit-learn's SVM like so:
clf = svm.SVC()
clf.fit(td_X, td_y)
When I use the classifier to predict the class of a member of the training set, could the classifier ever be wrong even in scikit-learn implementation (eg. clf.predict(td_X[a])==td_Y[a])? | https://stackoverflow.com/questions/43210970/predict-training-data-in-sklearn | python, machine-learning, scikit-learn, svm | 1,491,318,276 |
se_51350585 | stackoverflow | MACHINE_LEARNING | Predictions using Support Vector Regression | Predictions using Support Vector Regression
In my problem there are four features(X); a,b,c,d and two dependents(Y); e,f. I have with me a data set containing a set of values for all these variables. How can I predict the values through Support Vector Regression using scikit-learn, for the e,f variables when new a,b,c... | https://stackoverflow.com/questions/51350585/predictions-using-support-vector-regression | python, machine-learning, scikit-learn, svm | 1,531,675,862 |
se_34365105 | stackoverflow | MACHINE_LEARNING | Combining probabilistic estimates with support vector machine in sklearn | Combining probabilistic estimates with support vector machine in sklearn
I'm currently using a support vector machine with scikit-learn to predict which item a user will buy given demographic data. The data set also includes how many users of a certain age group bought each item. It looked something like this:
item... | https://stackoverflow.com/questions/34365105/combining-probabilistic-estimates-with-support-vector-machine-in-sklearn | python, scikit-learn, svm, ensemble-learning | 1,450,478,965 |
se_71676507 | stackoverflow | MACHINE_LEARNING | Error , Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ram to unpickle a file | Error , Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ram to unpickle a file
I am running into this error , i can't unpickle a file on my jupyter notebook:
import os
import pickle
import joblib
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
filename = open("loan... | https://stackoverflow.com/questions/71676507/error-unsuccessful-tensorslicereader-constructor-failed-to-find-any-matching | python, tensorflow, scikit-learn, pickle, joblib | 1,648,640,248 |
se_48508127 | stackoverflow | MACHINE_LEARNING | How to get coefficients of multinomial logistic regression? | How to get coefficients of multinomial logistic regression?
I need to calculate coefficients of a multiple logistic regression using sklearn:
X =
x1 x2 x3 x4 x5 x6
0.300000 0.100000 0.0 0.0000 0.5 0.0
0.000000 0.006000 0.0 0.0000 0.2 0.0
0.010000 0.678000 ... | https://stackoverflow.com/questions/48508127/how-to-get-coefficients-of-multinomial-logistic-regression | python, pandas, scikit-learn, logistic-regression | 1,517,252,132 |
se_75649038 | stackoverflow | MACHINE_LEARNING | Training difference between LightGBM API and Sklearn API | Training difference between LightGBM API and Sklearn API
I'm trying to train a LGBClassifier for multiclass task. I tried first working directly with LightGBM API and set the model and training as follows:
LightGBM API
train_data = lgb.Dataset(X_train, (y_train-1))
test_data = lgb.Dataset(X_test, (y_test-1))
params = ... | https://stackoverflow.com/questions/75649038/training-difference-between-lightgbm-api-and-sklearn-api | python, machine-learning, scikit-learn, multiclass-classification, lightgbm | 1,678,094,670 |
se_79320289 | stackoverflow | MACHINE_LEARNING | Why can't I wrap LGBM? | Why can't I wrap LGBM?
I'm using LGBM to forecast the relative change of a numerical quantity. I'm using the MSLE (Mean Squared Log Error) loss function to optimize my model and to get the correct scaling of errors. Since MSLE isn't native to LGBM, I have to implement it myself. But lucky me, the math can be simpl... | https://stackoverflow.com/questions/79320289/why-cant-i-wrap-lgbm | python, machine-learning, scikit-learn, lightgbm | 1,735,658,717 |
se_69522280 | stackoverflow | MACHINE_LEARNING | Kernel Density Estimation (KDE) implementation in pytorch or tensorflow | Kernel Density Estimation (KDE) implementation in pytorch or tensorflow
I found an implementation of the Kernel density estimation in scikit-learn as:
from sklearn.neighbors import KernelDensity
kde = KernelDensity(bandwidth=1.0, kernel='gaussian')
kde.fit(x[:, None])
logprob = kde.score_samples(x_d[:, None])
The pro... | https://stackoverflow.com/questions/69522280/kernel-density-estimation-kde-implementation-in-pytorch-or-tensorflow | python, tensorflow, scikit-learn, pytorch | 1,633,936,128 |
se_60231102 | stackoverflow | MACHINE_LEARNING | Implementation of Cross-validation | Implementation of Cross-validation
I am confused since many individuals have their own approach to apply the cross-validation. For instance, some apply it on the whole dataset and some apply it on the training set.
My question is whether the below code is appropriate to implement cross-validation and make prediction... | https://stackoverflow.com/questions/60231102/implementation-of-cross-validation | machine-learning, scikit-learn, classification, cross-validation | 1,581,701,847 |
se_72638981 | stackoverflow | MACHINE_LEARNING | How does predict_proba work with cross-validation? | How does predict_proba work with cross-validation?
When using 5-fold cross-validation to create a model, 5 different models are created. The selection of the final model can vary:
best-estimated (or other criteria) model out of the 5-fold created model or
the model create when trained on all the datasets.
I understa... | https://stackoverflow.com/questions/72638981/how-does-predict-proba-work-with-cross-validation | machine-learning, scikit-learn, cross-validation, r-caret | 1,655,336,877 |
se_79337434 | stackoverflow | MACHINE_LEARNING | What's the best way to use a sklearn feature selector in a grid search, to evaluate the usefulness of all features? | What's the best way to use a sklearn feature selector in a grid search, to evaluate the usefulness of all features?
I am training a sklearn classifier, and inserted in a pipeline a feature selection step. Via grid search, I would like to determine what's the number of features that allows me to maximize performanc... | https://stackoverflow.com/questions/79337434/whats-the-best-way-to-use-a-sklearn-feature-selector-in-a-grid-search-to-evalu | python, machine-learning, scikit-learn | 1,736,285,957 |
se_79337075 | stackoverflow | MACHINE_LEARNING | AdaBoostClassifier: Perfect Metrics with test_size=0.25, but Inconsistent Samples Error for Other Values | AdaBoostClassifier: Perfect Metrics with test_size=0.25, but Inconsistent Samples Error for Other Values
I'm using AdaBoostClassifier with a weak learner (DecisionTreeClassifier) to classify a dataset. The dataset has 7857 samples:
X.shape
# Output: (7857, 5)
y.shape
# Output: (7857,)
Here’s the code for splitting t... | https://stackoverflow.com/questions/79337075/adaboostclassifier-perfect-metrics-with-test-size-0-25-but-inconsistent-sample | python, machine-learning, scikit-learn, adaboost | 1,736,276,422 |
se_55095703 | stackoverflow | MACHINE_LEARNING | Linear Model in Julia | Linear Model in Julia
I have a 2D array X, shown as
6-element Array{Array{T,1} where T,1}:
[0.962, 0.282, 0.19, 0.533, 2.032, 2.482, 0.863, 1.24, 0.819, 0.927 … 2.161, 0.967, 0.809, 1.22, 1.3, 1.307, 0.945, 1.02, 0.519, 0.837]
[11.0, 8.5625, 6.65, 6.68, 17.0, 11.75, 8.5625, 6.65, 7.54, 8.0 …... | https://stackoverflow.com/questions/55095703/linear-model-in-julia | scikit-learn, julia | 1,552,282,329 |
se_73401862 | stackoverflow | MACHINE_LEARNING | How to write a python function that will take a dataframe as input, normalize its columns with numeric data type and return the result | How to write a python function that will take a dataframe as input, normalize its columns with numeric data type and return the result
This is my first question here, so I apologize in advance.
I want to write a function that takes dataframe name as argument and applies MinMaxScaler() on the dataframe columns that hav... | https://stackoverflow.com/questions/73401862/how-to-write-a-python-function-that-will-take-a-dataframe-as-input-normalize-it | python, pandas, scikit-learn | 1,660,820,262 |
se_33898665 | stackoverflow | MACHINE_LEARNING | Python - generate array of specific autocorrelation | Python - generate array of specific autocorrelation
I am interested in generating an array(or numpy Series) of length N that will exhibit specific autocorrelation at lag 1. Ideally, I want to specify the mean and variance, as well, and have the data drawn from (multi)normal distribution. But most importantly, I want t... | https://stackoverflow.com/questions/33898665/python-generate-array-of-specific-autocorrelation | python, numpy, random, scikit-learn, correlation | 1,448,381,867 |
se_79327647 | stackoverflow | MACHINE_LEARNING | precision_recall_curve of negative class leading to positively correlated precision and recall | precision_recall_curve of negative class leading to positively correlated precision and recall
I have a logistic regression model to predict a binary output (0 or 1). I'd like to understand the P/R of the 0-class, and produce the respective curve. I use this code:
clf = linear_model.LogisticRegression().fit(ohe_X_trai... | https://stackoverflow.com/questions/79327647/precision-recall-curve-of-negative-class-leading-to-positively-correlated-precis | machine-learning, scikit-learn, classification, precision-recall | 1,735,937,109 |
se_79329171 | stackoverflow | MACHINE_LEARNING | Can't run pytest with a `FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-env-3fagdb36/normal/bin/ninja' ` | Can't run pytest with a `FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-env-3fagdb36/normal/bin/ninja' `
I have tried many things like upgrading pip, pytest etc etc but nothing works. I have a fork of scikit-learn and working on some new functionality and would like to run all the ... | https://stackoverflow.com/questions/79329171/cant-run-pytest-with-a-filenotfounderror-errno-2-no-such-file-or-directory | python, scikit-learn, pytest, runtime-error | 1,736,007,590 |
se_79330764 | stackoverflow | MACHINE_LEARNING | How can I silence `UndefinedMetricWarning`? | How can I silence `UndefinedMetricWarning`?
How can I silence the following warning while running GridSearchCV(model, params, cv=10, scoring='precision', verbose=1, n_jobs=20, refit=True)?
/opt/dev/myenv/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1531: UndefinedMetricWarning: Precision is ill-defin... | https://stackoverflow.com/questions/79330764/how-can-i-silence-undefinedmetricwarning | python, scikit-learn | 1,736,082,229 |
se_75633185 | stackoverflow | MACHINE_LEARNING | ImportError: cannot import name '_check_weights' from 'sklearn.neighbors._base' | ImportError: cannot import name '_check_weights' from 'sklearn.neighbors._base'
I am trying to do Missforest as a method for handling missing values in table data.
import sklearn
print(sklearn.__version__)
->1.2.1
import sklearn.neighbors._base
import sys
sys.modules['sklearn.neighbors.base'] = sklear... | https://stackoverflow.com/questions/75633185/importerror-cannot-import-name-check-weights-from-sklearn-neighbors-base | python, machine-learning, scikit-learn, missing-data | 1,677,894,523 |
se_21971709 | stackoverflow | MACHINE_LEARNING | How can you discover what features in a dataset are predictive? | How can you discover what features in a dataset are predictive?
I'm working on a machine learning algorithm for the dataset available here.
There are 26 columns of data. Most of it is pointless. How can I effectively and quickly determine what features are interesting - what features tell me one way or another whether... | https://stackoverflow.com/questions/21971709/how-can-you-discover-what-features-in-a-dataset-are-predictive | python, machine-learning, artificial-intelligence, scikit-learn, feature-detection | 1,393,176,529 |
se_78872220 | stackoverflow | MACHINE_LEARNING | Problem with Keras class weights and KeyError | Problem with Keras class weights and KeyError
I anticipate that I have seen the question: Keras class_weight error dictionary keys/values referring to the same problem, but the solution does not seem to help me.
With this code, where I just added some class weights because the data for binary classifications was very ... | https://stackoverflow.com/questions/78872220/problem-with-keras-class-weights-and-keyerror | python, keras, scikit-learn, neural-network, imbalanced-data | 1,723,655,727 |
se_79321937 | stackoverflow | MACHINE_LEARNING | Confusion Matrix not showing numbers in every portion of Heat Map | Confusion Matrix not showing numbers in every portion of Heat Map
The image is showing confusion matrix in which text which are numbers and color of image is same in result confusion matrix not showing the number in first row of confusion matrix
# calculate accuracy
from sklearn import metrics
result_N = metrics.con... | https://stackoverflow.com/questions/79321937/confusion-matrix-not-showing-numbers-in-every-portion-of-heat-map | python, machine-learning, scikit-learn, confusion-matrix | 1,735,748,529 |
se_66695899 | stackoverflow | MACHINE_LEARNING | XGBoostError: Unknown gbm type g - Running RandomGridSearchCV on XGBoostClassifier model | XGBoostError: Unknown gbm type g - Running RandomGridSearchCV on XGBoostClassifier model
I am running a RandomizedGridSearchCV on XGBoostClassifier with a set of parameters to run the Grid Search on, but while running the code for RandomizedGridCV the program runs into the following error -
C:\Users\Shikhar\AppData\Ro... | https://stackoverflow.com/questions/66695899/xgboosterror-unknown-gbm-type-g-running-randomgridsearchcv-on-xgboostclassifi | python, scikit-learn, xgboost, grid-search | 1,616,087,636 |
se_53634808 | stackoverflow | MACHINE_LEARNING | How to improve performance of random forest multiclass classification model? | How to improve performance of random forest multiclass classification model?
I am working on a multi class classification for segmenting customers into 3 different classes based on their purchasing behavior and demographics. I cannot disclose the data set completely but in general it contains around 300 features and ... | https://stackoverflow.com/questions/53634808/how-to-improve-performance-of-random-forest-multiclass-classification-model | python, machine-learning, scikit-learn, random-forest | 1,544,020,987 |
se_35723472 | stackoverflow | MACHINE_LEARNING | How to use sklearn fit_transform with pandas and return dataframe instead of numpy array? | How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?
I want to apply scaling (using StandardScaler() from sklearn.preprocessing) to a pandas dataframe. The following code returns a numpy array, so I lose all the column names and indeces. This is not what I want.
features = df[["co... | https://stackoverflow.com/questions/35723472/how-to-use-sklearn-fit-transform-with-pandas-and-return-dataframe-instead-of-num | python, numpy, pandas, scikit-learn | 1,456,836,706 |
se_21819953 | stackoverflow | MACHINE_LEARNING | How to graph Learning Curve of Logistic Regression? | How to graph Learning Curve of Logistic Regression?
I am running a Logistic Regression and would like to plot the Learning Curve of this to get a feel for the data. Here is my code thus far:
from sklearn import metrics,preprocessing,cross_validation
from sklearn.feature_extraction.text import TfidfVectorizer
impo... | https://stackoverflow.com/questions/21819953/how-to-graph-learning-curve-of-logistic-regression | python, python-2.7, graph, matplotlib, scikit-learn | 1,392,605,878 |
se_78158192 | stackoverflow | MACHINE_LEARNING | Scikit-learn import error during Vercel deployment | Scikit-learn import error during Vercel deployment
I'm deploying a Flask chatbot backend to Vercel. I'm using scikit-learn (sklearn) to train my model, but it's not required during the chatbot's runtime.
During deployment, I encounter the following error:
LAMBDA_WARNING: Unhandled exception. The most likely cause is a... | https://stackoverflow.com/questions/78158192/scikit-learn-import-error-during-vercel-deployment | python, aws-lambda, scikit-learn, vercel | 1,710,392,303 |
se_20357705 | stackoverflow | MACHINE_LEARNING | scikit-learn cross-validation over-fitting or under-fitting | scikit-learn cross-validation over-fitting or under-fitting
I'm using scikit-learn cross_validation and get for example 0.82 mean score (r2_scorer).
How could I know do I have over-fitting or under-fitting using scikit-learn functions? | https://stackoverflow.com/questions/20357705/scikit-learn-cross-validation-over-fitting-or-under-fitting | machine-learning, scikit-learn, overfitting-underfitting | 1,386,091,503 |
se_77748547 | stackoverflow | MACHINE_LEARNING | The feature names should match those that were passed during fit | The feature names should match those that were passed during fit
Im trying to calculate the r squared value after the creation of a model using sklearn linear regression.
Im simply
importing a csv dataset
filtering the interesting columns
splitting the dataset in train and test
creating the model
making a prediction ... | https://stackoverflow.com/questions/77748547/the-feature-names-should-match-those-that-were-passed-during-fit | python-3.x, pandas, machine-learning, scikit-learn, linear-regression | 1,704,229,289 |
se_79269801 | stackoverflow | MACHINE_LEARNING | KNeighborsClassifier predict throws "Expected 2D array, got 1D array instead" | KNeighborsClassifier predict throws "Expected 2D array, got 1D array instead"
I am writing an image similarity algorithm. I am using cv2.calcHist to extract image features. After the features are created I save them to a json file as a list of numpy.float64:
list(numpy.float64(features)), this is a multidime... | https://stackoverflow.com/questions/79269801/kneighborsclassifier-predict-throws-expected-2d-array-got-1d-array-instead | python, json, image-processing, scikit-learn, knn | 1,733,864,591 |
se_79297842 | stackoverflow | MACHINE_LEARNING | Optimizing feature extraction with sklearn tfidf | Optimizing feature extraction with sklearn tfidf
I'm working on a Python project that mimics https://www.mtgassist.com/. For those not too familiar: Magic is a trading card game that has collectible cards that can be very expensive. The project should take the name of a card and list other cards that have similar mech... | https://stackoverflow.com/questions/79297842/optimizing-feature-extraction-with-sklearn-tfidf | scikit-learn, feature-extraction | 1,734,712,004 |
se_49167070 | stackoverflow | MACHINE_LEARNING | Cross Validation Python Sklearn | Cross Validation Python Sklearn
I want to do Cross Validation on my SVM classifier before using it on the actual test set. What I want to ask is do I do the cross validation on the original dataset or on the training set, which is the result of train_test_split() function?
import pandas as pd
from sklearn.model_selec... | https://stackoverflow.com/questions/49167070/cross-validation-python-sklearn | python, scikit-learn, classification, svm, cross-validation | 1,520,491,900 |
se_79231707 | stackoverflow | MACHINE_LEARNING | sklearn, gridsearchCV checkpoint | sklearn, gridsearchCV checkpoint
Is there a way to provide checkpointing to GridSearchCV in sklearn? I would love to be able to resume an interrupted search. I'm using the full set of results to plot the evaluation metric scores, hence it would be great to be able to resume with the results of previously examined para... | https://stackoverflow.com/questions/79231707/sklearn-gridsearchcv-checkpoint | scikit-learn, grid-search | 1,732,737,171 |
se_79245905 | stackoverflow | MACHINE_LEARNING | Sagemaker's SklearnModel requirements.txt not getting installed | Sagemaker's SklearnModel requirements.txt not getting installed
This is my code:
from sagemaker.sklearn import SKLearnModel
role = sagemaker.get_execution_role()
model = SKLearnModel(
model_data= f"s3://{default_bucket}/{prefix}/model.tar.gz",
role=role,
entry_point="inference.py",
framewo... | https://stackoverflow.com/questions/79245905/sagemakers-sklearnmodel-requirements-txt-not-getting-installed | python, amazon-web-services, scikit-learn, amazon-sagemaker | 1,733,183,491 |
se_79298012 | stackoverflow | MACHINE_LEARNING | Python scikit-learn memory leak | Python scikit-learn memory leak
This simple python code causes memory leak at each loop cycle. The leak only happens when when n_jobs parameter is not 1.
Is there something I'm missing or any way to free memory leak caused by library?
import gc
import numpy as np
from sklearn.manifold import TSNE
from sklearn.cluster ... | https://stackoverflow.com/questions/79298012/python-scikit-learn-memory-leak | python, scikit-learn, memory-leaks | 1,734,716,499 |
se_79291704 | stackoverflow | MACHINE_LEARNING | Splitting multivariate time series data to avoid data leakage in PyTorch? | Splitting multivariate time series data to avoid data leakage in PyTorch?
I have two predictors A and B with the goal to predict target (y) C using a multi-layer ANN. My inputs are 2D combinations of time series using 1 hour of A and 30 minutes of B for prediction.
Assume we are predicting C at time t = 0, then the in... | https://stackoverflow.com/questions/79291704/splitting-multivariate-time-series-data-to-avoid-data-leakage-in-pytorch | python, scikit-learn, pytorch, time-series | 1,734,536,899 |
se_22409855 | stackoverflow | MACHINE_LEARNING | RandomForestClassifier vs ExtraTreesClassifier in scikit learn | RandomForestClassifier vs ExtraTreesClassifier in scikit learn
Can anyone explain the difference between the RandomForestClassifier and ExtraTreesClassifier in scikit learn. I've spent a good bit of time reading the paper:
P. Geurts, D. Ernst., and L. Wehenkel, “Extremely randomized trees”, Machine Learning, 63(1), ... | https://stackoverflow.com/questions/22409855/randomforestclassifier-vs-extratreesclassifier-in-scikit-learn | scikit-learn, random-forest | 1,394,812,251 |
se_79288501 | stackoverflow | MACHINE_LEARNING | HistGradientBoostingClassifier - ValueError: could not convert string to float | HistGradientBoostingClassifier - ValueError: could not convert string to float
I'm running a HistGradientBoostingClassifier with some categorical features, and I'm getting ValueError: could not convert string to float. I defined the categorical features through the categorical_features parameter.
The documentation on ... | https://stackoverflow.com/questions/79288501/histgradientboostingclassifier-valueerror-could-not-convert-string-to-float | python, scikit-learn, boosting | 1,734,450,254 |
se_79289735 | stackoverflow | MACHINE_LEARNING | Model Training for Segmentation | Model Training for Segmentation
I want to train and evaluate models to find the best models for my segments, but sklearn is having something go wrong with the tags and the estimators, and I can't figure out the issue. There might be something wrong with the tags.py, base.py, and search.py scripts, but I'm not certain ... | https://stackoverflow.com/questions/79289735/model-training-for-segmentation | python, pandas, scikit-learn, xgboost | 1,734,484,643 |
se_52833348 | stackoverflow | MACHINE_LEARNING | Calculate the predicted model accuracy in python for regression problem | Calculate the predicted model accuracy in python for regression problem
I want to calculate my model accuracy for rainfall forecasting. I already calculated MAE, RMSE, MAPE for rainfall forecasting. But want to know the total model accuracy, for instance, my model is predicting 96% accurate results. How can I do this ... | https://stackoverflow.com/questions/52833348/calculate-the-predicted-model-accuracy-in-python-for-regression-problem | python, python-3.x, scikit-learn, non-linear-regression | 1,539,685,611 |
se_79281350 | stackoverflow | MACHINE_LEARNING | Getting "TypeError: ufunc 'isnan' not supported for the input types" | Getting "TypeError: ufunc 'isnan' not supported for the input types"
I am doing a Machine Learning project to predict the prices of electric cars on Jupyter Notebook.
I run these cells:
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
cols = ['County', 'City', 'State', 'ZIP Code', ... | https://stackoverflow.com/questions/79281350/getting-typeerror-ufunc-isnan-not-supported-for-the-input-types | python, machine-learning, scikit-learn | 1,734,207,799 |
se_49885007 | stackoverflow | MACHINE_LEARNING | How to use scikit learn inverse_transform with new values | How to use scikit learn inverse_transform with new values
I have a set of data that I have used scikit learn PCA. I scaled the data before performing PCA with StandardScaler().
variance_to_retain = 0.99
np_scaled = StandardScaler().fit_transform(df_data)
pca = PCA(n_components=variance_to_retain)
np_pca = pca.fit_tran... | https://stackoverflow.com/questions/49885007/how-to-use-scikit-learn-inverse-transform-with-new-values | python, scikit-learn, pca | 1,523,989,422 |
se_79271439 | stackoverflow | MACHINE_LEARNING | Create custom kernel for GPR | Create custom kernel for GPR
I would like to write a RBF kernel that is working only in a specific range on X axis. I tried to write a class that contains a RBF kernel to test the code
class RangeLimitedRBFTest(Kernel):
def __init__(self, length_scale=1.0, length_scale_bounds=(1e-5, 1e5), x_min = 0., x_max = 1.):
... | https://stackoverflow.com/questions/79271439/create-custom-kernel-for-gpr | python, machine-learning, scikit-learn, gaussian-process | 1,733,914,816 |
se_79281735 | stackoverflow | MACHINE_LEARNING | How do I configure the function r2_score from SciKit-Learn to recognize that I have installed PyTorch that uses GPU? | How do I configure the function r2_score from SciKit-Learn to recognize that I have installed PyTorch that uses GPU?
I am new to PyTorch, and I have just installed it and run a somewhat Hello-World example.
First of all, I installed PyTorch as follows.
$ pip3 install torch torchvision torchaudio --index-url https://do... | https://stackoverflow.com/questions/79281735/how-do-i-configure-the-function-r2-score-from-scikit-learn-to-recognize-that-i-h | scikit-learn, pytorch | 1,734,231,383 |
se_69468059 | stackoverflow | MACHINE_LEARNING | How to perform linear regression in sklearn with a custom loss function | How to perform linear regression in sklearn with a custom loss function
I am running a linear regression in sklearn
model = LinearRegression()
model.fit(x_poly, y_true)
Instead of using the standard loss function (I think is MSE) to fit my linear regression. I would like to define a distance metric with a sym... | https://stackoverflow.com/questions/69468059/how-to-perform-linear-regression-in-sklearn-with-a-custom-loss-function | python, scikit-learn, linear-regression | 1,633,532,182 |
se_52173203 | stackoverflow | MACHINE_LEARNING | How do I force clustering of data in a specific evident pattern? | How do I force clustering of data in a specific evident pattern?
I have a large set of 'Vehicle speed vs Engine RPM' values for a vehicle. I'm try to predict the time spent by the vehicle on each gear.
I ran K-Means clustering on the dataset and got the following result:
Clearly, my algorithm has failed to capture ... | https://stackoverflow.com/questions/52173203/how-do-i-force-clustering-of-data-in-a-specific-evident-pattern | python, scikit-learn, data-science | 1,536,091,009 |
se_79277258 | stackoverflow | MACHINE_LEARNING | How to save XGBoost model in ipynb and load in javascript in order to call the model and prompt input from user and get predicted value? | How to save XGBoost model in ipynb and load in javascript in order to call the model and prompt input from user and get predicted value?
How can I link the trained model (ipynb or python file in local) into javascript (Front-end?
I have a trained XGB model using some features(float) to predict one
value (carbon inten... | https://stackoverflow.com/questions/79277258/how-to-save-xgboost-model-in-ipynb-and-load-in-javascript-in-order-to-call-the-m | javascript, python, machine-learning, scikit-learn, frontend | 1,734,065,493 |
se_78228322 | stackoverflow | MACHINE_LEARNING | I am trying to build an AI image classifier in Python using a youtube guide. When I run my program (unfinished) it does not open up the image | I am trying to build an AI image classifier in Python using a youtube guide. When I run my program (unfinished) it does not open up the image
I am trying to build an AI image classifier using a youtube guide for a school project. Here is the link: https://www.youtube.com/watch?v=oEKg_jiV1Ng&t=727s
At this stage, I am ... | https://stackoverflow.com/questions/78228322/i-am-trying-to-build-an-ai-image-classifier-in-python-using-a-youtube-guide-whe | python, scikit-learn, pytorch, python-imaging-library | 1,711,489,449 |
se_39001956 | stackoverflow | MACHINE_LEARNING | sklearn pipeline - how to apply different transformations on different columns | sklearn pipeline - how to apply different transformations on different columns
I have a dataset that has a mixture of text and numbers i.e. certain columns have text only and rest have integers (or floating point numbers).
I was wondering if it was possible to build a pipeline where I can for example call LabelEncoder... | https://stackoverflow.com/questions/39001956/sklearn-pipeline-how-to-apply-different-transformations-on-different-columns | python, scikit-learn, pipeline, scikit-learn-pipeline | 1,471,451,643 |
se_39258158 | stackoverflow | MACHINE_LEARNING | How do I apply one hot encoding on a pandas dataframe with both categorical and numerical features? | How do I apply one hot encoding on a pandas dataframe with both categorical and numerical features?
Some features are numerical such as "graduation rate from school", while other features are categorical like the name of the school. I used a label encoder on the features that are categorical to transform them into int... | https://stackoverflow.com/questions/39258158/how-do-i-apply-one-hot-encoding-on-a-pandas-dataframe-with-both-categorical-and | pandas, python-2.7, machine-learning, scikit-learn, one-hot-encoding | 1,472,674,009 |
se_67197522 | stackoverflow | MACHINE_LEARNING | What is the best way to encode a large number of categorical features? | What is the best way to encode a large number of categorical features?
I'm trying to make a small data science tool (kinda like a mini version of WEKA). Now, I have these datasets that have large amounts of features (70-100+), and they're mostly categorical. I'm using Python sklearn for the Machine Learning logic and ... | https://stackoverflow.com/questions/67197522/what-is-the-best-way-to-encode-a-large-number-of-categorical-features | machine-learning, scikit-learn, weka, categorical-data | 1,619,014,039 |
se_79032788 | stackoverflow | MACHINE_LEARNING | How to Perform Inference in Spark with an XGBoost Model Trained in scikit-learn? | How to Perform Inference in Spark with an XGBoost Model Trained in scikit-learn?
I found one xgboost model which was trained using sklearn in native python.
How can I use that model to produce inference on new dataset in pyspark?
Apart from using UDFs, what other options do I have? | https://stackoverflow.com/questions/79032788/how-to-perform-inference-in-spark-with-an-xgboost-model-trained-in-scikit-learn | pyspark, scikit-learn, xgboost, apache-spark-mllib, apache-spark-ml | 1,727,468,076 |
se_79268711 | stackoverflow | MACHINE_LEARNING | ValueError: could not convert string to float: 'N/' | ValueError: could not convert string to float: 'N/'
I am working on a Machine Learning project that predicts the price electric cars on Jupyter Notebook.
I run this cell on Jupyter Notebook:
p = regressor.predict(df2)
I get this error:
ValueError Traceback (most recent call last... | https://stackoverflow.com/questions/79268711/valueerror-could-not-convert-string-to-float-n | python, machine-learning, scikit-learn | 1,733,842,814 |
se_79263163 | stackoverflow | MACHINE_LEARNING | skfolio how to set various parameters | skfolio how to set various parameters
I have started using skfolio using a portfolio given in skfolio.datasets (sp500). My idea is to run a portfolio of equally weighted names using the sp500 as my universe. For this I do the following:
import skfolio
from skfolio.datasets import load_sp500_dataset
from skfolio.prepro... | https://stackoverflow.com/questions/79263163/skfolio-how-to-set-various-parameters | python-3.x, optimization, scikit-learn, portfolio | 1,733,684,693 |
se_35812074 | stackoverflow | MACHINE_LEARNING | Shortest Syntax To Use numpy 1d-array As sklearn X | Shortest Syntax To Use numpy 1d-array As sklearn X
I often have two numpy 1d arrays, x and y, and would like to perform some quick sklearn fitting + prediction using them.
import numpy as np
from sklearn import linear_model
# This is an example for the 1d aspect - it's obtained from something else.
x = np.array(... | https://stackoverflow.com/questions/35812074/shortest-syntax-to-use-numpy-1d-array-as-sklearn-x | python, numpy, scikit-learn | 1,457,167,843 |
se_79267421 | stackoverflow | MACHINE_LEARNING | Scikit-learn estimator that accepts non array-like input | Scikit-learn estimator that accepts non array-like input
I am developing a scikit-learn estimator, the documentation states that the input "X" for the .fit() method should be an "array-like of shape (n_samples, n_features)".
However, my estimator takes as input a list of objects (nx Graphs).
What is the best practice ... | https://stackoverflow.com/questions/79267421/scikit-learn-estimator-that-accepts-non-array-like-input | python, scikit-learn, networkx | 1,733,817,735 |
se_70864176 | stackoverflow | MACHINE_LEARNING | NotFittedError: This DecisionTreeClassifier instance is not fitted yet | NotFittedError: This DecisionTreeClassifier instance is not fitted yet
Am trying to run a decision tree based model. I tried the below:
X = df[['Quantity']]
y = df[['label']]
params = {'max_depth':[2,3,4], 'min_samples_split':[2,3,5,10]}
clf_dt = DecisionTreeClassifier()
clf = GridSearchCV(clf_dt, param_grid=params, s... | https://stackoverflow.com/questions/70864176/notfittederror-this-decisiontreeclassifier-instance-is-not-fitted-yet | python, machine-learning, scikit-learn, classification, decision-tree | 1,643,203,712 |
se_74928705 | stackoverflow | MACHINE_LEARNING | sklearn.exceptions.NotFittedError: This DecisionTreeClassifier instance is not fitted yet | sklearn.exceptions.NotFittedError: This DecisionTreeClassifier instance is not fitted yet
im trying to visualize decision tree with using mode from image data in python without graphviz using DecisionTreeClassifier but i keep getting error
sklearn.exceptions.NotFittedError: This DecisionTreeClassifier instance is not... | https://stackoverflow.com/questions/74928705/sklearn-exceptions-notfittederror-this-decisiontreeclassifier-instance-is-not-f | python, machine-learning, scikit-learn, decision-tree | 1,672,140,489 |
se_65470930 | stackoverflow | MACHINE_LEARNING | Dimensionality Reduction – PCA explanation | Dimensionality Reduction – PCA explanation
I don't think I have a good understanding of PCA, can someone help with my confusion below please?
Take iris dataset as an example, I have 4 covariates, x1:sepal length; x2:sepal width; x3:petal length; x4:petal width. And the formula can be seen below, a1,a2,a3,a4 are the we... | https://stackoverflow.com/questions/65470930/dimensionality-reduction-pca-explanation | python, machine-learning, scikit-learn, pca, dimensionality-reduction | 1,609,106,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.