You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestRegressor
import matplotlib.pyplot as plt
from sklearn import tree
import dtreeviz
import pandas as pd
iris = load_iris()
data = pd.DataFrame(iris.data)
X = data.iloc[:,1:4]
y = data.iloc[:,0]
fn=["sepal width","petal length","petal width"]
cn ="sepal length"
clf = RandomForestRegressor(max_depth=4,random_state=2024,min_samples_leaf=10,n_estimators=10,oob_score=True )
clf.fit(X, y)
model = clf.estimators_[0]
no_dup = list(set(clf.estimators_samples_[0]))
X_in = X.loc[no_dup]
y_in = y.loc[no_dup]
viz_model = dtreeviz.model(model,
X_train = X_in,
y_train = y_in,
feature_names=fn,
target_name=cn)
v = viz_model.view(x=X.iloc[0,:]) # render as SVG into internal object
v.show()
v = viz_model.view(x=[3.5,1.4,0.2])
The text was updated successfully, but these errors were encountered:
flystar233
changed the title
The path that dtreeviz takes to show the results of the sample predictions is wrong
The path of dtreeviz to show the sample prediction results is wrong when using iloc directly to select data from the dataframe
Aug 31, 2024
dtreeviz version: 2.2.2
The text was updated successfully, but these errors were encountered: