根据numpy.r_ 这里的numpy/scipy doc ,它"不是一个函数,因此不需要参数".
如果它不是一个函数,那么"函数"的正确用语是numpy.r_什么?
我有一个这种形式的numpy数组
[[-0.77947021 0.83822138]
[ 0.15563491 0.89537743]
[-0.0599077 -0.71777995]
[ 0.20759636 0.75893338]]
Run Code Online (Sandbox Code Playgroud)
我想创建这种形式的numpy的阵列[x1, x2, x1*x2],其中[x1, x2]是从原来的数组列表.
目前我正在使用python代码创建列表列表,然后将其转换为numpy数组.但我认为可能有更好的方法来做到这一点.
我以为我理解lambda函数是如何工作的,尽管我自己并没有使用它们.但是本教程下面的lambda 完全让我感到困惑:
import matplotlib.pyplot as plt
import numpy as np
import sklearn
import sklearn.datasets
import sklearn.linear_model
import matplotlib
Run Code Online (Sandbox Code Playgroud)
那很简单.更多:
# Generate a dataset and plot it
np.random.seed(0)
X, y = sklearn.datasets.make_moons(200, noise=0.20)
plt.scatter(X[:,0], X[:,1], s=40, c=y, cmap=plt.cm.Spectral)
clf = sklearn.linear_model.LogisticRegressionCV()
clf.fit(X, y)
# Helper function to plot a decision boundary.
# If you don't fully understand this function don't worry, it just generates the contour plot below.
def plot_decision_boundary(pred_func):
# Set min and max values and give it …Run Code Online (Sandbox Code Playgroud)