Category : function

I’ve got an error in python trying to do my homework for python course. The task was to create an array of expenses using operations such as add and list(printing all the elements) The error persists in any version of Python (3.7,3.8,3.9) and in different IDEs ( Visual Studio, PyCharm, some online interpretator) To describe ..

Read more

I use this function: from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression X, y = load_iris(return_X_y=True) for i in range(X.shape[1]): clf = LogisticRegression(random_state=0, verbose=0, max_iter=1000).fit(X[:,i].reshape(-1,1), y) print(clf.score(X[:,i].reshape(-1,1),y)) and i get 4 values as output: 0.7466666666666667 0.5533333333333333 0.9533333333333334 0.96 But when i try to add these 4 values to list: from sklearn.datasets import load_iris from sklearn.linear_model ..

Read more

I have a dataframes. X is dataframe with features. Y is predicted values. I want to write a function to get all accuracies ifI train with model with each column from X. I try this code but it doesn’t work: import sklearn.metrics as mtr from sklearn import linear_model model = linear_model.LogisticRegression(max_iter=3000,solver=’lbfgs’) model.fit(X, Y) def accuracies_find(X, ..

Read more

I have table of population size in two countries in different years that looks like this: year pop1 pop2 0 0 1.000000e+08 1.000000e+08 1 1 9.620000e+07 9.970000e+07 2 2 9.254440e+07 9.940090e+07 3 3 8.902771e+07 9.910270e+07 4 4 8.564466e+07 9.880539e+07 The table has information only about the first 300 years. I’m trying to create a function ..

Read more

So i have this class: import matplotlib.pyplot as plt import numpy as np class F: def __init__(self,n,m): self.n=n self.m=m def __call__(self,x): return np.sin(self.n*x)*np.cos(self.m*x) pi=2*np.pi u = F(7, 1) v = F(3, 5) x=np.linspace(0,2*np.pi,10000) plt.plot(u,v) plt.show So I get the error: TypeError: float() argument must be a string or a number, not ‘F’ When I print ..

Read more