我正在尝试从with绘制一个plot_tree对象,但我的树图看起来不太好。我的树图看起来被压扁了:sklearnmatplotlib
下面是我的代码:
from sklearn import tree
from sklearn.model_selection import cross_val_score
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
# create tree object
model_gini_class = tree.DecisionTreeClassifier(criterion='gini')
# train the model using the training sets and check score
model_gini_class.fit(X_train, y_train)
model_gini_class.score(X_train, y_train)
# predict output
predicted_gini_class = model_gini_class.predict(X_test)
plt.figure()
tree.plot_tree(model_gini_class, filled=True)
plt.title("Decision trees on the Shakespear dataset (Gini)")
plt.show() # the tree looks squished?
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
sklearnplot_tree对象的大小,使其看起来不被压扁吗?谢谢你,
我正在尝试使用 GCP 文档中提供的 Google Cloud Tasks 代码示例: https: //cloud.google.com/tasks/docs/creating-http-target-tasks(请参阅下面的代码)。但是,从文档中尚不清楚我需要哪个包才能使其工作。有任何想法吗?
但是,我收到以下错误。
ImportError: cannot import name 'tasks_v2' from 'google.cloud'
Run Code Online (Sandbox Code Playgroud)
代码示例:
from google.cloud import tasks_v2
from google.protobuf import timestamp_pb2
# Create a client.
client = tasks_v2.CloudTasksClient()
# TODO(developer): Uncomment these lines and replace with your values.
# project = 'my-project-id'
# queue = 'my-appengine-queue'
# location = 'us-central1'
# payload = 'hello'
# Construct the fully qualified queue name.
parent = client.queue_path(project, location, queue)
# Construct the request body.
task = { …Run Code Online (Sandbox Code Playgroud) 每当我尝试将 statsmodels.formula.api 作为 smf 导入时,我都会收到以下错误。
import statsmodels.formula.api as smf
Traceback (most recent call last):
File "<ipython-input-257-268d740a5877>", line 1, in <module>
import statsmodels.formula.api as smf
File "C:\Users\ldresl\Anaconda3\lib\site-
packages\statsmodels\formula\__init__.py", line 1, in <module>
from statsmodels import PytestTester
ImportError: cannot import name 'PytestTester'
Run Code Online (Sandbox Code Playgroud)