After a small example, we will now deploy the algorithm that we just developed and test it in our click-through prediction project.
Again, the first 10,000 samples are for training and the next 10,000 are for testing:
>>> n = 10000
>>> X_dict_train, y_train = read_ad_click_data(n)
>>> dict_one_hot_encoder = DictVectorizer(sparse=False)
>>> X_train = dict_one_hot_encoder.fit_transform(X_dict_train)
>>> X_dict_test, y_test = read_ad_click_data(n, n)
>>> X_test = dict_one_hot_encoder.transform(X_dict_test)
>>> X_train_10k = X_train
>>> y_train_10k = np.array(y_train)
Train a logistic regression model by 10000 iterations, at learning rate 0.01 based on intercept-included weights, and print out current costs at every 1000 iterations:
>>> import timeit
>>> start_time...