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_46113732 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'sklearn' | ModuleNotFoundError: No module named 'sklearn'
I want to import scikit-learn, but there isn't any module apparently:
ModuleNotFoundError: No module named 'sklearn'
I am using Anaconda and Python 3.6.1.
When I use the command:
conda install scikit-learn, should this not just work?
Where does Anaconda install t... | https://stackoverflow.com/questions/46113732/modulenotfounderror-no-module-named-sklearn | python, scikit-learn, anaconda, package, conda | 1,504,864,568 |
se_39463675 | stackoverflow | MACHINE_LEARNING | Unexpected StandardScaler fit_transform output | Unexpected StandardScaler fit_transform output
I am trying to scale a pandas Series with StandardScaler().fit_transform(). However, the output is always an array of zeros.
The input Series has a length of 201, when I do:
print values[:5]
I get a list of floats as below:
0 1943.0
1 508.0
2 1657.0
3 ... | https://stackoverflow.com/questions/39463675/unexpected-standardscaler-fit-transform-output | python, scikit-learn | 1,473,748,827 |
se_46555820 | stackoverflow | MACHINE_LEARNING | sklearn StandardScaler returns all zeros | sklearn StandardScaler returns all zeros
I have a sklearn StandardScaler saved from a previous model and am trying to apply it to new data
scaler = myOldStandardScaler
print("ORIG:", X)
print("CLASS:", X.__class__)
X = scaler.fit_transform(X)
print("SCALED:", X)
I have three observations each with 2000 features. If... | https://stackoverflow.com/questions/46555820/sklearn-standardscaler-returns-all-zeros | python, scikit-learn | 1,507,081,523 |
se_36846795 | stackoverflow | MACHINE_LEARNING | Support Vector Machine. Precision and/or accuracy? | Support Vector Machine. Precision and/or accuracy?
I am trying to figure whether the code I use calculates precision or accuracy or both. Since I only have a little background in statistics (in another language) I don't really understand the Wikipedia article covering that topic.
Concretely I use following Python code... | https://stackoverflow.com/questions/36846795/support-vector-machine-precision-and-or-accuracy | python, machine-learning, scikit-learn, svm | 1,461,603,817 |
se_29586323 | stackoverflow | MACHINE_LEARNING | How to retain column headers of data frame after Pre-processing in scikit-learn | How to retain column headers of data frame after Pre-processing in scikit-learn
I have a pandas data frame which has some rows and columns. Each column has a header. Now as long as I keep doing data manipulation operations in pandas, my variable headers are retained. But if I try some data pre-processing feature of Sc... | https://stackoverflow.com/questions/29586323/how-to-retain-column-headers-of-data-frame-after-pre-processing-in-scikit-learn | python, numpy, pandas, scikit-learn | 1,428,816,905 |
se_34550577 | stackoverflow | MACHINE_LEARNING | Sci-Kit Learn: Investigating Incorrectly Classified Data | Sci-Kit Learn: Investigating Incorrectly Classified Data
I want to analyze data that has been incorrectly classified by a model using sci-kit learn, so that I can improve my feature generation. I have a method for doing this, but I am both new to sci-kit learn and pandas, so I'd like to know if there is a more efficie... | https://stackoverflow.com/questions/34550577/sci-kit-learn-investigating-incorrectly-classified-data | python, machine-learning, scikit-learn | 1,451,588,098 |
se_56177767 | stackoverflow | MACHINE_LEARNING | How to scale back predicted data with skLearn MinMaxScaler()? | How to scale back predicted data with skLearn MinMaxScaler()?
I am creating a neural network to denoise music.
The input to the model is an array that is scaled from 0 to 1. This is achieved using sklearn MinMaxScaler. The original range of the data is from -1 to 1. The output of the model is also an array scaled fr... | https://stackoverflow.com/questions/56177767/how-to-scale-back-predicted-data-with-sklearn-minmaxscaler | python, machine-learning, scikit-learn | 1,558,049,186 |
se_20772601 | stackoverflow | MACHINE_LEARNING | Cross validation with precision scoring for a subset of classes | Cross validation with precision scoring for a subset of classes
I have a dataset for classification with 3 class labels [0,1,2].
I want to run cross validation and try several estimators, but I am interested in scoring with precision of only classes 1 and 2. I don't care about the precision of class 0, and I don't wa... | https://stackoverflow.com/questions/20772601/cross-validation-with-precision-scoring-for-a-subset-of-classes | python, machine-learning, cross-validation, scikit-learn | 1,387,973,034 |
se_55701697 | stackoverflow | MACHINE_LEARNING | AUC for ROC curve in sklearn | AUC for ROC curve in sklearn
I am trying to understand how the ROC curve works for AUC.
y_pred = clf.predict(X2)
probs = clf.predict_proba(X2)
# keep probabilities for the positive outcome only
probs = probs[:, 1]
# calculate AUC
auc = roc_auc_score(y_true, probs)
When i ran probs = probs[:,1] i got an AUC of 0.66... | https://stackoverflow.com/questions/55701697/auc-for-roc-curve-in-sklearn | python, scikit-learn | 1,555,395,444 |
se_67678705 | stackoverflow | MACHINE_LEARNING | Using Precision Recall AUC as a scoring metric in cross validation | Using Precision Recall AUC as a scoring metric in cross validation
I would like to use the AUC for the Precision and Recall curve as a metric to train my model.
Do I need to make a specific scorer for this when using cross validation?
Consider the below reproducible example. Note the imbalanced target variable.
from s... | https://stackoverflow.com/questions/67678705/using-precision-recall-auc-as-a-scoring-metric-in-cross-validation | python-3.x, scikit-learn | 1,621,888,795 |
se_42843352 | stackoverflow | MACHINE_LEARNING | Is there a way to save the preprocessing objects in scikit-learn? | Is there a way to save the preprocessing objects in scikit-learn?
I am building a neural net with the purpose of make predictions on new data in the future. I first preprocess the training data using sklearn.preprocessing, then train the model, then make some predictions, then close the program. In the future, when ne... | https://stackoverflow.com/questions/42843352/is-there-a-way-to-save-the-preprocessing-objects-in-scikit-learn | machine-learning, scikit-learn, preprocessor | 1,489,692,996 |
se_65907089 | stackoverflow | MACHINE_LEARNING | Saving sklearn scaler objects to json instead of pickling | Saving sklearn scaler objects to json instead of pickling
Is there an accepted solution to saving sklearn objects to json, instead of pickling them?
I'm interested in this because saving to json will take up much less storage and make saving the objects to db's like redis much more straightforward.
In particular, for ... | https://stackoverflow.com/questions/65907089/saving-sklearn-scaler-objects-to-json-instead-of-pickling | python, scikit-learn | 1,611,685,506 |
se_73053195 | stackoverflow | MACHINE_LEARNING | Saving a scaler in a model | Saving a scaler in a model
I'm using the following scaler:
scaler = preprocessing.MinMaxScaler()
X_train = pd.DataFrame(scaler.fit_transform(dataset_train),
columns=dataset_train.columns,
index=dataset_train.index)
X_train.sample(frac=1)
X_test = pd.Data... | https://stackoverflow.com/questions/73053195/saving-a-scaler-in-a-model | python, machine-learning, scikit-learn | 1,658,326,144 |
se_51688568 | stackoverflow | MACHINE_LEARNING | Faster kNN Classification Algorithm in Python | Faster kNN Classification Algorithm in Python
I want to code my own kNN algorithm from scratch, the reason is that I need to weight the features. The problem is that my program is still really slow despite removing for loops and using built in numpy functionality.
Can anyone suggest a way to speed this up? I don't us... | https://stackoverflow.com/questions/51688568/faster-knn-classification-algorithm-in-python | python, machine-learning, scikit-learn, knn | 1,533,407,964 |
se_50625975 | stackoverflow | MACHINE_LEARNING | TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'q') | TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'q')
I am trying to apply Gower distance implementation to my data frame. While it was smoothly working with the same dataset with more features, this time it gives an error when I c... | https://stackoverflow.com/questions/50625975/typeerror-ufunc-true-divide-output-typecode-d-could-not-be-coerced-to-pro | python, python-3.x, numpy, scikit-learn, typeerror | 1,527,774,805 |
se_79459969 | stackoverflow | MACHINE_LEARNING | Plotting one Decision Tree of a Random Forest in sklearn | Plotting one Decision Tree of a Random Forest in sklearn
I have come around a strange thing when plotting a decision tree in sklearn.
I just wanted to compare a Random Forest model consisting of one estimator using bootstrapping and one without bootstrapping.
I am using a toy dataset with sample size n = 5.
My code lo... | https://stackoverflow.com/questions/79459969/plotting-one-decision-tree-of-a-random-forest-in-sklearn | scikit-learn, random-forest, decision-tree | 1,740,243,508 |
se_54619366 | stackoverflow | MACHINE_LEARNING | Control the number of CPU cores sklearn MLPClassifier uses? | Control the number of CPU cores sklearn MLPClassifier uses?
The MLPClassifier in sklearn.neural_network seems to use a lot of available CPU cores, i.e. the python process starts using 50% of processing power when fitting the model. How to prevent this? Is it possible? From the documentation it seem that there is no n_... | https://stackoverflow.com/questions/54619366/control-the-number-of-cpu-cores-sklearn-mlpclassifier-uses | python, scikit-learn, cpu-cores | 1,549,821,783 |
se_55880598 | stackoverflow | MACHINE_LEARNING | Predict probability of predicted class | Predict probability of predicted class
I have a dataset containing the GPA, GRE, TOEFL, SOP&LOR Ranking(out of 5)etc. (all numerical) , and a final column that states whether or not they were admitted to a university(0 or 1), which is what we'll use as y_train.
I'm supposed to not just classify the predicted labels, b... | https://stackoverflow.com/questions/55880598/predict-probability-of-predicted-class | machine-learning, scikit-learn | 1,556,368,417 |
se_73914558 | stackoverflow | MACHINE_LEARNING | UserWarning: X does not have valid feature names, but DecisionTreeClassifier was fitted with feature names | UserWarning: X does not have valid feature names, but DecisionTreeClassifier was fitted with feature names
I am learning machine learning from Programming with Mosh channel.
I got desired output in this case.
output=array(['HipHop', 'Acoustic', 'Classical'], dtype=object)
but there is a warning like this and I cannot... | https://stackoverflow.com/questions/73914558/userwarning-x-does-not-have-valid-feature-names-but-decisiontreeclassifier-was | python, scikit-learn, decision-tree | 1,664,577,561 |
se_79483002 | stackoverflow | MACHINE_LEARNING | 'numpy.ndarray' object has no attribute 'groupby' | 'numpy.ndarray' object has no attribute 'groupby'
I am trying to apply target encoding to categorical features using the category_encoders.TargetEncoder in Python. However, I keep getting the following error:
AttributeError: 'numpy.ndarray' object has no attribute 'groupby'
from category_encoders impo... | https://stackoverflow.com/questions/79483002/numpy-ndarray-object-has-no-attribute-groupby | python, numpy, scikit-learn, numpy-ndarray | 1,741,075,257 |
se_76994608 | stackoverflow | MACHINE_LEARNING | How can I use sklearn's make_column_selector to select all valid datetime columns? | How can I use sklearn's make_column_selector to select all valid datetime columns?
I want to select columns based on their datetime data types. My DataFrame has for example columns with types np.dtype('datetime64[ns]'), np.datetime64 and 'datetime64[ns, UTC]'.
Is there a generic way to select all columns with a da... | https://stackoverflow.com/questions/76994608/how-can-i-use-sklearns-make-column-selector-to-select-all-valid-datetime-column | python, datetime, scikit-learn, scikit-learn-pipeline | 1,693,240,827 |
se_63380766 | stackoverflow | MACHINE_LEARNING | How to unscale data after predictions? | How to unscale data after predictions?
I have a dataset with 2 features (price & volume) & 1 predicted variable (price) and use LTSM model to predict next price based on the previous set of prices.
First I scale the dataset:
#Scale the data
scaler = MinMaxScaler(feature_range=(0,1))
scaled_data = scaler.fit_transform(... | https://stackoverflow.com/questions/63380766/how-to-unscale-data-after-predictions | python, machine-learning, scikit-learn | 1,597,249,250 |
se_33822948 | stackoverflow | MACHINE_LEARNING | Pandas + sklearn Linear regression fails | Pandas + sklearn Linear regression fails
I am trying to implement some linear regression model in Python. See the code below, which I've used to make a linear regression.
import pandas
salesPandas = pandas.DataFrame.from_csv('home_data.csv')
# check the shape of the DataFrame (rows, columns)
salesPandas.shape
(21613... | https://stackoverflow.com/questions/33822948/pandas-sklearn-linear-regression-fails | python, pandas, scikit-learn | 1,448,011,093 |
se_40830782 | stackoverflow | MACHINE_LEARNING | what is different between fit_transform, transform in sklearn and get_dummies in pandas? | what is different between fit_transform, transform in sklearn and get_dummies in pandas?
When I do data processing with one-hot-encoding in sklearn and pandas, I have two options:
1st way: train_data uses fit_transform and test_data uses transform only
2nd way: or I can use pandas get_dummies for both
What is diffe... | https://stackoverflow.com/questions/40830782/what-is-different-between-fit-transform-transform-in-sklearn-and-get-dummies-in | python, pandas, scikit-learn | 1,480,261,803 |
se_30851944 | stackoverflow | MACHINE_LEARNING | Using Pandas 'categorical' dtype with sklearn | Using Pandas 'categorical' dtype with sklearn
Is there any support in sklearn to use Panda's Categorical datatype directly in fitting models? From what I've seen sklearn does not support this datatype which is unfortunate because the Categorical datatype both encodes categorical data and contains the mapping s... | https://stackoverflow.com/questions/30851944/using-pandas-categorical-dtype-with-sklearn | python, pandas, scikit-learn, categorical-data | 1,434,391,328 |
se_56299142 | stackoverflow | MACHINE_LEARNING | How to use ColumnTransformer for categorical data? | How to use ColumnTransformer for categorical data?
I am trying to preprocess data.
data = {'Country':['Germany', 'Turkey', 'England', 'Turkey', 'Germany', 'Turkey'],
'Age':['44', '32', '27', '29', '31', '25'],
'Salary':['5400', '8500', '7200', '4800', '6200', '10850'],
'Purchased':['yes', 'yes... | https://stackoverflow.com/questions/56299142/how-to-use-columntransformer-for-categorical-data | python, scikit-learn | 1,558,729,499 |
se_17197492 | stackoverflow | MACHINE_LEARNING | Is there a library function for Root mean square error (RMSE) in python? | Is there a library function for Root mean square error (RMSE) in python?
I know I could implement a root mean squared error function like this:
def rmse(predictions, targets):
return np.sqrt(((predictions - targets) ** 2).mean())
What I'm looking for if this rmse function is implemented in a library somewhere, ... | https://stackoverflow.com/questions/17197492/is-there-a-library-function-for-root-mean-square-error-rmse-in-python | python, scikit-learn, scipy | 1,371,662,650 |
se_49671215 | stackoverflow | MACHINE_LEARNING | Cache entry deserialization failed, entry ignored | Cache entry deserialization failed, entry ignored
C:\Users\deypr>pip3 install sklearn
Collecting sklearn
Cache entry deserialization failed, entry ignored
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DEN... | https://stackoverflow.com/questions/49671215/cache-entry-deserialization-failed-entry-ignored | python, windows, ssl, scikit-learn, installation | 1,522,927,620 |
se_52356128 | stackoverflow | MACHINE_LEARNING | how to set up the initial value for curve_fit to find the best optimizing, not just local optimizing? | how to set up the initial value for curve_fit to find the best optimizing, not just local optimizing?
I am trying to fit a power-law function, and in order to find the best fit parameter. However, I find that if the initial guess of parameter is different, the "best fit" output is different. Unless I find the right in... | https://stackoverflow.com/questions/52356128/how-to-set-up-the-initial-value-for-curve-fit-to-find-the-best-optimizing-not-j | python, scikit-learn, scipy, least-squares, best-fit-curve | 1,537,115,180 |
se_70396644 | stackoverflow | MACHINE_LEARNING | VCF file is missing mandatory header line ("#CHROM...") | VCF file is missing mandatory header line ("#CHROM...")
I am getting an error when I am going to read a VCF file using scikit-allel library inside a docker image and os ubuntu 18.04. It shows that
raise RuntimeError('VCF file is missing mandatory header line ("#CHROM...")')
RuntimeError: VCF file is missing ... | https://stackoverflow.com/questions/70396644/vcf-file-is-missing-mandatory-header-line-chrom | pandas, numpy, scikit-learn, python-3.6, vcftools | 1,639,761,245 |
se_45627784 | stackoverflow | MACHINE_LEARNING | Unable to obtain accuracy score for my linear regression | Unable to obtain accuracy score for my linear regression
I am working on my regression model based on the IMDB data, to predict IMDB value. On my linear-regression, i was unable to obtain the accuracy score.
my line of code:
metrics.accuracy_score(test_y, linear_predicted_rating)
Error:
ValueError: continuous is not ... | https://stackoverflow.com/questions/45627784/unable-to-obtain-accuracy-score-for-my-linear-regression | python, machine-learning, scikit-learn | 1,502,430,390 |
se_79467306 | stackoverflow | MACHINE_LEARNING | MlflowException: RestException('BAD_REQUEST: CreateMultipartUpload with multi-cloud URLs is supported for AWS only.') | MlflowException: RestException('BAD_REQUEST: CreateMultipartUpload with multi-cloud URLs is supported for AWS only.')
I try to train and then log my scikit-learn model into Databricks model registry. I run the following code on Databricks serverless cluster.
mlflow.sklearn.log_model(
sk_model=model,
ar... | https://stackoverflow.com/questions/79467306/mlflowexception-restexceptionbad-request-createmultipartupload-with-multi-cl | scikit-learn, databricks, mlflow | 1,740,502,073 |
se_79474361 | stackoverflow | MACHINE_LEARNING | Why VotingClassifer performance with voting set to "hard" is different with different weights? | Why VotingClassifer performance with voting set to "hard" is different with different weights?
I wanted to test VotingClassifier from sklearn and comparae performance with different parameters. I used param grid and then I notice something unintelligible.
I prepared three classifiers
gnb = GaussianNB() # Acc... | https://stackoverflow.com/questions/79474361/why-votingclassifer-performance-with-voting-set-to-hard-is-different-with-diff | machine-learning, scikit-learn, classification, voting | 1,740,708,868 |
se_28314337 | stackoverflow | MACHINE_LEARNING | TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0] while using RF classifier? | TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0] while using RF classifier?
I am learning about random forests in scikit learn and as an example I would like to use Random forest classifier for text classification, with my own dataset. So first I vectorized the text with tfidf and for classificat... | https://stackoverflow.com/questions/28314337/typeerror-sparse-matrix-length-is-ambiguous-use-getnnz-or-shape0-while-usi | python, numpy, machine-learning, nlp, scikit-learn | 1,423,028,915 |
se_53278489 | stackoverflow | MACHINE_LEARNING | Perfect precision, recall and f1-score, yet bad prediction | Perfect precision, recall and f1-score, yet bad prediction
Using scikit-learn to classify a binary problem. Getting perfect classification_report (all 1's). Yet prediction gives 0.36. How can it be?
I'm familiar with imbalanced labels. Yet I don't think this is the case here since f1 and the other score columns, as w... | https://stackoverflow.com/questions/53278489/perfect-precision-recall-and-f1-score-yet-bad-prediction | python, machine-learning, scikit-learn, prediction, decision-tree | 1,542,103,557 |
se_58429786 | stackoverflow | MACHINE_LEARNING | How to show error output between boosting rounds in XGBoost? | How to show error output between boosting rounds in XGBoost?
I'm using Scikit-Learn API, XGBRegressor. I'm trying to make my model as verbose as possible. These are the parameters of the model. This is running on Kaggle kernels. df_train and df_target are pandas dataframes.
model = xgb.XGBRegressor(
n_estimators=... | https://stackoverflow.com/questions/58429786/how-to-show-error-output-between-boosting-rounds-in-xgboost | python, machine-learning, scikit-learn, xgboost | 1,571,305,976 |
se_34239355 | stackoverflow | MACHINE_LEARNING | Feature Importance extraction of Decision Trees | Feature Importance extraction of Decision Trees
I've been trying to get a grip on the importance of features used in a decision tree i've modelled. I'm interested in discovering the weight of each feature selected at the nodes as well as the term itself. My data is a bunch of documents.
This is my code for the decisio... | https://stackoverflow.com/questions/34239355/feature-importance-extraction-of-decision-trees | python, scikit-learn, decision-tree | 1,449,920,208 |
se_63718559 | stackoverflow | MACHINE_LEARNING | Finding most similar sentences among all in python | Finding most similar sentences among all in python
I have a data which is having more than 1500 rows. Each row has a sentence. I am trying to find out the best method to find the most similar sentences among all.
What I have tried
I have tried K-mean algorithm which groups similar sentences in a cluster. But I found ... | https://stackoverflow.com/questions/63718559/finding-most-similar-sentences-among-all-in-python | python, tensorflow, scikit-learn, sentence-similarity | 1,599,117,055 |
se_35714772 | stackoverflow | MACHINE_LEARNING | Sklearn Lasso Regression is orders of magnitude worse than Ridge Regression? | Sklearn Lasso Regression is orders of magnitude worse than Ridge Regression?
I've currently implemented Ridge and Lasso regression using the sklearn.linear_model module.
However, the Lasso Regression seems to do 3 orders of magnitude worse on the same dataset!
I'm not sure what's wrong, because mathematically, this sh... | https://stackoverflow.com/questions/35714772/sklearn-lasso-regression-is-orders-of-magnitude-worse-than-ridge-regression | python, machine-learning, scikit-learn, linear-regression | 1,456,806,983 |
se_79489137 | stackoverflow | MACHINE_LEARNING | Nested parallelism with GridSearchCV causes infinite hang | Nested parallelism with GridSearchCV causes infinite hang
I'm running a GridSearchCV optimization into a parallelized function. The pseudocode looks like this
from tqdm.contrib.concurrent import process_map
from sklearn.model_selection import GridSearchCV
def main():
results = process_map(func, it, max_workers=5)... | https://stackoverflow.com/questions/79489137/nested-parallelism-with-gridsearchcv-causes-infinite-hang | python, scikit-learn, multiprocessing, joblib, gridsearchcv | 1,741,259,648 |
se_76377362 | stackoverflow | MACHINE_LEARNING | Issue with FastAPI, Uvicorn, and pickled FunctionTransformer | Issue with FastAPI, Uvicorn, and pickled FunctionTransformer
I have a microservice (fastapi) that serves predictions from a model that was pre-trained in a separate repo. Ideally, this microservice only has one job: given an input X, a pre-trained model, and a pickled my_transformer: serve predictions y. The microserv... | https://stackoverflow.com/questions/76377362/issue-with-fastapi-uvicorn-and-pickled-functiontransformer | python, scikit-learn, fastapi, uvicorn, dill | 1,685,567,799 |
se_29393739 | stackoverflow | MACHINE_LEARNING | how to use GridSearchCV with custom estimator in sklearn? | how to use GridSearchCV with custom estimator in sklearn?
I have an estimator that should be compatible with the sklearn api. I am trying to fit one parameter of this estimator with gridsearchcv but I do not understand how to do it.
This is my code:
import numpy as np
import sklearn as sk
from sklearn.linear_model ... | https://stackoverflow.com/questions/29393739/how-to-use-gridsearchcv-with-custom-estimator-in-sklearn | python, machine-learning, scikit-learn | 1,427,899,173 |
se_42080598 | stackoverflow | MACHINE_LEARNING | What is the best way to build and expose a Machine Learning model REST api? | What is the best way to build and expose a Machine Learning model REST api?
I have been working on designing REST api using springframework and deploying them on web servers like Tomcat. I have also worked on building Machine Learning model and use the model to make prediction using sklearn in Python.
Now I have a use... | https://stackoverflow.com/questions/42080598/what-is-the-best-way-to-build-and-expose-a-machine-learning-model-rest-api | java, python, rest, machine-learning, scikit-learn | 1,486,433,951 |
se_56107259 | stackoverflow | MACHINE_LEARNING | How to save a trained model by scikit-learn? | How to save a trained model by scikit-learn?
I am trying to re-create the prediction of a trained model but I don't know how to save a model.
For example, I want to save the trained Gaussian processing regressor model and recreate the prediction after I trained the model.
The package I used to train model is scikit-le... | https://stackoverflow.com/questions/56107259/how-to-save-a-trained-model-by-scikit-learn | python, python-3.x, scikit-learn, save, pre-trained-model | 1,557,731,141 |
se_26139826 | stackoverflow | MACHINE_LEARNING | Save a decision tree model in scikit-learn | Save a decision tree model in scikit-learn
I'm building a decision tree using Scikit-Learn in Python. I've trained the model on a particular dataset and now I want to save this decision tree so that it can be used later. How to do this? | https://stackoverflow.com/questions/26139826/save-a-decision-tree-model-in-scikit-learn | python, scikit-learn, decision-tree | 1,412,161,226 |
se_71509883 | stackoverflow | MACHINE_LEARNING | Recovering features names of StandardScaler().fit_transform() with sklearn | Recovering features names of StandardScaler().fit_transform() with sklearn
Edited from a tutorial in Kaggle, I try to run the code below and data (available to download from here):
Code:
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np # linear algebra
import pandas as pd # data processing, CSV... | https://stackoverflow.com/questions/71509883/recovering-features-names-of-standardscaler-fit-transform-with-sklearn | python-3.x, machine-learning, scikit-learn, xgboost | 1,647,509,323 |
se_46616883 | stackoverflow | MACHINE_LEARNING | How to set numbers of epoch in scikit-learn mlpregressor? | How to set numbers of epoch in scikit-learn mlpregressor?
I'm trying to do some supervised learning using scikit-learn MLPRegressor. I want to know what is the leverage of numbers of epoch in supervised learning.
But when I set the MLP like this :
mlp = MLPRegressor(max_iter=100, learning_rate_init=0.1)
and then t... | https://stackoverflow.com/questions/46616883/how-to-set-numbers-of-epoch-in-scikit-learn-mlpregressor | python, scikit-learn, epoch | 1,507,353,113 |
se_54403302 | stackoverflow | MACHINE_LEARNING | Sagemaker - additional endpoint | Sagemaker - additional endpoint
I created my own model with scikit learn. Apart from standard endpoints, '/ping' and '/invocations' I added a third one, '/estimates' (it calls predict_probabilities()).
When I run locally container all endpoints work correctly. When I deploy this as endpoint on Sagemaker '/invocation... | https://stackoverflow.com/questions/54403302/sagemaker-additional-endpoint | python, amazon-web-services, docker, scikit-learn, amazon-sagemaker | 1,548,682,918 |
se_79471646 | stackoverflow | MACHINE_LEARNING | In ordinal encoder what does handle_unknown= use_encoded_values do? | In ordinal encoder what does handle_unknown= use_encoded_values do?
I've done my research about but I'm not satisfied with the answer I looked up both on the documentation and gemini. use_encoded_value what does it mean? Do I have to pass an argument to act as an encoded values? If so could you give an example on its ... | https://stackoverflow.com/questions/79471646/in-ordinal-encoder-what-does-handle-unknown-use-encoded-values-do | machine-learning, scikit-learn, ordinal-classification | 1,740,632,959 |
se_79475986 | stackoverflow | MACHINE_LEARNING | Pipeline FutureWarning: This Pipeline instance is not fitted yet | Pipeline FutureWarning: This Pipeline instance is not fitted yet
I am working on a fairly simple machine learning problem in the form of a practicum. I am using the following code to preprocess the data:
from preprocess.date_converter import DateConverter
from sklearn.pipeline import Pipeline
from preprocess.nan_fixer... | https://stackoverflow.com/questions/79475986/pipeline-futurewarning-this-pipeline-instance-is-not-fitted-yet | python, machine-learning, scikit-learn, scikit-learn-pipeline | 1,740,756,311 |
se_78103638 | stackoverflow | MACHINE_LEARNING | Sklearn LinearRegression() don't require Iterations and Learning rate as parameter | Sklearn LinearRegression() don't require Iterations and Learning rate as parameter
As far as I know the cost is minimized using the Gradient Descent algorithm by updating the weights(repeat until convergence), In case of linear regression we have
m : slope
c : intercept (constant value)
import numpy as np
from s... | https://stackoverflow.com/questions/78103638/sklearn-linearregression-dont-require-iterations-and-learning-rate-as-paramet | python, scikit-learn, linear-regression | 1,709,580,628 |
se_72754217 | stackoverflow | MACHINE_LEARNING | FastAPI: Internal Server Error when returning ML model prediction | FastAPI: Internal Server Error when returning ML model prediction
I would like to test my pipeline in FastAPI, but I can't find the mistake in my code. When I test it using the Visual Studio Code (using a print() statement), it works. However, when I try accessing the endpoint through the browser, I get Internal Serve... | https://stackoverflow.com/questions/72754217/fastapi-internal-server-error-when-returning-ml-model-prediction | python, machine-learning, scikit-learn, fastapi, pipeline | 1,656,163,472 |
se_79472873 | stackoverflow | MACHINE_LEARNING | Cannot register and deploy scikit-learn linear regression model on AWS Sagemaker AI | Cannot register and deploy scikit-learn linear regression model on AWS Sagemaker AI
We are evaluating AWS Sagemaker AI pipeline for MLOps, using the step decorator approach as introduced here, and mostly following the example here.
Since we are just starting out we'd prefer to have full flexibility in how we script ou... | https://stackoverflow.com/questions/79472873/cannot-register-and-deploy-scikit-learn-linear-regression-model-on-aws-sagemaker | python, scikit-learn, amazon-sagemaker | 1,740,663,966 |
se_73533170 | stackoverflow | MACHINE_LEARNING | My Neural network is perfroming regression instead of classification | My Neural network is perfroming regression instead of classification
I am working on a Data Science project which requires implementation of a neural network. The dataset I am providing for training is not sequential and has class labels. But I don't know why it is treating it as sequence of events.
I am using the fol... | https://stackoverflow.com/questions/73533170/my-neural-network-is-perfroming-regression-instead-of-classification | python, tensorflow, machine-learning, scikit-learn, neural-network | 1,661,797,668 |
se_45169345 | stackoverflow | MACHINE_LEARNING | mutual information significance levels | mutual information significance levels
I have a dataset of 21 variables and 75 datapoints/rows. I am trying to investigate the mutual information between each pair of variables. I have used the mutual_info_score function in sklearn.metrics and this returns a number that is more than 0. How do I know which values of th... | https://stackoverflow.com/questions/45169345/mutual-information-significance-levels | python, scikit-learn, statistics, entropy | 1,500,387,262 |
se_52955249 | stackoverflow | MACHINE_LEARNING | NoneType' object is not iterable for Vectorizer sklearn | NoneType' object is not iterable for Vectorizer sklearn
I have imported text data into pandas dataframe. I would like to implement Vectorizer. So i use sklearn to do tfidf and so on
So the first step i did. clean the text.
#Creating Function
from nltk.corpus import stopwords
def text_process(sms):
nonpunc =... | https://stackoverflow.com/questions/52955249/nonetype-object-is-not-iterable-for-vectorizer-sklearn | python, scikit-learn, nlp | 1,540,317,931 |
se_21105661 | stackoverflow | MACHINE_LEARNING | Importing svm gives ValueError: numpy.dtype has the wrong size, try recompiling | Importing svm gives ValueError: numpy.dtype has the wrong size, try recompiling
I am trying to use scikit-learn svm to classify emails based on the topic. However, I am unable to import the svm module from sklearn. I already have sklearn installed. The error I get is as follows:
>>> from sklearn import svm
Traceback ... | https://stackoverflow.com/questions/21105661/importing-svm-gives-valueerror-numpy-dtype-has-the-wrong-size-try-recompiling | python, svm, scikit-learn | 1,389,670,579 |
se_44939725 | stackoverflow | MACHINE_LEARNING | Support vector machine overfitting my data | Support vector machine overfitting my data
I am trying to make predictions for the iris dataset. I have decided to use svms for this purpose. But, it gives me an accuracy 1.0. Is it a case of overfitting or is it because the model is very good? Here is my code.
X_train, X_test, y_train, y_test = train_test_split(X, y... | https://stackoverflow.com/questions/44939725/support-vector-machine-overfitting-my-data | python, python-3.x, machine-learning, scikit-learn, svm | 1,499,314,673 |
se_28154839 | stackoverflow | MACHINE_LEARNING | SVM overfitting in scikit learn | SVM overfitting in scikit learn
I am building digit recognition classification using SVM. I have 10000 data and I split them to training and test data with a ratio 7:3. I use linear kernel.
The results turn out that training accuracy is always 1 when change training example numbers, however the test accuracy is just a... | https://stackoverflow.com/questions/28154839/svm-overfitting-in-scikit-learn | machine-learning, scikit-learn, svm | 1,422,291,244 |
se_24088010 | stackoverflow | MACHINE_LEARNING | Python scikit-learn (using grid_search.GridSearchCV) | Python scikit-learn (using grid_search.GridSearchCV)
I'm using grid search to fit machine learning model parameters.
I typed in the following code (modified from the sklearn documentation page: http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.GridSearchCV.html)
from sklearn import svm, grid_searc... | https://stackoverflow.com/questions/24088010/python-scikit-learn-using-grid-search-gridsearchcv | python, scikit-learn | 1,402,077,629 |
se_79463484 | stackoverflow | MACHINE_LEARNING | Force Partial Least Squares solver to only consider positive results | Force Partial Least Squares solver to only consider positive results
I am using the Partial Least Squares (PLS) solver for data analysis of several overlaid spectral signals. Sometimes I am getting some of the weaker signals coming out as negative values which is not possible in my setup.
Is there any way to constrain... | https://stackoverflow.com/questions/79463484/force-partial-least-squares-solver-to-only-consider-positive-results | python, scikit-learn, pls | 1,740,399,129 |
se_46514654 | stackoverflow | MACHINE_LEARNING | Sklearn and cross_val_scores: can we use it for leave-one-out cross validation? | Sklearn and cross_val_scores: can we use it for leave-one-out cross validation?
I am writing a loop where I have to execute the k-fold cross-validation on 1000 entries. The value of k changes at every iteration in the loop and it can have the value of 1000. However, when trying to do the leave-on-out cross-validation ... | https://stackoverflow.com/questions/46514654/sklearn-and-cross-val-scores-can-we-use-it-for-leave-one-out-cross-validation | python, numpy, scikit-learn | 1,506,876,909 |
se_69461574 | stackoverflow | MACHINE_LEARNING | 'Stopwords' are ignored during LDA from scikit-learn | 'Stopwords' are ignored during LDA from scikit-learn
I'm trying to run a LDA analysis from SKlearn on a list of Danish reviews from Trustpilot with the following code:
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.decomposition import LatentDirich... | https://stackoverflow.com/questions/69461574/stopwords-are-ignored-during-lda-from-scikit-learn | python, scikit-learn, lda, topic-modeling | 1,633,505,791 |
se_22556172 | stackoverflow | MACHINE_LEARNING | sklearn and SVMs with polynomial kernel | sklearn and SVMs with polynomial kernel
I am using sklearn for python to perform cross validation using SVMs. I tried with the linear and rbf kernels and it all works fine. When i run it with the polynomial kernel though it never finishes. It has been running for 8 hours and still nothing. The dimensionality of the in... | https://stackoverflow.com/questions/22556172/sklearn-and-svms-with-polynomial-kernel | python, scikit-learn, svm | 1,395,397,664 |
se_79454185 | stackoverflow | MACHINE_LEARNING | How to apply different model on different rows of a pandas dataframe? | How to apply different model on different rows of a pandas dataframe?
I have a pandas dataframe that looks like this:
import pandas as pd
df = pd.DataFrame({'id': [1,2], 'var1': [5,6], 'var2': [20,60], 'var3': [8, -2], 'model_version': ['model_a', 'model_b']})
I have 2 different models, saved in pkl files, which I lo... | https://stackoverflow.com/questions/79454185/how-to-apply-different-model-on-different-rows-of-a-pandas-dataframe | python, pandas, scikit-learn | 1,740,047,924 |
se_79434756 | stackoverflow | MACHINE_LEARNING | ValueError: X has 7 features, but ColumnTransformer expects 13 features | ValueError: X has 7 features, but ColumnTransformer expects 13 features
I have the following code where I try to predict price of tools for which I use poisson regression.
# --- Load and Prepare Data ---
y = train['PriceToday']
X = train.drop(columns=['PriceToday'])
# Define non-standard types
non_standard_types = ["... | https://stackoverflow.com/questions/79434756/valueerror-x-has-7-features-but-columntransformer-expects-13-features | python, machine-learning, scikit-learn, one-hot-encoding, column-tansformer | 1,739,404,263 |
se_56265017 | stackoverflow | MACHINE_LEARNING | geodesic distance on 3d triangular mesh using scikit-fmm or gdist | geodesic distance on 3d triangular mesh using scikit-fmm or gdist
I'm trying to evaluate a geodesic distance matrix on the TOSCA dataset.
e.g. the following 3d mesh-
I've tried using two python implementations.
The first one is the scikit-fmm, which does not seems to work on 3d structures at all (am I right?) henc... | https://stackoverflow.com/questions/56265017/geodesic-distance-on-3d-triangular-mesh-using-scikit-fmm-or-gdist | python, scikit-learn, distance, mesh | 1,558,559,149 |
se_79439462 | stackoverflow | MACHINE_LEARNING | How to train sklearn model in different Dataframes? | How to train sklearn model in different Dataframes?
I have a ML model made with "knn" in scikit-learn and noticed that the more i have data, more precise my model is getting with it's predictions. The problem is, i have lot's of DataFrames that show different situations for the same system i want to predict. Is it pos... | https://stackoverflow.com/questions/79439462/how-to-train-sklearn-model-in-different-dataframes | python, machine-learning, scikit-learn | 1,739,538,105 |
se_76020437 | stackoverflow | MACHINE_LEARNING | Trouble unscaling data after predictions | Trouble unscaling data after predictions
I am working on a project where I am trying to predict mlb player stats from 1970 - 2022. I have 2 datasets, one for batters where I am predicting on 5 stats with 20 features and another for pitchers where I am predicting on 6 stats with 25 features. I am currently working on a... | https://stackoverflow.com/questions/76020437/trouble-unscaling-data-after-predictions | python, machine-learning, scikit-learn, decision-tree | 1,681,534,854 |
se_63892696 | stackoverflow | MACHINE_LEARNING | How to use LabelEncoder in sklearn make_column_tranformer? | How to use LabelEncoder in sklearn make_column_tranformer?
How to use LabelEncoder in sklearn pipeline?
NOTE
The following code works for "OneHotEncoder" but fails for "LabelEncoder", How to use LabelEncoder in this circumstance?
MWE
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.preprocessi... | https://stackoverflow.com/questions/63892696/how-to-use-labelencoder-in-sklearn-make-column-tranformer | python, scikit-learn | 1,600,123,420 |
se_48938905 | stackoverflow | MACHINE_LEARNING | return the labels and their encoded values in sklearn LabelEncoder | return the labels and their encoded values in sklearn LabelEncoder
I'm using LabelEncoder and OneHotEncoder from sklearn in a Machine Learning project to encode the labels (country names) in the dataset. Everything works good and my model runs perfectly. The project is to classify whether a bank customer will continue... | https://stackoverflow.com/questions/48938905/return-the-labels-and-their-encoded-values-in-sklearn-labelencoder | python, machine-learning, scikit-learn, one-hot-encoding | 1,519,342,082 |
se_44974360 | stackoverflow | MACHINE_LEARNING | How to visualize an sklearn GradientBoostingClassifier? | How to visualize an sklearn GradientBoostingClassifier?
I've trained a gradient boost classifier, and I would like to visualize it using the graphviz_exporter tool shown here.
When I try it I get:
AttributeError: 'GradientBoostingClassifier' object has no attribute 'tree_'
this is because the graphviz_exporter is mea... | https://stackoverflow.com/questions/44974360/how-to-visualize-an-sklearn-gradientboostingclassifier | scikit-learn, graphviz, decision-tree | 1,499,440,713 |
se_71193740 | stackoverflow | MACHINE_LEARNING | TypeError: Encoders require their input to be uniformly strings or numbers. Got ['int', 'str'] | TypeError: Encoders require their input to be uniformly strings or numbers. Got ['int', 'str']
I already referred the posts here, here and here. Don't mark it as duplicate.
I am working on a binary classification problem where my dataset has categorical and numerical columns.
However, some of the categ... | https://stackoverflow.com/questions/71193740/typeerror-encoders-require-their-input-to-be-uniformly-strings-or-numbers-got | python, pandas, machine-learning, scikit-learn, smote | 1,645,355,042 |
se_55332339 | stackoverflow | MACHINE_LEARNING | Error "could not convert string to float: 'INLAND'" | Error "could not convert string to float: 'INLAND'"
I'm doing a project on housing price prediction using machine learning, and want to submit it to a private firm for an application.
I am working in the Jupiter notebook for this project, but I am unable to fix the bugs regarding conversion for word... | https://stackoverflow.com/questions/55332339/error-could-not-convert-string-to-float-inland | python, machine-learning, scikit-learn | 1,553,495,639 |
se_11763613 | stackoverflow | MACHINE_LEARNING | Python List of Ngrams with frequencies | Python List of Ngrams with frequencies
I need to get most popular ngrams from text. Ngrams length must be from 1 to 5 words.
I know how to get bigrams and trigrams. For example:
bigram_measures = nltk.collocations.BigramAssocMeasures()
finder = nltk.collocations.BigramCollocationFinder.from_words(words)
finder.appl... | https://stackoverflow.com/questions/11763613/python-list-of-ngrams-with-frequencies | python, nltk, scikit-learn | 1,343,838,560 |
se_79426062 | stackoverflow | MACHINE_LEARNING | `sklearn.metrics.r2_score` is giving wrong R2 value? | `sklearn.metrics.r2_score` is giving wrong R2 value?
I notice that sklearn.metrics.r2_score is giving wrong R2 value.
from sklearn.metrics import r2_score
r2_score(y_true=[2,4,3,34,23], y_pred=[21,12,3,11,17]) # -0.17
r2_score(y_pred=[21,12,3,11,17], y_true=[2,4,3,34,23]) # -4.36
However, the true R2 value shoul... | https://stackoverflow.com/questions/79426062/sklearn-metrics-r2-score-is-giving-wrong-r2-value | python, scikit-learn | 1,739,160,726 |
se_65645125 | stackoverflow | MACHINE_LEARNING | Producing a confusion matrix with cross_validate | Producing a confusion matrix with cross_validate
I'm trying to figure out how to produce a confusion matrix with cross_validate. I'm able to print out the scores with the code I have so far.
# Instantiating model
model = DecisionTreeClassifier()
#Scores
scoring = {'accuracy' : make_scorer(accuracy_score),
... | https://stackoverflow.com/questions/65645125/producing-a-confusion-matrix-with-cross-validate | python, machine-learning, scikit-learn, cross-validation, confusion-matrix | 1,610,210,788 |
se_9734403 | stackoverflow | MACHINE_LEARNING | Confusion matrix with cross validation | Confusion matrix with cross validation
I am training a svm classifier with cross validation (stratifiedKfold) using the scikits interfaces. For each test set (of k), I get a classification result. I want to have a confusion matrix with all the results.
Scikit-learn has a confusion matrix interface:
sklearn.metrics.con... | https://stackoverflow.com/questions/9734403/confusion-matrix-with-cross-validation | python, machine-learning, scikit-learn | 1,331,888,759 |
se_40169152 | stackoverflow | MACHINE_LEARNING | Confusion Matrix for 10-fold cross validation in scikit learn | Confusion Matrix for 10-fold cross validation in scikit learn
How can I calculate confusion matrix in 10-fold cross-validation with scikit-learn? How can I find y_test and y_pred? | https://stackoverflow.com/questions/40169152/confusion-matrix-for-10-fold-cross-validation-in-scikit-learn | python, machine-learning, scikit-learn, cross-validation, confusion-matrix | 1,477,028,370 |
se_67482597 | stackoverflow | MACHINE_LEARNING | Is there a method to do transfer learning with decision trees/random forest? | Is there a method to do transfer learning with decision trees/random forest?
Is there a way to do transfer learning with a decision tree or a random forest model? Concretely, I was wondering if there is a good and easy way of doing so in Python with a model trained with Scikit-learn.
All I can think of is training a r... | https://stackoverflow.com/questions/67482597/is-there-a-method-to-do-transfer-learning-with-decision-trees-random-forest | python, scikit-learn, random-forest, decision-tree | 1,620,719,587 |
se_79395026 | stackoverflow | MACHINE_LEARNING | Different SSIM Results for 3D Microscopy Slices Using torchmetrics and skimage: Which One Should I Use? | Different SSIM Results for 3D Microscopy Slices Using torchmetrics and skimage: Which One Should I Use?
I am working with 3D microscopy data (e.g., stacks of 2D images) and trying to compute the Structural Similarity Index (SSIM) between two 3D images. The goal is to evaluate the similarity between an input stack and ... | https://stackoverflow.com/questions/79395026/different-ssim-results-for-3d-microscopy-slices-using-torchmetrics-and-skimage | python, scikit-learn, torch, scikit-image, ssim | 1,738,094,212 |
se_78739263 | stackoverflow | MACHINE_LEARNING | Use and save plots created by scikit learn RocCurveDisplay with matplotlib's functions | Use and save plots created by scikit learn RocCurveDisplay with matplotlib's functions
I have created a plot with scikit's RocCurveDisplay class and I cannot figure out how to save this plot. I cannot find a way to use matplotlib's functions like savefig() somehow. I would also like to use the plots of RocCurveDis... | https://stackoverflow.com/questions/78739263/use-and-save-plots-created-by-scikit-learn-roccurvedisplay-with-matplotlibs-fun | matplotlib, scikit-learn | 1,720,772,239 |
se_79414997 | stackoverflow | MACHINE_LEARNING | Dagster: preserve multiple sklearn model in asset | Dagster: preserve multiple sklearn model in asset
I have a linear regression asset in dagster that uses data previously computed and sklearn LinearRegression (Python 10 here).
For each of my input columns (that represents a country, I want to fit a Linear Regression model.
Everything works fine. My question is about o... | https://stackoverflow.com/questions/79414997/dagster-preserve-multiple-sklearn-model-in-asset | python, scikit-learn, dagster | 1,738,763,604 |
se_79416292 | stackoverflow | MACHINE_LEARNING | Is there a way to set the data_min and the data_max in MinMaxScaler()? | Is there a way to set the data_min and the data_max in MinMaxScaler()?
I'm currently using MinMaxScaler() on my dataset. However, because my dataset is large I'm doing a first iteration pass in batches to compute the Min and Max Values for my Scaler. i'm using partial_fit() to help with this.
Anyway, for some of my fe... | https://stackoverflow.com/questions/79416292/is-there-a-way-to-set-the-data-min-and-the-data-max-in-minmaxscaler | machine-learning, scikit-learn, scaling, data-preprocessing | 1,738,792,655 |
se_57669503 | stackoverflow | MACHINE_LEARNING | How to find optimal number of clusters with Scikit-Learn and Python | How to find optimal number of clusters with Scikit-Learn and Python
I'm learning clustering with Pythons scikit-learn lib but I cant find a way to find the optimal number of clusters. I have tried to make a list of numbers of clusters and to pass it in for loop, and to see elbow but I want to find better solution. Thi... | https://stackoverflow.com/questions/57669503/how-to-find-optimal-number-of-clusters-with-scikit-learn-and-python | python, scikit-learn | 1,566,890,275 |
se_35996970 | stackoverflow | MACHINE_LEARNING | TypeError: fit() missing 1 required positional argument: 'y' | TypeError: fit() missing 1 required positional argument: 'y'
I am trying to predict economic cycles using Gaussian Naive Bayes "Classifier".
data (input X) :
SPY Interest Rate Unemployment Employment CPI
Date
1997-01-02 56.05 7.82 9.7 3399... | https://stackoverflow.com/questions/35996970/typeerror-fit-missing-1-required-positional-argument-y | python-3.x, pandas, scikit-learn | 1,457,985,755 |
se_73396380 | stackoverflow | MACHINE_LEARNING | How to extract auc scores from scikitplot plot_precision_recall method? | How to extract auc scores from scikitplot plot_precision_recall method?
I am trying to get the micro-average score as displayed in:
from scikitplot.metrics import plot_precision_recall
plot_precision_recall(np.array(y_test), y_pred_proba)
plt.show()
For example, I have the plot:
with micro-average of 0.975
I've tri... | https://stackoverflow.com/questions/73396380/how-to-extract-auc-scores-from-scikitplot-plot-precision-recall-method | python, scikit-learn, auc | 1,660,784,350 |
se_48859767 | stackoverflow | MACHINE_LEARNING | Python: Gridsearch Without Machine Learning? | Python: Gridsearch Without Machine Learning?
I want to optimize an algorithm that has several variable parameters
as input.
For machine learning tasks, Sklearn offers the optimization of hyperparameters with the gridsearch functionality.
Is there a standardized way / library in Python that allows the optimization... | https://stackoverflow.com/questions/48859767/python-gridsearch-without-machine-learning | python, optimization, scikit-learn, grid-search, hyperparameters | 1,519,016,491 |
se_33504183 | stackoverflow | MACHINE_LEARNING | Parameter Optimization in Python | Parameter Optimization in Python
Given a Python callable that returns a fitness measurement (0.0=horrible, 0.5=ok, 1.0=perfect) and a description of its parameters (type=bool|int|float|nominal, min, max), what are robust implementations of parameter optimizers that can find the combination of parameters that get the f... | https://stackoverflow.com/questions/33504183/parameter-optimization-in-python | python, optimization, scipy, scikit-learn | 1,446,567,909 |
se_59795682 | stackoverflow | MACHINE_LEARNING | Breadth-first search on numpy array for consecutive adjacent zeroes | Breadth-first search on numpy array for consecutive adjacent zeroes
I have a numpy array that looks like the following:
arr = np.array([[-1, -1, -1, 0, -1]
[ -1, -1, -1, 0, -1]
[ -1, 0, -1, -1, 0]
[ -1, 0, -1, -1, -1]
[ -1, -1, -1, -1, 0]])
I want each... | https://stackoverflow.com/questions/59795682/breadth-first-search-on-numpy-array-for-consecutive-adjacent-zeroes | python, numpy, scikit-learn, breadth-first-search | 1,579,300,448 |
se_34165731 | stackoverflow | MACHINE_LEARNING | A column-vector y was passed when a 1d array was expected | A column-vector y was passed when a 1d array was expected
I need to fit RandomForestRegressor from sklearn.ensemble.
forest = ensemble.RandomForestRegressor(**RF_tuned_parameters)
model = forest.fit(train_fold, train_y)
yhat = model.predict(test_fold)
This code always worked until I made some preprocessing of data (t... | https://stackoverflow.com/questions/34165731/a-column-vector-y-was-passed-when-a-1d-array-was-expected | python, pandas, numpy, scikit-learn | 1,449,607,649 |
se_21963486 | stackoverflow | MACHINE_LEARNING | troubleshooting random forests classifier in sci-kit learn | troubleshooting random forests classifier in sci-kit learn
I am trying to run the random forests classifier from sci-kit learn and getting suspiciously bad output - less than 1% of predictions are correct. The model is performing much worse than chance. I am relatively new to Python, ML, and sci-kit learn (a triple ... | https://stackoverflow.com/questions/21963486/troubleshooting-random-forests-classifier-in-sci-kit-learn | python, machine-learning, scikit-learn, random-forest | 1,393,123,228 |
se_33948946 | stackoverflow | MACHINE_LEARNING | Random Forest is overfitting | Random Forest is overfitting
I'm using scikit-learn with a stratified CV to compare some classifiers.
I'm computing: accuracy, recall, auc.
I used for the parameter optimization GridSearchCV with a 5 CV.
RandomForestClassifier(warm_start= True, min_samples_leaf= 1, n_estimators= 800, min_samples_split= 5,max_featur... | https://stackoverflow.com/questions/33948946/random-forest-is-overfitting | python, machine-learning, scikit-learn, random-forest | 1,448,585,700 |
se_50629219 | stackoverflow | MACHINE_LEARNING | How do cross_val_score and gridsearchCV work? | How do cross_val_score and gridsearchCV work?
I have been trying to figure out how gridsearchCV and cross_val_score work.
Finding odds results a set up a sort of validation experiment, but still I do not understand what I am doing wrong.
To try to simplify I am using gridsearchCV is the simplest possible way and try t... | https://stackoverflow.com/questions/50629219/how-do-cross-val-score-and-gridsearchcv-work | python, machine-learning, scikit-learn, cross-validation | 1,527,785,439 |
se_64675820 | stackoverflow | MACHINE_LEARNING | what is difference between criterion and scoring in GridSearchCV | what is difference between criterion and scoring in GridSearchCV
I have created a GradientBoostingRegressor model.
I use scoring parameter in GridSearchCV function to return MSE score.
I wonder if I use criterion in param_grids does it change my model? which is the correct way?
GBR = GradientBoostingRegressor()
param_... | https://stackoverflow.com/questions/64675820/what-is-difference-between-criterion-and-scoring-in-gridsearchcv | python, machine-learning, scikit-learn, linear-regression, grid-search | 1,604,475,306 |
se_36404042 | stackoverflow | MACHINE_LEARNING | ImportError: No module named sklearn (Python) | ImportError: No module named sklearn (Python)
I wanna use scikit-learn. I have typed
pip install -U scikit-learn
pip3 install sklearn
to install it; but when i type
$ Python
>>> import sklearn
it returns
ImportError: No module named sklearn
I followed other tutorials, but it doesn't work. Furthermore, my en... | https://stackoverflow.com/questions/36404042/importerror-no-module-named-sklearn-python | python, macos, scikit-learn | 1,459,776,457 |
se_67612665 | stackoverflow | MACHINE_LEARNING | When I install older version of scikit-learn in Google Colab, it still import the newest version | When I install older version of scikit-learn in Google Colab, it still import the newest version
I would like to use scikit-learn version 0.24.1 in Google Colab. First, I uninstall the current installed version (which is 0.24.2) by:
!pip uninstall scikit-learn -y
Then, I install version 0.24.1 by:
!pip install scikit... | https://stackoverflow.com/questions/67612665/when-i-install-older-version-of-scikit-learn-in-google-colab-it-still-import-th | scikit-learn, google-colaboratory, uninstallation | 1,621,472,611 |
se_61962591 | stackoverflow | MACHINE_LEARNING | visualize 10x10 grid of each digit using MNIST samples | visualize 10x10 grid of each digit using MNIST samples
I'm trying to plot 10x10 grid samples from the MNIST dataset. 10 of each digit. Here's the code:
Import libraries:
import sklearn
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
from sklearn.pipeline import Pipeli... | https://stackoverflow.com/questions/61962591/visualize-10x10-grid-of-each-digit-using-mnist-samples | python-3.x, scikit-learn, mnist | 1,590,176,060 |
se_79410458 | stackoverflow | MACHINE_LEARNING | Different Results (With Seed) For sklearn Random Forest | Different Results (With Seed) For sklearn Random Forest
I am using sklearn to run a random forest. I am setting the seed for the random forest, as well as splitting the data for cross validation. When I re-run the code consecutive times, it gives me the same result. However, re-running the same code after a month, I g... | https://stackoverflow.com/questions/79410458/different-results-with-seed-for-sklearn-random-forest | python, machine-learning, scikit-learn, random-forest, random-seed | 1,738,636,452 |
se_39492171 | stackoverflow | MACHINE_LEARNING | Scikit dendrogram: How to disable ouput? | Scikit dendrogram: How to disable ouput?
If I run dendrogram from the scikit libary:
from scipy.cluster.hierarchy import linkage, dendrogram
# ...
X = np.asarray(X)
Z = linkage(X, 'single', 'correlation')
plt.figure(figsize=(16,8))
dendrogram(Z, color_threshold=0.7)
I get a ton of print output in my ipython noteboo... | https://stackoverflow.com/questions/39492171/scikit-dendrogram-how-to-disable-ouput | python, scikit-learn | 1,473,860,844 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.