<jupyter_start><jupyter_text>Fit test<jupyter_code>X_train=pd.DataFrame({'aa':[0.1,0.2,0.7,0.8,0.8],
                      'bb':[1,0,1,0,0],
                      'cc':[1,0,1,1,0]})
X_train
y_train=pd.Series([0,0,1,1,0])
y_train
dtc=DecisionTreeClassifier()
dtc.fit(X_train,y_train)
dtc.tree
X_test=pd.DataFrame({'aa':[0.1,0.2,0.7,0.8,0.8],
                      'bb':[1,0,1,0,0],
                      'cc':[1,0,1,1,0]})
dtc.predict(X_test)<jupyter_output><empty_output><jupyter_text>Predict test<jupyter_code>dtc=DecisionTreeClassifier(min_samples_split=10)
dtc.tree={'level': 0,
 'type': 'root',
 'feature': 'aa',
 'threshold': 0.5,
 'left': None,
 'right': None}
dtc.tree['left']={'level': 1,
                 'type': 'root',
                 'feature': 'bb',
                 'threshold': 0.5,
                 'left': {'level':2,'type':'leaf','category':1},
                 'right': {'level':2,'type':'leaf','category':0}}
dtc.tree['right']={'level':1,
                  'type':'leaf',
                  'category':1}
X_test=pd.DataFrame({'aa':[0.1,0.2,0.7],'bb':[1,0,1],'cc':[1,1,0]})
X_test
(dtc.predict(X_test)==pd.Series([0,1,1])).all()
X_test
splits={}
for index,col in X_test.iteritems():
    splits[index]=np.sort(col.sample(1000,replace=True).unique())
    splits[index]=list((splits[index][1:]+splits[index][:-1])/2)
splits
splits=[[(key,threshold) for threshold in value] for key,value in splits.items()]
splits=[y for x in splits for y in x]
splits
ser=pd.Series([4,2,3,4])
ser
np.random.choice(ser.unique(),6)
np.sort(ser.sample(1000,replace=True).unique())
npp=np.sort(ser.unique())
npp
(npp[1:]+npp[:-1])/2
X_test
y_test=pd.DataFrame({'target':[1,0,1]})
y_test
y_test.iloc[:,0][mask]
mask=X_test['bb']>0.5
y_left=y_test[mask].iloc[:,0]
y_left
1-((y_test.iloc[:,0].groupby(y_test.iloc[:,0]).count()/y_test.iloc[:,0].count())**2).sum()
type(y_test)==pd.core.frame.DataFrame
mask
y_test.iloc[:,0]
[3,4]+[3]
y_test.iloc[:,0]#.mode()
lis=[2,5,6,2,7]
lis.index(min(lis))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24962779156327544, 'fraction_numerical': 0.05707196029776675, 'mean_word_length': 4.263707571801566, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '612086', 'license': 'MIT', 'n_tokens_mistral': 916, 'n_tokens_neox': 900, 'n_words': 95, 'path': 'notebooks/Decision_trees_development_notebook.ipynb', 'repo_name': 'bdepebhe/handmadeML', 'size': '2015'}