我正在尝试通过sklearn lib树绘制一棵树,但是问题是列索引写在图片中。
public buildForm() {
this.editForm = this.form.group({
username: [this.username, [Validators.required, Validators.minLength(this.minLength), CustomValidators.validateCharacters], AlreadyTakenValidator.checkUsername(this.registrationService)],
email: [this.email, [Validators.required, Validators.email, CustomValidators.validateCharacters], AlreadyTakenValidator.checkEmail(this.registrationService)],
oldPassword: ['', [Validators.required]],
newPassword: ['', [Validators.required]],
newPasswordConf: ['', [Validators.required]],
firstname: [this.firstname, [Validators.required, NoWhitespaceValidator()]],
lastname: [this.lastname, [Validators.required, NoWhitespaceValidator()]],
country: ['', [Validators.required]],
dateOfBirth: ['', [Validators.required]],
gender: ['', [Validators.required]],
}
, {
validator: MustMatch('newPassword', 'newPasswordConf')
})
}
答案 0 :(得分:2)
使用feature_names
and class_names
parameters:
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
clf = tree.DecisionTreeClassifier(random_state=0).fit(iris.data, iris.target)
tree.plot_tree(clf, feature_names=iris.feature_names, class_names=iris.target_names)