repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/utils.py | from typing import Optional, Tuple
import holidays
import pandas as pd
class HolidayUtil:
def __init__(self, country="US"):
try:
country, subdivision = self.convert_to_subdivision(country)
self.holidays = holidays.country_holidays(
country=country,
... | 1,730 | 32.288462 | 88 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_working_hours.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsWorkingHours(TransformPrimitive):
"""Determines if a datetime falls during working hour... | 1,718 | 37.2 | 117 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/date_to_holiday.py | import pandas as pd
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Categorical, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.primitives.standard.transform.datetime.utils import HolidayUtil
class DateToHoliday(TransformPrimitive):
"""Tr... | 2,356 | 35.261538 | 84 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_month_start.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsMonthStart(TransformPrimitive):
"""Determines the is_month_start attribute of a datetim... | 1,035 | 31.375 | 68 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/part_of_day.py | import numpy as np
import pandas as pd
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Categorical, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class PartOfDay(TransformPrimitive):
"""Determines the part ... | 2,609 | 35.760563 | 84 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/date_to_timezone.py | import numpy as np
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Categorical, Datetime
from featuretools.primitives.base import TransformPrimitive
class DateToTimeZone(TransformPrimitive):
"""Determines the timezone of a datetime.
Description:
Given a list of dat... | 1,428 | 36.605263 | 84 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/days_in_month.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class DaysInMonth(TransformPrimitive):
"""Determines the number of days in the month of given datetime.... | 1,089 | 30.142857 | 68 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_federal_holiday.py | import numpy as np
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.primitives.standard.transform.datetime.utils import HolidayUtil
class IsFederalHoliday(TransformPrimitive):
... | 1,697 | 34.375 | 81 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/day_of_year.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class DayOfYear(TransformPrimitive):
"""Determines the ordinal day of the year from the given datetime
... | 1,180 | 29.282051 | 69 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/weekday.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class Weekday(TransformPrimitive):
"""Determines the day of the week from a datetime.
Description:... | 1,197 | 29.717949 | 65 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_quarter_end.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsQuarterEnd(TransformPrimitive):
"""Determines the is_quarter_end attribute of a datetim... | 974 | 30.451613 | 68 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_year_start.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsYearStart(TransformPrimitive):
"""Determines if a date falls on the start of a year.
... | 1,112 | 31.735294 | 71 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/hour.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class Hour(TransformPrimitive):
"""Determines the hour value of a datetime.
Examples:
>>> ... | 1,015 | 28.028571 | 65 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/day.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class Day(TransformPrimitive):
"""Determines the day of the month from a datetime.
Examples:
... | 999 | 27.571429 | 65 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_quarter_start.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsQuarterStart(TransformPrimitive):
"""Determines the is_quarter_start attribute of a dat... | 990 | 30.967742 | 70 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/__init__.py | from featuretools.primitives.standard.transform.datetime.age import Age
from featuretools.primitives.standard.transform.datetime.date_to_holiday import (
DateToHoliday,
)
from featuretools.primitives.standard.transform.datetime.date_to_timezone import (
DateToTimeZone,
)
from featuretools.primitives.standard.tr... | 2,903 | 46.606557 | 88 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/time_since.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils import convert_time_units
from featuretools.utils.gen_utils import Library
class TimeSince(TransformPrimitive):
"""Calculates time from a... | 2,070 | 35.982143 | 83 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_month_end.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsMonthEnd(TransformPrimitive):
"""Determines the is_month_end attribute of a datetime co... | 1,018 | 30.84375 | 66 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/diff_datetime.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Timedelta
from featuretools.primitives.standard.transform.numeric.diff import Diff
class DiffDatetime(Diff):
"""Computes the timedelta between a datetime in a list and the
previous datetime in that list.
Args:
... | 1,668 | 38.738095 | 139 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/week.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime, Ordinal
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class Week(TransformPrimitive):
"""Determines the week of the year from a datetime.
Description:
... | 1,336 | 30.093023 | 74 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/is_leap_year.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils.gen_utils import Library
class IsLeapYear(TransformPrimitive):
"""Determines the is_leap_year attribute of a datetime co... | 1,044 | 31.65625 | 66 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/time_since_previous.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.utils import convert_time_units
class TimeSincePrevious(TransformPrimitive):
"""Computes the time since the previous entry in a list.
Args... | 1,746 | 34.653061 | 85 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/season.py | from datetime import date
import pandas as pd
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Categorical, Datetime
from featuretools.primitives.base import TransformPrimitive
class Season(TransformPrimitive):
"""Determines the season of a given datetime.
Returns winte... | 1,968 | 33.54386 | 84 | py |
featuretools | featuretools-main/featuretools/primitives/standard/transform/datetime/distance_to_holiday.py | import pandas as pd
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Datetime
from featuretools.primitives.base import TransformPrimitive
from featuretools.primitives.standard.transform.datetime.utils import HolidayUtil
class DistanceToHoliday(TransformPrimitive):
"""Computes th... | 3,274 | 35.388889 | 85 | py |
featuretools | featuretools-main/featuretools/primitives/base/transform_primitive_base.py | from featuretools.primitives.base.primitive_base import PrimitiveBase
class TransformPrimitive(PrimitiveBase):
"""Feature for dataframe that is a based off one or more other features
in that dataframe."""
# (bool) If True, feature function depends on all values of dataframe
# (and will receive thes... | 817 | 34.565217 | 86 | py |
featuretools | featuretools-main/featuretools/primitives/base/aggregation_primitive_base.py | from featuretools.primitives.base.primitive_base import PrimitiveBase
class AggregationPrimitive(PrimitiveBase):
def generate_name(
self,
base_feature_names,
relationship_path_name,
parent_dataframe_name,
where_str,
use_prev_str,
):
base_features_str = "... | 1,057 | 25.45 | 69 | py |
featuretools | featuretools-main/featuretools/primitives/base/primitive_base.py | import os
from inspect import signature
import numpy as np
import pandas as pd
from featuretools import config
from featuretools.utils.description_utils import convert_to_nth
from featuretools.utils.gen_utils import Library
class PrimitiveBase(object):
"""Base class for all primitives."""
#: (str): Name of... | 6,014 | 35.23494 | 83 | py |
featuretools | featuretools-main/featuretools/primitives/base/__init__.py | from featuretools.primitives.base.aggregation_primitive_base import AggregationPrimitive
from featuretools.primitives.base.primitive_base import PrimitiveBase
from featuretools.primitives.base.transform_primitive_base import TransformPrimitive
| 244 | 60.25 | 88 | py |
featuretools | featuretools-main/featuretools/selection/api.py | # flake8: noqa
from featuretools.selection.selection import *
| 62 | 20 | 46 | py |
featuretools | featuretools-main/featuretools/selection/selection.py | import pandas as pd
from woodwork.logical_types import Boolean, BooleanNullable
def remove_low_information_features(feature_matrix, features=None):
"""Select features that have at least 2 unique values and that are not all null
Args:
feature_matrix (:class:`pd.DataFrame`): DataFrame whose columns are... | 8,895 | 38.362832 | 113 | py |
featuretools | featuretools-main/featuretools/selection/__init__.py | # flake8: noqa
from featuretools.selection.api import *
| 56 | 18 | 40 | py |
featuretools | featuretools-main/featuretools/feature_discovery/LiteFeature.py | from __future__ import annotations
import hashlib
from dataclasses import field
from functools import total_ordering
from typing import Any, Dict, List, Optional, Set, Type, Union
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import LogicalType
from featuretools.feature_discovery.utils ... | 9,826 | 29.236923 | 87 | py |
featuretools | featuretools-main/featuretools/feature_discovery/feature_discovery.py | import inspect
from collections import defaultdict
from itertools import combinations, permutations, product
from typing import Iterable, List, Set, Tuple, Type, Union, cast
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import LogicalType
from woodwork.table_schema import TableSchema
fro... | 12,161 | 30.754569 | 128 | py |
featuretools | featuretools-main/featuretools/feature_discovery/FeatureCollection.py | from __future__ import annotations
import hashlib
from itertools import combinations
from typing import Any, Dict, List, Optional, Set, Type, Union, cast
from woodwork.logical_types import LogicalType
from featuretools.feature_discovery.LiteFeature import LiteFeature
from featuretools.feature_discovery.type_defs imp... | 9,039 | 34.873016 | 126 | py |
featuretools | featuretools-main/featuretools/feature_discovery/convertors.py | from __future__ import annotations
from typing import Dict, List
import pandas as pd
from woodwork.logical_types import LogicalType
from featuretools.feature_base.feature_base import (
FeatureBase,
IdentityFeature,
TransformFeature,
)
from featuretools.feature_discovery.LiteFeature import LiteFeature
fro... | 6,120 | 27.207373 | 78 | py |
featuretools | featuretools-main/featuretools/feature_discovery/utils.py | import hashlib
import json
from functools import lru_cache
from typing import Any, Dict, Tuple
from woodwork.column_schema import ColumnSchema
from featuretools.feature_discovery.type_defs import ANY
from featuretools.primitives.base.primitive_base import PrimitiveBase
from featuretools.primitives.utils import (
... | 2,172 | 26.858974 | 97 | py |
featuretools | featuretools-main/featuretools/feature_discovery/type_defs.py | ANY = "ANY"
| 12 | 5.5 | 11 | py |
featuretools | featuretools-main/docs/notebook_version_standardizer.py | import json
import os
import click
DOCS_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source")
def _get_ipython_notebooks(docs_source):
directories_to_skip = ["_templates", "generated", ".ipynb_checkpoints"]
notebooks = []
for root, _, filenames in os.walk(docs_source):
if any... | 5,577 | 31.811765 | 86 | py |
featuretools | featuretools-main/docs/source/setup.py | import os
import featuretools as ft
def load_feature_plots():
es = ft.demo.load_mock_customer(return_entityset=True)
path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"getting_started/graphs/",
)
agg_feat = ft.AggregationFeature(
ft.IdentityFeature(es["sessions"... | 1,071 | 28.777778 | 78 | py |
featuretools | featuretools-main/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# featuretools documentation build configuration file, created by
# sphinx-quickstart on Thu May 19 20:40:30 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
... | 13,163 | 31.029197 | 108 | py |
featuretools | featuretools-main/docs/source/set-headers.py | import urllib.request
opener = urllib.request.build_opener()
opener.addheaders = [("Testing", "True")]
urllib.request.install_opener(opener)
| 142 | 22.833333 | 41 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/self_learning.py | import numpy as np
from sklearn.ensemble import RandomForestClassifier
import pyximport;
pyximport.install()
import self_learning_cython as slc
def joint_bayes_risk(margin, pred, i, j, theta, samplingRate=50):
# li = \sum_{x\in X_U} \I{y=i} =approx.= \sum_{x\in X_U} m_Q(x,i)
li = np.sum(margin[:, i])
marg... | 6,771 | 32.86 | 117 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/tsvm.py | import numpy as np
import pandas as pd
import subprocess
import os
from sklearn.datasets import dump_svmlight_file
import aux_functions as af
def create_folders(db_name, num_exp):
try:
os.mkdir("output")
except FileExistsError:
pass
try:
os.mkdir("output/"+db_name)
except FileE... | 3,258 | 30.038095 | 111 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/experiment_test.py | # classifiers
from sklearn.semi_supervised import LabelPropagation
from sklearn.ensemble import RandomForestClassifier
import tsvm
import self_learning as sl
# auxiliary functions
from aux_functions import ReadDataset, partially_labeled_view
from sklearn.model_selection import train_test_split
from sklearn.metrics impo... | 5,008 | 35.297101 | 106 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/simple_test.py | # classifiers
from sklearn.semi_supervised import LabelPropagation
from sklearn.ensemble import RandomForestClassifier
import tsvm
import self_learning as sl
# auxiliary functions
from aux_functions import ReadDataset, partially_labeled_view
from sklearn.model_selection import train_test_split
from sklearn.metrics impo... | 4,337 | 29.765957 | 96 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/aux_functions.py | import numpy as np
from sklearn.datasets import load_svmlight_file
class ReadDataset:
"""
A class to read different datasets in numpy.ndarray format.
1. DNA Data Set: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass.html
2. Vowel Data Set: https://www.csie.ntu.edu.tw/~cjlin/libsvmtoo... | 2,087 | 31.625 | 103 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/new-module/pseudo_label_policy.py | import numpy as np
# import pyximport; pyximport.install(setup_args={"include_dirs": np.get_include()},
# language_level="3", reload_support=True)
from .self_learning_cython import c_optimal_threshold_vector
class Policy:
def __init__(self):
self.returned_subset = np.ar... | 9,110 | 36.187755 | 112 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/new-module/self_learning.py | from .pseudo_label_policy import *
import numpy as np
from copy import deepcopy
class SelfLearning:
def __init__(self, base_estimator=None, policy='confidence', voting='soft', theta='auto', cython=True,
sup_prob=True, worst_prob=False, fixed_prob=None, num_take=None, decreased_pl_weights=True,
... | 9,772 | 43.221719 | 119 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/new-module/setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy as np
extensions = [
Extension("self_learning_cython", sources=["self_learning_cython.pyx"], libraries=["m"],
include_dirs=[np.get_include... | 611 | 35 | 118 | py |
trans-bounds-maj-vote | trans-bounds-maj-vote-master/new-module/__init__.py | # -*- coding: utf-8 -*-
"""Self-learning module."""
__author__ = """Vasilii Feofanov"""
__email__ = 'vasilii.feofanov@gmail.com'
__version__ = '0.1.0'
from .self_learning import SelfLearning
__all__ = ["SelfLearning"]
| 222 | 17.583333 | 40 | py |
scientific-re | scientific-re-main/main.py | import os
import random
import torch
import numpy
import torch.backends.cudnn
from src.data.prepare_data import Preparedata
from src.model.CNN import CNN
from src.model.run import Run
from src.parameters.parameters import Parameters
class Controller(Parameters):
def __init__(self):
# prepare the data
... | 1,999 | 26.027027 | 73 | py |
scientific-re | scientific-re-main/src/data/prepare_data.py | import numpy
class Preparedata:
def __init__(self, params):
self.dataset_train = params.train
self.relations_train = params.train_relations
self.dataset_dev = params.dev
self.relations_dev = params.dev_relations
self.dataset_test = params.test
self.relations_test =... | 5,379 | 40.705426 | 172 | py |
scientific-re | scientific-re-main/src/model/CNN.py | import torch
from torch import nn
import torch.nn.functional as F
class CNN(torch.nn.Module):
def __init__(self, params):
super().__init__()
self.device = params.device
self.dropout = nn.Dropout(params.dropout)
self.embedding_size = params.bert_emb_size + 2 * params.position_emb... | 1,788 | 33.403846 | 125 | py |
scientific-re | scientific-re-main/src/model/run.py | import torch
from sklearn.metrics import f1_score
from torch import optim, nn
from torch.utils.data import Dataset, DataLoader
from transformers import AutoTokenizer, AutoModel
class DatasetMaper(Dataset):
def __init__(self, s, p1, p2, y):
self.s = s
self.p1 = p1
self.p2 = p2
self.... | 9,545 | 45.565854 | 200 | py |
scientific-re | scientific-re-main/src/parameters/parameters.py | from dataclasses import dataclass
import torch
@dataclass
class Parameters:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
seeds = [3828, 3152, 2396]
# Files
train = 'sample-data/sample-train.txt'
train_relations = 'sample-data/sample-train-rel.txt'
dev = 'sample-data/... | 1,140 | 25.534884 | 106 | py |
gaze-spirals | gaze-spirals-main/clock.py | import json
import argparse
from pupil_labs.realtime_api.simple import Device
from utils.utils_clock import blank_clock, create_clock
from utils.utils_linear import scanlines_from_pupil_device
parser = argparse.ArgumentParser()
parser.add_argument('--ip', required=True, type=str)
parser.add_argument('--port', requir... | 956 | 37.28 | 77 | py |
gaze-spirals | gaze-spirals-main/spiral.py | import argparse
import json
import cv2 as cv
from utils.utils_load import VideoReader, GazeReader
from utils.utils_spiral import create_spiral, blank_spiral
from utils.utils_linear import scanlines_from_files
parser = argparse.ArgumentParser()
parser.add_argument('--gaze', required=True, type=str)
parser.add_argumen... | 1,039 | 36.142857 | 96 | py |
gaze-spirals | gaze-spirals-main/linear.py | import argparse
import json
import cv2 as cv
import numpy as np
from utils.utils_linear import scanlines_from_files
from utils.utils_load import VideoReader, GazeReader
from linear import scanlines_from_files
from tqdm import tqdm
def create_blank(width, height, rgb_color=(10, 10, 10)):
image = np.zeros((width, ... | 2,694 | 38.632353 | 155 | py |
gaze-spirals | gaze-spirals-main/utils/utils_clock.py | import numpy as np
import cv2 as cv
def get_angle(num_sample, angle_k):
return np.radians(pow(num_sample, angle_k))
def get_radius(angle, height):
return height*angle/(2*np.pi)
def hex2bgr(hex_str):
r = int(hex_str[1:3], 16)
g = int(hex_str[3:5], 16)
b = int(hex_str[5:7], 16)
return np.arr... | 3,820 | 32.814159 | 126 | py |
gaze-spirals | gaze-spirals-main/utils/utils_spiral.py | import cv2 as cv
import numpy as np
def get_angle(num_sample, angle_k):
return np.radians(pow(num_sample, angle_k))
def get_radius(angle, height):
return height*angle / (2*np.pi)
def spiral_set_scanline(spiral, line, num_sample, kwargs):
line_height = kwargs['slitscan']['line_height']
line_width =... | 2,075 | 32.483871 | 105 | py |
gaze-spirals | gaze-spirals-main/utils/utils_linear.py | import cv2 as cv
import numpy as np
import time
def transform_frame(img, new_height):
height, width = img.shape[:2]
aspect = width / height
videoWidth = int(new_height*aspect)
videoHeight = new_height
return cv.resize(img, (videoWidth, videoHeight), interpolation=cv.INTER_CUBIC)
def transform_ga... | 3,085 | 39.077922 | 133 | py |
gaze-spirals | gaze-spirals-main/utils/utils_load.py | import cv2 as cv
import numpy as np
import json
from lib.gaze_utils.load import parse_gaze
class VideoReader:
"""This class reads video data"""
def __init__(self, filename):
self.videoCapture = cv.VideoCapture(filename)
# get frames per second
self.videoCaptureFps = self.videoCaptur... | 1,704 | 31.169811 | 89 | py |
gaze-spirals | gaze-spirals-main/lib/gaze_utils/eyelink_utils.py | import pandas as pd
def parse_eyelink_fixations(fixation_events, separator='\t', check_consistency=True):
efix_events = [s for s in fixation_events if s.startswith('EFIX')]
if check_consistency:
sfix_events = [s for s in fixation_events if s.startswith('SFIX')]
assert len(sfix_events) == len(e... | 2,176 | 47.377778 | 119 | py |
gaze-spirals | gaze-spirals-main/lib/gaze_utils/utils.py | def add_frame_col(gaze, fps, remove_offset=False):
if 'FRAME' in gaze:
raise ValueError('FRAME column already exists!')
if remove_offset:
offset = gaze['TIME_MS'].values[0]
else:
offset = 0
gaze['FRAME'] = gaze['TIME_MS'].apply(lambda t_ms: (t_ms-offset)*fps/1000).round()
gaz... | 367 | 32.454545 | 86 | py |
gaze-spirals | gaze-spirals-main/lib/gaze_utils/load.py | import pandas as pd
import re
from tqdm import tqdm
def get_columns(config):
columns = {}
for col in config['columns']:
p = col['position']
columns[p] = col['mappedTo']
columns = sorted(columns.items(), key=lambda x: x[0])
return zip(*columns)
def split_lines(filename, separator, mappings, use_cols):
"""
... | 2,896 | 31.550562 | 141 | py |
gaze-spirals | gaze-spirals-main/lib/gaze_utils/__init__.py | 0 | 0 | 0 | py | |
gaze-spirals | gaze-spirals-main/lib/gaze_utils/scripts/edf2asc.py | import subprocess
import argparse
from glob import glob
import os
import os.path
EDF2ASC_OPTIONS = [
'-sg', # outputs sample GAZE data if present (default)
'-nv', # hide viewer commands
'-nmsg', # blocks message event output
'-t', # use only tabs as delimiters
]
def edf_to_asc(edf_file: str... | 1,619 | 30.764706 | 82 | py |
openabe | openabe-master/bindings/python/test.py | from __future__ import print_function
import pyopenabe
print("Testing Python bindings for PyOpenABE...")
openabe = pyopenabe.PyOpenABE()
cpabe = openabe.CreateABEContext("CP-ABE")
cpabe.generateParams()
cpabe.keygen("|two|three|", "alice")
pt1 = b"hello world!"
ct = cpabe.encrypt("((one or two) and three)", pt1)
... | 2,203 | 21.04 | 65 | py |
openabe | openabe-master/bindings/python/setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import os, sys
__version__ = "1.0.0"
os_platform = sys.platform
ZROOT_DIR = os.environ.get('ZROOT')
ZML_LIB = os.environ.get('ZML_LIB')
if (ZROOT_DIR is None):
sys.exit("Need to source env via '. ./en... | 2,078 | 33.65 | 101 | py |
taskgrouping | taskgrouping-master/taskonomy_loader.py | import torch.utils.data as data
from PIL import Image, ImageOps
import os
import os.path
import zipfile as zf
import io
import logging
import random
import copy
import numpy as np
import time
import torch
import multiprocessing
import warnings
import torchvision.transforms as transforms
from multiprocessing import M... | 10,600 | 29.81686 | 131 | py |
taskgrouping | taskgrouping-master/taskonomy_losses.py | import torch
import collections
sl=0
nl=0
nl2=0
nl3=0
dl=0
el=0
rl=0
kl=0
tl=0
al=0
cl=0
popular_offsets=collections.defaultdict(int)
batch_number=0
def segment_semantic_loss(output,target,mask):
global sl
sl = torch.nn.functional.cross_entropy(output.float(),target.long().squeeze(dim=1),ignore_index=0,reduct... | 6,961 | 27.650206 | 119 | py |
taskgrouping | taskgrouping-master/train_taskonomy.py | import argparse
import os
import shutil
import time
import platform
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torchvision.datasets as datasets
from taskonomy_losses import *
from taskonomy_loader import TaskonomyLoader
from apex.parallel impo... | 26,764 | 35.917241 | 160 | py |
taskgrouping | taskgrouping-master/read_training_history.py | import argparse
import os
import torch
from collections import defaultdict
from train_taskonomy import print_table
parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
parser.add_argument('--model_file', '-m', default='', type=str, metavar='PATH',
help='path to latest checkpoin... | 2,820 | 30.696629 | 83 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/replicate.py | # -*- coding: utf-8 -*-
# File : replicate.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import functools
from torch.nn.parallel.da... | 3,226 | 32.968421 | 115 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/unittest.py | # -*- coding: utf-8 -*-
# File : unittest.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import unittest
import torch
class TorchTes... | 746 | 23.9 | 59 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/batchnorm.py | # -*- coding: utf-8 -*-
# File : batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import collections
import contextlib
import... | 15,829 | 39.075949 | 116 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/batchnorm_reimpl.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : batchnorm_reimpl.py
# Author : acgtyrant
# Date : 11/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import torch
import torch.nn as nn
import torch... | 2,385 | 30.813333 | 95 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/comm.py | # -*- coding: utf-8 -*-
# File : comm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import queue
import collections
import threading... | 4,449 | 31.246377 | 117 | py |
taskgrouping | taskgrouping-master/sync_batchnorm/__init__.py | # -*- coding: utf-8 -*-
# File : __init__.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
from .batchnorm import SynchronizedBatchNorm1... | 507 | 35.285714 | 96 | py |
taskgrouping | taskgrouping-master/network_selection/make_plots.py | import plotly.graph_objects as go
import plotly.io as pio
from plotly.validators.scatter.marker import SymbolValidator
import plotly.express as px
#pio.templates.default = "plotly_dark"
# Add data
def make_plot(curves,name):
#color_list = ["#E69F00", "#56B4E9", "#009E73", "#F0E442", "#D55E00", "#0072B2", "#CC7... | 7,507 | 45.925 | 203 | py |
taskgrouping | taskgrouping-master/model_definitions/ozan_rep_fun.py | import torch.autograd
import sys
import math
from .ozan_min_norm_solvers import MinNormSolver
import statistics
class OzanRepFunction(torch.autograd.Function):
# def __init__(self,copies,noop=False):
# super(OzanRepFunction,self).__init__()
# self.copies=copies
# self.noop=noop
n=5
d... | 7,442 | 34.442857 | 155 | py |
taskgrouping | taskgrouping-master/model_definitions/xception_taskonomy_small.py | """
Creates an Xception Model as defined in:
Francois Chollet
Xception: Deep Learning with Depthwise Separable Convolutions
https://arxiv.org/pdf/1610.02357.pdf
This weights ported from the Keras implementation. Achieves the following performance on the validation set:
Loss:0.9173 Prec@1:78.892 Prec@5:94.292
REMEM... | 29,185 | 34.37697 | 317 | py |
taskgrouping | taskgrouping-master/model_definitions/resnet_taskonomy.py | import torch.nn as nn
import math
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from torch.nn import init
import torch
from .ozan_rep_fun import ozan_rep_function,trevor_rep_function,OzanRepFunction,TrevorRepFunction
#from .utils import load_state_dict_from_url
__all__ = ['resnet18_taskon... | 16,822 | 36.301552 | 154 | py |
taskgrouping | taskgrouping-master/model_definitions/__init__.py | from .xception_taskonomy_new import *
from .xception_taskonomy_joined_decoder import *
from .xception_taskonomy_small import *
from .resnet_taskonomy import *
| 160 | 25.833333 | 48 | py |
taskgrouping | taskgrouping-master/model_definitions/ozan_min_norm_solvers.py | import numpy as np
import torch
import math
class MinNormSolver:
MAX_ITER = 250
STOP_CRIT = 1e-5
def _min_norm_element_from2(v1v1, v1v2, v2v2):
"""
Analytical solution for min_{c} |cx_1 + (1-c)x_2|_2^2
d is the distance (objective) optimzed
v1v1 = <x1,x1>
v1v2 = <x... | 7,628 | 36.214634 | 147 | py |
taskgrouping | taskgrouping-master/model_definitions/xception_taskonomy_joined_decoder.py | """
Creates an Xception Model as defined in:
Francois Chollet
Xception: Deep Learning with Depthwise Separable Convolutions
https://arxiv.org/pdf/1610.02357.pdf
This weights ported from the Keras implementation. Achieves the following performance on the validation set:
Loss:0.9173 Prec@1:78.892 Prec@5:94.292
REMEM... | 13,355 | 31.183133 | 251 | py |
taskgrouping | taskgrouping-master/model_definitions/xception_taskonomy_new.py | """
"""
import math
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from torch.nn import init
import torch
from .ozan_rep_fun import ozan_rep_function,trevor_rep_function,OzanRepFunction,TrevorRepFunction
__all__ = ['xception_taskonomy_new','xception_taskonomy_new_fifth... | 14,950 | 32.979545 | 181 | py |
vae_lesion_deficit | vae_lesion_deficit-main/utils.py | import numpy as np
import random
from torch.utils.data import Dataset, DataLoader
from monai.transforms import *
def resize(volume, target_size):
resize_transform = Compose([Resize((target_size[0],
target_size[1],
target_size[2]))])
... | 4,837 | 35.104478 | 111 | py |
vae_lesion_deficit | vae_lesion_deficit-main/model.py | import math
import torch
import torch.nn as nn
import torch.distributions as D
import torch.nn.functional as F
# Define two globals
bce_fn = nn.BCELoss(reduction='none')
Tensor = torch.cuda.FloatTensor
def add_coords(x, just_coords=False):
'''
This just the Uber CoordConv method extended to 3D. Definitely u... | 13,659 | 36.322404 | 132 | py |
vae_lesion_deficit | vae_lesion_deficit-main/train.py | import numpy as np
import os
import argparse
import torch
import torch.optim as optim
import datetime
import torch as tc
from model import ModelWrapper
from utils import create_train_val_cal_loaders
Tensor = torch.cuda.FloatTensor
def count_parameters(model):
return sum(p.numel() for p in model.parameters() if... | 6,905 | 34.234694 | 107 | py |
GCNH | GCNH-main/main.py | """
Perform training and testing of GCNH on the 10 available splits
"""
import torch
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from utils import *
from datetime import datetime
from copy import deepcopy
from scipy.sparse import coo_matrix
from models import GCNH
from tqdm import tq... | 5,717 | 34.7375 | 161 | py |
GCNH | GCNH-main/utils.py | import scipy.sparse as sp
import torch
import numpy as np
import pickle as pkl
import sys
import networkx as nx
from dataset import CustomDataset
import argparse
import random
from os import path as path
"""
READ ARGUMENTS
"""
def parse_boolean(value):
"""Parse boolean values passed as argument"""
value = v... | 12,193 | 38.980328 | 127 | py |
GCNH | GCNH-main/dataset.py | """
Dataset class definition for syn-cora
ref: https://github.com/GemsLab/H2GCN
"""
import os.path as osp
import numpy as np
import scipy.sparse as sp
class Dataset():
"""Dataset class contains four citation network datasets "cora", "cora-ml", "citeseer" and "pubmed",
and one blog dataset "Polblogs". Datasets... | 9,331 | 39.398268 | 211 | py |
GCNH | GCNH-main/layers.py | """
GCNH Layer
"""
import torch
import torch.nn as nn
from torch.nn.modules.module import Module
from torch_scatter import scatter
class GCNH_layer(Module):
def __init__(self, nfeat, nhid, maxpool):
super(GCNH_layer, self).__init__()
self.nhid = nhid
self.maxpool = maxpool
... | 1,967 | 28.373134 | 84 | py |
GCNH | GCNH-main/models.py | """
Define GCNH model
"""
import torch.nn as nn
import torch.nn.functional as F
from layers import GCNH_layer
import torch
from utils import *
class GCNH(nn.Module):
def __init__(self, nfeat, nclass, nhid, dropout, nlayers, maxpool):
super(GCNH, self).__init__()
self.nhid = nhid
s... | 1,619 | 28.454545 | 109 | py |
GCNH | GCNH-main/main_syn.py | """
Perform training and testing of GCNH on the synthetic dataset
"""
import torch
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from utils import *
import os
from tqdm import tqdm
from copy import deepcopy
from models import GCNH
from scipy.sparse import coo_matrix
if __name__ == "_... | 4,675 | 36.111111 | 141 | py |
path-integrity | path-integrity-main/pi-oracle.py | #!/usr/bin/python
import re
import os
import sys
debug = True
lines = sys.stdin.readlines()
lemma = sys.argv[1]
# INPUT:
# - lines contain a list of "%i:goal" where "%i" is the index of the goal
# - lemma contain the name of the lemma under scrutiny
# OUTPUT:
# - (on stdout) a list of ordered index separated by EOL
... | 3,710 | 34.682692 | 87 | py |
merc2020 | merc2020-master/feature_extract.py | """
train code
"""
import os
import tensorflow as tf
import keras
from keras.layers import Dense, Lambda, AveragePooling1D
import numpy as np
from keras import backend as K
from keras.models import load_model, Model
os.environ["CUDA_VISIBLE_DEVICES"]='0'
def attention_pooling(model_input):
"""
attention pooli... | 2,279 | 28.230769 | 117 | py |
merc2020 | merc2020-master/train.py | """
train code
"""
import os
import tensorflow as tf
import keras
from keras.callbacks import EarlyStopping, ModelCheckpoint
from keras.layers import Dense, Conv2D, Dropout, MaxPooling2D, Input, Flatten, Lambda, AveragePooling1D, Activation, TimeDistributed, LSTM, Bidirectional, BatchNormalization
import numpy as np
fr... | 4,570 | 34.434109 | 173 | py |
merc2020 | merc2020-master/gen_dataset.py | """
generate dataset_numpy
"""
import os
import numpy as np
import librosa
import scipy
from pyvad import trim
### Pre-processing
MAX_FRAME_LENGTH = 400 # max wave length (4 sec)
STRIDE = 0.01 # STRIDE (10ms)
WINDOW_SIZE = 0.025 # filter window size (25ms)
NUM_MELS = 40 # Mel filter number
PRE_EMPHASIS... | 4,003 | 27.805755 | 123 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.