コード例 #1
0
def main():
    training = datas.training
    training = training.drop(["SibSp"], axis=1)
    testing  = datas.testing
    testing  = testing.drop(["SibSp"], axis=1)
    random_forest = RandomForestClassifier(n_estimators=100, min_samples_split=1, max_depth=None, min_samples_leaf=5)
    random_forest = random_forest.fit(pca.reduced_data(training),training.ix[:,'Survived'])
    result = random_forest.predict(pca.reduced_data(testing))
    return result
コード例 #2
0
def main():
    training = datas.training
    training = training.drop(["Embarked"], axis=1)
    testing = datas.testing
    testing = testing.drop(["Embarked"], axis=1)

    knn = KNeighborsClassifier(15, weights="uniform")
    knn.fit(pca.reduced_data(training, 4), training.ix[:, "Survived"])
    result = knn.predict(pca.reduced_data(testing, 4))
    datas.write_data(result)
コード例 #3
0
def main():
    training = datas.training
    training = training.drop(['Embarked'], axis=1)
    testing = datas.testing
    testing = testing.drop(['Embarked'], axis=1)

    knn = KNeighborsClassifier(15, weights="uniform")
    knn.fit(pca.reduced_data(training, 4), training.ix[:, 'Survived'])
    result = knn.predict(pca.reduced_data(testing, 4))
    datas.write_data(result)
コード例 #4
0
def test():
    training = datas.training
    knn = KNeighborsClassifier(25, weights="uniform")
    kfold = cross_validation.KFold(len(training), 3)
    result = cross_validation.cross_val_score(knn,
                                              pca.reduced_data(training),
                                              training['Survived'],
                                              cv=kfold,
                                              n_jobs=1)
    print result
コード例 #5
0
def test():
    training = datas.training
    knn = KNeighborsClassifier(25, weights="uniform")
    kfold = cross_validation.KFold(len(training), 3)
    result = cross_validation.cross_val_score(knn, pca.reduced_data(training), training["Survived"], cv=kfold, n_jobs=1)
    print result