I have been learning python form youtube videos. im new to python just a beginner. I saw this code on video so i tried it but getting the error which i dont known how to solve. This is the following code where im getting trouble. I didint wrote the enitre code as its to long. please help me fix my
Tag: scikit-learn
how to convert generated data into pandas dataframe
after creating the data. it is tuple and after converting tuple into pandas dataframe so i got 9 features (columns) but when i try to insert 9 cols it says. ValueError: Shape of passed values is (2, 1), indices imply (2, 9) Basically i wanna generate data and convert it into pandas dataframe but could not get…
Why Python’s scikit-learn K-Means text clustering algorithm always provides different retult
I have a list of documents and this class to perform actions on that list. So, basically, morphed_documents is a list of strings. And at the end, the algorithm returns the cluster for each document. But why the results and model’s labels are not the same though? Answer K-Means algorithm starts with a ra…
Pytest: How to locate a FutureWarning and fix it?
In my current project when I run my tests (with pytest) I get this output (besides others): This FutureWarning is quite clear – from version 1.0 (I’m using 0.24 at the moment) there will be change to some parameters and I will not be able to pass standardize as positional arguments. But the questi…
Cannot get L1 ratio in LogisticRegressionCV object
I am trying to fit an elastic net model using LogisticRegressionCV. I want to see what L1 ratio LogisticRegressionCV chooses after cross validation. I read from its documentation that after fitting we can access it by its attribute l1_ratio_. But when I tried this, it failed. The code is: It returns : Attribu…
AttributeError: format not found – pyodide + joblib.dump + scikit-learn (TfidfVectorizer)
I have pickled a SMS spam prediction model using pickle. Now, I want to use Pyodide to load the model in the browser. I have loaded the pickled file using pickle.loads in the browser: This works. But, when I try to call: It gives an error(in vectorizer.transform): AttributeError: format not found Full error d…
K-Fold cross validation for Lasso and Ridge models
I’m working with the Boston housing dataset from sklearn.datasets and have run ridge and lasso regressions on my data (post train/test split). I’m now trying to perform k-fold cross validation to find the optimal penalty parameters, and have written the code below. What can I do to resolve this is…
How to change plot legends with roc_auc_score?
I’m plotting ROC curve with plot_roc_curve of scikit-learn, that plot legends are printed automatically. Is there a way to change them? Answer You can pretty much add anything you like to the plot object that is produced through plot_roc_curve. For instance, you can do something like this: This will ret…
AttributeError: ‘numpy.ndarray’ object has no attribute ‘score’ error
I have tried to look for a problem but there is nothing Im seeing wrong here. What could it be? This is for trying binary classification in SVM for the fashion MNIST data set but only classifying 5 and 7. Answer ypred is an array of predicted class labels, so the exception makes sense. What you should do is u…
precision score warnings results in score =0 sklearn
I am using precision_score in sklearn to evaluate the result of the outlier detection algorithm. I trained with one class only and predict on unseen data. So the label for the one class is just 0 all the way. I have found the following: There are two columns, truth and predicted. (I used the label encoder to …