This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from sklearn.model_selection import KFold | |
import dill as pickle | |
import sys | |
def input_data(train_file): | |
with open(train_file, 'rb') as f1: | |
train_data = pickle.load(f1) | |
cat_feature = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_batch(data, batch_size, skip_window): | |
""" | |
Generates a mini-batch of training data for the training CBOW | |
embedding model. | |
:param data (numpy.ndarray(dtype=int, shape=(corpus_size,)): holds the | |
training corpus, with words encoded as an integer | |
:param batch_size (int): size of the batch to generate | |
:param skip_window (int): number of words to both left and right that form | |
the context window for the target word. | |
Batch is a vector of shape (batch_size, 2*skip_window), with each entry for the batch containing all the context words, with the corresponding label being the word in the middle of the context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ensemble(object): | |
def __init__(self, n_splits, stacker, base_models): | |
self.n_splits = n_splits | |
self.stacker = stacker | |
self.base_models = base_models | |
def fit_predict(self, X, y, T): | |
X = np.array(X) | |
y = np.array(y) | |
T = np.array(T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from csv import DictReader | |
from math import exp, log, sqrt,pow | |
import itertools | |
import math | |
from random import random,shuffle,uniform,seed | |
import pickle | |
import sys | |
seed(1024) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## for category columns | |
def category_feature2FFM(data, category_list): | |
previous_len = 0 | |
for i in range(len(category_list)): | |
category_name = category_list[i] | |
dic = data[category_name].unique() | |
dic = dict(zip(dic, range(len(dic)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.hq.modules.executor.service.impl; | |
import com.alibaba.fastjson.JSON; | |
import com.hq.common.utils.GenericSuperclassUtil; | |
import com.hq.common.utils.HttpResult; | |
import com.hq.common.utils.HttpUtils; | |
import com.shaw.common.model.RoadLink; | |
import com.shaw.common.model.TaskInfo; | |
import com.shaw.common.model.TrafficLightModel; | |
import com.shaw.common.model.TrafficStateData; |