Пример #1
0
def final_model(df):

    #final model we decided on through selection
    model = RandomForestClassifier(bootstrap=True,
                                   class_weight=None,
                                   criterion='gini',
                                   max_depth=None,
                                   max_features='log2',
                                   max_leaf_nodes=None,
                                   min_impurity_decrease=0.0,
                                   min_impurity_split=None,
                                   min_samples_leaf=1,
                                   min_samples_split=2,
                                   min_weight_fraction_leaf=0.0,
                                   n_estimators=400,
                                   n_jobs=1,
                                   oob_score=False,
                                   random_state=None,
                                   verbose=0,
                                   warm_start=False)

    #get the data in the form we want according to transform function
    X, y = transform_train(df)

    #fit the model
    model.fit(X, y)

    with open('website/model.pkl', 'wb') as f:
        # Write the model to a file.
        pickle.dump(model, f)
Пример #2
0
    if args.src == 'visda':
        src = visda_train
        tgt = visda_test
        visda = True
    return src, tgt, office, visda, noe


src, tgt, office, visda, noe = get_datasetname(args)

batch_size = {"train": 36, "val": 36, "test": 4}
for i in range(10):
    batch_size["val" + str(i)] = 4

if visda == False:
    data_transforms = {
        'train': tran.transform_train(resize_size=28, crop_size=28),
        'val': tran.transform_train(resize_size=28, crop_size=28),
    }
    data_transforms = tran.transform_test(data_transforms=data_transforms,
                                          resize_size=28,
                                          crop_size=28)
    dsets = {
        "train":
        ImageList(open(src).readlines(), transform=data_transforms["train"]),
        "val":
        ImageList(open(tgt).readlines(), transform=data_transforms["val"]),
        "test":
        ImageList(open(tgt).readlines(), transform=data_transforms["val"])
    }
    dset_loaders = {
        x: torch.utils.data.DataLoader(dsets[x],
Пример #3
0
    if args.src == 'visda':
        src = visda_train
        tgt = visda_test
        visda = True
    return src, tgt, office, visda, noe


src, tgt, office, visda, noe = get_datasetname(args)

batch_size = {"train": 36, "val": 36, "test": 4}
for i in range(10):
    batch_size["val" + str(i)] = 4

if visda == False:
    data_transforms = {
        'train': tran.transform_train(resize_size=256, crop_size=224),
        'val': tran.transform_train(resize_size=256, crop_size=224),
    }
    data_transforms = tran.transform_test(data_transforms=data_transforms,
                                          resize_size=256,
                                          crop_size=224)
    dsets = {
        "train":
        ImageList(open(src).readlines(), transform=data_transforms["train"]),
        "val":
        ImageList(open(tgt).readlines(), transform=data_transforms["val"]),
        "test":
        ImageList(open(tgt).readlines(), transform=data_transforms["val"])
    }
    dset_loaders = {
        x: torch.utils.data.DataLoader(dsets[x],