Questions tagged [sklearn-pandas]

Python module providing a bridge between Scikit-Learn’s Machine Learning methods and pandas-style DataFrames

Resources

1336 questions
11
votes
3 answers

statistical summary table in sklearn.linear_model.ridge?

In OLS form StatsModels, results.summary shows the summary of regression results (such as AIC, BIC, R-squared, ...) Is there any way to have this summary table in sklearn.linear_model.ridge? I would appreciate it if someone could guide me. Thank…
zhr
  • 419
  • 2
  • 6
  • 14
11
votes
3 answers

Sklearn SVM: SVR and SVC, getting the same prediction for every input

Here is a paste of the code: SVM sample code I checked out a couple of the other answers to this problem...and it seems like this specific iteration of the problem is a bit different. First off, my inputs are normalized, and I have five inputs per…
Chris
  • 28,822
  • 27
  • 83
  • 158
10
votes
3 answers

sklearn_extra installation issue

[in]: from sklearn_extra.cluster import KMedoids [out]: ModuleNotFoundError: No module named 'sklearn_extra' Then, I tried installing sklearn_extra via [in]: python -m pip install sklearn_extra [out]: ERROR: Could not find a version that…
Mine
  • 831
  • 1
  • 8
  • 27
10
votes
2 answers

Getting decision path to a node in sklearn

I wanted the decision path (i.e the set of rules) from the root node to a given node (which I supply) in a decision tree (DecisionTreeClassifier) in scikit-learn. clf.decision_path specifies the nodes a sample goes through, which may help in getting…
smian
  • 101
  • 1
  • 5
10
votes
1 answer

DecisionTreeClassifier predict_proba returns 0 or 1

I m trying to use the decision tree classified to identify two classes (renamed 0 and 1) based on certain parameters. I train it using a dataset and then run it on the "test dataset". When I try to calculate the probability for each data point in…
akaur
  • 389
  • 1
  • 6
  • 22
10
votes
3 answers

python3 + Pandas styles + Change alternate row color

Hi i am using Pandas and displaying a table. I there a function to apply alternate row color to make it clear to read. Using below code I am sending table in mail and it works. my code: count = 1000 df =…
Vinod HC
  • 1,557
  • 5
  • 20
  • 38
9
votes
4 answers

How to use KBinsDiscretizer to make continuous data into bins in Sklearn?

I am working on a ML algorithm in which I tried to convert the continuous target values into small bins to understand the problem better. Hence to make better prediction. My original problem is for regression but I convert into classification by…
Mass17
  • 1,555
  • 2
  • 14
  • 29
9
votes
2 answers

Sklearn Agglomerative Clustering Custom Affinity

I'm trying to use agglomerative clustering with a custom distance metric (ie affinity) since I'd like to cluster a sequence of integers by sequence similarity and not something like the euclidean distance which isn't meaningful. My data looks…
9
votes
1 answer

Tuning leaf_size to decrease time consumption in Scikit-Learn KNN

I was trying to implement KNN for handwritten character recognition where I found out that the execution of code was taking a lot of time. When added parameter leaf_size with value 400, I observed that time taken by code to execute was significantly…
9
votes
1 answer

Imputer reduces the size of columns in my dataframe

print(np.shape(ar_fulldata_input_xx)) Output: (9027, 1443) Now I use Imputer to impute the missing values of my dataframe ar_fulldata_input_xx as follows. fill_NaN = Imputer(missing_values=np.nan, strategy='mean', axis=0) imputed_DF =…
Stupid420
  • 1,347
  • 3
  • 19
  • 44
9
votes
4 answers

Converting a Pandas Dataframe column into one hot labels

I have a pandas dataframe similar to this: Col1 ABC 0 XYZ A 1 XYZ B 2 XYZ C By using the pandas get_dummies() function on column ABC, I can get this: Col1 A B C 0 XYZ 1 0 0 1 XYZ 0 1 0 2 XYZ 0 0 1 While…
Nir_J
  • 133
  • 1
  • 3
  • 7
9
votes
1 answer

Coverting Back One Hot Encoded Results back to single Column in Python

I was doing Multi-class Classification using Keras.It contained 5 classes of Output. I converted the single class vector to matrix using one hot encoding and made a model. Now to evaluate the model I want to convert back the 5 class probabilistic…
Abhik Sarkar
  • 901
  • 3
  • 12
  • 32
9
votes
2 answers

TypeError: unhashable type

I wrote a small piece of code to do linear regression using sklearn. I created a 2 column csv file (column names X,Y with some numbers) and when I read the file I see that the content is properly read - as shown below. However, I am getting…
qurious
  • 93
  • 1
  • 1
  • 4
8
votes
9 answers

sklearn cross_val_score() returns NaN values

i'm trying to predict next customer purchase to my job. I followed a guide, but when i tried to use cross_val_score() function, it returns NaN values.Google Colab notebook screenshot Variables: X_train is a dataframe X_test is a dataframe y_train…
Tomás Ortiz
  • 111
  • 1
  • 1
  • 8
8
votes
4 answers

Visualising the decision tree in sklearn

When I want to visualise the tree I got this error. I have shown the required libraries imported. Is there expected reason with jupiter-notebook ? from sklearn import tree import matplotlib.pyplot from sklearn.tree import DecisionTreeClassifier from…
Roshan
  • 101
  • 1
  • 1
  • 6
1 2
3
88 89