python中import的引用机制引起的坑
最近在撸Scikit-Learn的代码,想加载点Seaborn的数据训练模型,简单的一句seaborn.load_dataset('')都编译通不过。 import matplotlib.pyplot as plt import numpy as np import seaborn as sns from sklearn.linear_model import LinearRegression # 选择模型 model = LinearRegression(fit_intercept=True) # 整理数据 iris = sns.load_dataset('iris') rng = np.random.RandomState(42) x = 10* rng.rand(50) y = 2*x - 1 + rng.randn(50) X = x[:, np.newaxis] #拟合数据 model.fit(X,y) #预测 xfit = np.linspace(-1,11) Xfit = xfit[:, np.newaxis] yfit = model.predict(Xfit) plt...