Re: Excersize

From Smelly Mockingjay, 7 Months ago, written in Plain Text, viewed 154 times. This paste is a reply to Excersize from Ivan Kirilenkov - go back
URL http://codebin.org/view/534291fd/diff Embed
Viewing differences between Excersize and Re: Excersize
import pandas as pd
from sklearn.tree import DecisionTreeClassifier

data = pd.read_csv('/datasets/heart.csv')
features = data.drop(['target'], axis=1)
target = data['target']

scores = []

# ??????? ?????? ?????, ???? ?? ????? ???
sample_size = int(len(data)/3)

for i in range(0, len(data), sample_size):
    valid_indexes = data.loc[i: i+sample_size].index
    train_indexes = data[:i].index.union(data[i+sample_size:].index)
                # ???????? ?????????? features ? target ?? ??????? features_train, target_train, features_valid, target_valid
    # < ???????? ??? ????? >
    features_valid = features.loc[valid_indexes]
    target_valid = target.loc[valid_indexes]
    features_train = features.loc[train_indexes]
    target_train = target.loc[train_indexes]

    model = DecisionTreeClassifier(random_state=0)
    model = model.fit(features_train, target_train)
    score = model.score(features_valid, target_valid) # < ??????? ???????? ?????? >
   
    scores.append(score)

scores = pd.Series(scores)
final_score = scores.mean()
print('??????? ?????? ???????? ??????:', final_score)

Replies to Re: Excersize rss

Title Name Language When
Re: Re: Excersize Cute Duck text 7 Months ago.

Reply to "Re: Excersize"

Here you can reply to the paste above