TypeError: scatter() got multiple values for argument 's' (Plot Logistic Regression)

user15601343

I am trying to plot a decision boundary for logistic regression but i got this error :

TypeError: scatter() got multiple values for argument 's'

Here is my code :

logreg = LogisticRegression()
logreg.fit(X_train,y_train)

b = logreg.intercept_[0]
w1, w2 = logreg.coef_.T
c = -b/w2
m = -w1/w2

# Plot the data and the classification with the decision boundary.
xmin, xmax = -1, 2
ymin, ymax = -1, 2.5
xd = np.array([xmin, xmax])
yd = m*xd + c
plt.plot(xd, yd, 'k', lw=1, ls='--')
plt.fill_between(xd, yd, ymin, color='tab:blue', alpha=0.2)
plt.fill_between(xd, yd, ymax, color='tab:orange', alpha=0.2)

plt.scatter(*X[y==0].T, s=8, alpha=0.5)
plt.scatter(*X[y==1].T, s=8,  alpha=0.5)
plt.xlim(xmin, xmax)
plt.ylim(ymin, ymax)
plt.show()

Since i am a beginner i would also like to know if there is possibility to plot my logistic regression including all features or something else (2 most important features). I had to choose only 2 columns here.

EDIT : I also got this error :

TypeError: scatter() takes from 2 to 13 positional arguments but 1715 were given

For your information :

X = df
X = X.drop(columns=['answer']) #features
y = df['answer'] #target 
X.shape # (4948, 2)
y.shape # (4948,)
X[y==0].shape # (1715,2)

Any help would be appreciated ! Thanks.

liorr

The problem is with the shape of what you are trying to plot, namely, X[y==0]. Here I recreate a 1715x2 matrix with the same shape, and try to scatter() it:

import numpy as np
from matplotlib import pyplot as plt

x = np.random.rand(1715, 2)
print(np.shape(x)) # (1715, 2)
plt.scatter(*x, s= 8)

I get a TypeError: scatter() got multiple values for argument 's'.

However, if I transpose it:

x = np.random.rand(1715, 2)
print(np.shape(x))
plt.scatter(*x.T, s= 8)

plt.show()

I get:

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TypeError: got multiple values for argument

class method generates "TypeError: ... got multiple values for keyword argument ..."

TypeError: pivot_table() got multiple values for keyword argument 'values'

TypeError: bar() got multiple values for keyword argument 'height'

TypeError: to_excel() got multiple values for argument 'sheet_name'

TypeError: concat() got multiple values for argument 'axis'

Keras Concatenate TypeError: __init__() got multiple values for argument 'axis'

TypeError update() got multiple values for argument 'upsert' with $setOnInsert

TypeError: inner() got multiple values for keyword argument 'ax'

TypeError: dropna() got multiple values for argument 'axis'

TypeError: products() got multiple values for argument 'pk'

TypeError: __init__() got multiple values for argument 'strides'

TypeError: __init__() got multiple values for argument 'fieldnames'

Django - TypeError ; got multiple values for argument

TypeError: got multiple values for argument 'dictionary'

TypeError: __init__() got multiple values for argument 'n_splits'

TypeError: got multiple values for argument when passing in *args

TypeError: barh() got multiple values for argument 'width'

TypeError: __init__() got multiple values for argument 'axes'

TypeError: update_one() got multiple values for argument 'upsert'

TypeError: "__init__() got multiple values for keyword argument 'name'"

tensorflow TypeError: run() got multiple values for argument 'feed_dict'

TypeError: loadshortlink() got multiple values for argument 'shortlink'

TypeError: scatter() got multiple values for argument 'c'

Python plot error : annotate() got multiple values for argument 'xy'

TypeError : got multiple values for argument 'reports_pk'

TypeError: TimeGrouper.__init__() got multiple values for argument 'freq'

TypeError: __init__() got multiple values for argument 'options'

Odoo, Python: TypeError: info() got multiple values for keyword argument 'title'

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive