sklearn-pandas

How can I optimize KNN, GNB nd SVC sklearn algorithms to reduce exec time?

How can I optimize KNN, GNB nd SVC sklearn algorithms to reduce exec time? Question: I’m currently evaluating which classifier have the best performance for movie reviews sentiment analysis task. So far I have evaluate Logistic Regression, Linear Regression, Random Forest and Decision tree but I also want to consider KNN, GNB and SVC models …

Total answers: 1

Comparing two Dataframes and creating a third one where certain contions are met

Comparing two Dataframes and creating a third one where certain contions are met Question: I am trying to compare two different dataframe that have the same column names and indexes(not numerical) and I need to obtain a third df with the biggest value for the row with the same column name. Example df1= | | …

Total answers: 1

Why am I receiving an error for return_train_score when trying to cross validate

Why am I receiving an error for return_train_score when trying to cross validate Question: I am trying to execute a for loop for the following dictionary, but I am receiving an error that states: "cross_val_score() got an unexpected keyword argument ‘return_train_score’" I thought this was a valid parameter for cross_val_score so I’m a bit confused …

Total answers: 2

Why use sklearn normalising functions rather than the raw method?

Why use sklearn normalising functions rather than the raw method? Question: After having a look at the source code for the MinMaxScaler and MaxAbsScaler, I dont understand why I should use them when I can create the same output with no overhead. import sklearn.preprocessing import numpy as np x = np.arange(25).reshape(5,5) sklearn.preprocessing.MaxAbsScaler().fit_transform(x) x/np.max(np.abs(x),axis=0) sklearn.preprocessing.MinMaxScaler().fit_transform(x) (x-x.min(axis=0))/(x.max(axis=0)-x.min(axis=0)) …

Total answers: 1

ModuleNotFoundError: No module named 'sklearn.metrics.regression'

ModuleNotFoundError: No module named 'sklearn.metrics.regression' Question: trying to do the following import: from sklearn.metrics.regression import mean_absolute_error, mean_squared_error, r2_score and I get the error: ModuleNotFoundError: No module named ‘sklearn.metrics.regression’ tried fixing with the installation of: pip install -U scikit-learn scipy matplotlib but I don’t think that’s what I’m missing since it didn’t work… Asked By: user17809580 …

Total answers: 2

ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 455, 30), found shape=(None, 30)

ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 455, 30), found shape=(None, 30) Question: Here is the little project of Cancer detection, and it has already has the dataset and colab code, but I get an error when I execute model.fit(x_train, y_train, epochs=1000) The error is: ValueError: Input 0 of …

Total answers: 3

To determine the optimal k-mean for given dataset using python

To determine the optimal k-mean for given dataset using python Question: I am pretty new to python and the clusttering stuff. Right now I have a task to analyze a set of data and determine its optimal Kmean by using elbow and silhouette method. As shown in the picture, my dataset has three features, one …

Total answers: 1

What is the difference between X_test, X_train, y_test, y_train in sklearn?

What is the difference between X_test, X_train, y_test, y_train in sklearn? Question: I’m learning sklearn and I didn’t understand very good the difference and why use 4 outputs with the function train_test_split(). In the Documentation, I found some examples but it wasn’t sufficient to end my doubts. Does the code use the X_train to predict …

Total answers: 4

sklearn cross_val_score() returns NaN values

sklearn cross_val_score() returns NaN values Question: 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 is a list y_test is a list Code: X_train, X_test, …

Total answers: 9

get_feature_names not found in countvectorizer()

get_feature_names not found in countvectorizer() Question: I’m mining the Stack Overflow data dump of posts about deep learning libraries. I’d like to identify stop words in my corpus (like ‘python’ for instance). I want to get my feature names so I can identify the words with highest term frequencies. I create my documents and my …

Total answers: 2