logistic-regression

Error in running SVM and Logistic Regression in python

Error in running SVM and Logistic Regression in python Question: I am trying to tune the parameter between the SVM, Logistic regression, MLP and Random forest regression in the python but it shows a value error for SVM and logistic regression. my sample data is this: Wavelength Phase_velocity Shear_wave_velocity 1.50 202.69 240.73 1.68 192.72 240.73 …

Total answers: 1

Sklearn: KNeighborsRegressor vs KNeighborsClassifer

Sklearn: KNeighborsRegressor vs KNeighborsClassifer Question: What is the difference between the KNeighborsRegressor and the KNeighborsClassifier of the sklearn library? I’m trying to use the kNN algorithm to make predictions on a datset that has the names of certain emotions (like happy, sad, angry) as possible classes. The attributes are numerical pixel values. I’ve learned that …

Total answers: 3

How to choose cross-entropy loss in TensorFlow?

How to choose cross-entropy loss in TensorFlow? Question: Classification problems, such as logistic regression or multinomial logistic regression, optimize a cross-entropy loss. Normally, the cross-entropy layer follows the softmax layer, which produces probability distribution. In tensorflow, there are at least a dozen of different cross-entropy loss functions: tf.losses.softmax_cross_entropy tf.losses.sparse_softmax_cross_entropy tf.losses.sigmoid_cross_entropy tf.contrib.losses.softmax_cross_entropy tf.contrib.losses.sigmoid_cross_entropy tf.nn.softmax_cross_entropy_with_logits tf.nn.sigmoid_cross_entropy_with_logits … …

Total answers: 3

ValueError: Unknown label type: 'unknown'

ValueError: Unknown label type: 'unknown' Question: I try to run following code. Btw, I am new to both python and sklearn. import pandas as pd import numpy as np from sklearn.linear_model import LogisticRegression # data import and preparation trainData = pd.read_csv(‘train.csv’) train = trainData.values testData = pd.read_csv(‘test.csv’) test = testData.values X = np.c_[train[:, 0], train[:, …

Total answers: 3

Logistic Regression: How to find top three feature that have highest weights?

Logistic Regression: How to find top three feature that have highest weights? Question: I am working on UCI breast cancer dataset and trying to find the top 3 features that have highest weights. I was able to find the weight of all features using logmodel.coef_ but how can I get the feature names? Below is …

Total answers: 2

Why does predict_proba function print the probabilities in reverse order?

Why does predict_proba function print the probabilities in reverse order? Question: I am using scikit-learn to implement classification using Logistic Regression. The class labels are predicted using predict() function, while the predicted probabilities are printed using predict_proba() function. The code snippet is pasted below: # Partition the dataset into train and test data X_train, X_test, …

Total answers: 2

Logistic regression python solvers' definitions

Logistic regression python solvers' definitions Question: I am using the logistic regression function from sklearn, and was wondering what each of the solver is actually doing behind the scenes to solve the optimization problem. Can someone briefly describe what "newton-cg", "sag", "lbfgs" and "liblinear" are doing? Asked By: Clement || Source Answers: Well, I hope …

Total answers: 2

How to increase the model accuracy of logistic regression in Scikit python?

How to increase the model accuracy of logistic regression in Scikit python? Question: I am trying to predict the admit variable with predictors such as gre,gpa and ranks. But the prediction accuracy is very low (0.66).The dataset is given below. https://gist.github.com/abyalias/3de80ab7fb93dcecc565cee21bd9501a The first few rows of the dataset looks like: admit gre gpa rank_2 rank_3 …

Total answers: 2

scikit-learn return value of LogisticRegression.predict_proba

scikit-learn return value of LogisticRegression.predict_proba Question: What exactly does the LogisticRegression.predict_proba function return? In my example I get a result like this: array([ [4.65761066e-03, 9.95342389e-01], [9.75851270e-01, 2.41487300e-02], [9.99983374e-01, 1.66258341e-05] ]) From other calculations, using the sigmoid function, I know, that the second column is the probabilities. The documentation says that the first column is n_samples, …

Total answers: 2

sklearn Logistic Regression "ValueError: Found array with dim 3. Estimator expected <= 2."

sklearn Logistic Regression "ValueError: Found array with dim 3. Estimator expected <= 2." Question: I attempt to solve this problem 6 in this notebook. The question is to train a simple model on this data using 50, 100, 1000 and 5000 training samples by using the LogisticRegression model from sklearn.linear_model. lr = LogisticRegression() lr.fit(train_dataset,train_labels) This …

Total answers: 5