Exemplo n.º 1
0
 def __init__(self, k=10, n=100, m=50):
     Data.__init__(self)
     self.k = k
     self.m = m
     self.means = rnd.uniform(mean_low, mean_high, (self.k, self.m))
     self.divs = rnd.uniform(div_low, div_high, (self.k, self.m))
     self.data, self.labels = self.generate_data(n)
Exemplo n.º 2
0
    def __init__2(self):
        import numpy as np
        iris = load_iris()

        feature_vector = iris.data.tolist()
        new_column1 = (len(feature_vector) /
                       2) * ["a"] + (len(feature_vector) / 2) * ["b"]
        new_column2 = (len(feature_vector) /
                       2) * ["c"] + (len(feature_vector) / 2) * ["d"]

        feature_vector = [[new_column2[i]] + feature_vector[i] +
                          [new_column1[i]] for i in range(len(feature_vector))]
        feature_vector = np.array(feature_vector, dtype=object)

        target_vector = [iris.target_names[i] for i in iris.target]

        feature_names = iris.feature_names
        feature_names.append("test")
        feature_names.append("test2")

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="Iris")
Exemplo n.º 3
0
    def __init__(self, headers, pdata, evals, evecs, means, filename=None):
        Data.__init__(self)
        self.eigenValues = evals
        self.eigenVectors = evecs
        self.dataMeans = means
        self.dataHeaders = headers
        self.matrix_data = pdata

        # add to raw_headers and raw data types
        for idx in range(len(headers)):
            if idx > 9:
                self.raw_headers.append("P%d" % (idx))
            else:
                self.raw_headers.append("P0%d" % (idx))
            self.raw_types.append("numeric")


# 		print self.raw_headers
# add a numpy array to raw_data
        self.raw_data = np.squeeze(np.asarray(pdata))

        # add to header2raw and header2matrix
        for index in range(len(self.raw_headers)):
            self.header2raw[self.raw_headers[index]] = index
            self.header2matrix[self.raw_headers[index]] = index
Exemplo n.º 4
0
 def __init__(self, ogDataHeaders, projectedData, eigenValues, eigenVectors, ogDataMeans):
     Data.__init__(self)
     self.eigenValues = eigenValues
     self.eigenVectors = eigenVectors
     self.meanDataValues = ogDataMeans
     self.projectedHeaders = ogDataHeaders
     self.matrix = projectedData
     self.rawHeaders = ["P"+`i` for i in range(len(ogDataHeaders))]
Exemplo n.º 5
0
    def __init__(self):
        wine = load_wine()

        feature_vector = wine.data
        target_vector = [wine.target_names[i] for i in wine.target]

        feature_names = wine.feature_names

        Data.__init__(self, feature_vector, target_vector, feature_names, name="Wine")
Exemplo n.º 6
0
    def __init__(self, projected_data, eigenvectors, eigenvalues,
                 original_means, data_headers):

        Data.__init__(self)
        self.data = projected_data
        self.eigenvalues = eigenvalues
        self.eigenvectors = eigenvectors
        self.original_means = original_means
        self.original_headers = data_headers
        self.organize_stuff()
Exemplo n.º 7
0
    def __init__(self, args):
        self.args = args
        Data.__init__(self, self.args.input_file)

        self.population = []
        for _ in range(self.args.population_size):
            self.population.append(Individual(self.items, self.args))
        self.elite = Elite(self.args, list(self.items.keys()), self.population)
        self.registry = Registry(self.elite)
        self.runEvolutive()
Exemplo n.º 8
0
 def __init__(self, m_file, **kwargs):
     self.surface = None
     Data.__init__(self, m_file, **kwargs)
     self.container = gwy.gwy_file_load(self.m_file, gwy.RUN_NONINTERACTIVE)
     gwy.gwy_app_data_browser_add(self.container)
     self.channel_id = gwy.gwy_app_data_browser_find_data_by_title(
         self.container, "*SE*"
     )[0]
     gwy.gwy_app_data_browser_select_data_field(self.container, self.channel_id)
     self.extract_meta(gwyddion.get_meta_ids(self.container)[0])
Exemplo n.º 9
0
 def __init__(self, m_file, **kwargs):
     self.electrolyte = None
     self.gas = None
     self.surface = None
     self.ph = None
     self.re = ""
     self.ce = None
     self.we = None
     self.ecell = None
     self.icell = None
     Data.__init__(self, m_file, **kwargs)
Exemplo n.º 10
0
    def __init__(self, data, headers, codebooks, codes, errors):

        Data.__init__(self)
        self.data = data
        self.headers = headers
        self.codebooks = codebooks
        self.codes = codes
        self.errors = errors
        self.k = self.codebooks.shape[0]
        self.N = self.codes.shape[0]
        self.organize_stuff()
Exemplo n.º 11
0
    def __init__(self):
        cancer = load_breast_cancer()

        feature_vector = cancer.data
        target_vector = [cancer.target_names[i] for i in cancer.target]

        feature_names = cancer.feature_names

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="BreastCancer")
Exemplo n.º 12
0
    def __init__(self):
        iris = load_iris()

        feature_vector = iris.data
        target_vector = [iris.target_names[i] for i in iris.target]

        feature_names = iris.feature_names

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="Iris")
Exemplo n.º 13
0
    def __init__(self):
        # Read data from file
        df = pd.read_csv("../data/bank_note/data_banknote_authentication.csv", header=None)

        # Add all columns as feature vector expect the target column
        feature_vector = df.iloc[:, :-1].values

        target_vector = df.iloc[:, -1].values

        # Set the column names as the feature names
        feature_names = ["variance of WTI", "skewness of WTI", "curtosis of Wavelet", "entropy of image"]

        Data.__init__(self, feature_vector, target_vector, feature_names, name="BankNote")
Exemplo n.º 14
0
    def __init__(self):
        feature_names = [
            "Age", "Workclass", "fnlwgt", "Education", "Education-Num",
            "Marital Status", "Occupation", "Relationship", "Race", "Sex",
            "Capital Gain", "Capital Loss", "Hours per week", "Country"
        ]

        data = pd.read_csv('../data/adult/adult.data',
                           na_values="NA",
                           names=feature_names + ["Salary"],
                           header=None).values
        labels = data[:, 14]

        Data.__init__(self, data[:, :-1], labels, feature_names, name="Adult")
Exemplo n.º 15
0
    def __init__(self, path):
        # Read data from file
        df = pd.read_csv(path)

        # Add all columns as feature vector expect the target vector
        feature_vector = df.iloc[:, 0:-1].values

        # Get the last column as target vector
        target_vector = df.iloc[:, -1].values

        # Set the column names as the feature names
        feature_names = list(df)[:-1]

        Data.__init__(self, feature_vector, target_vector, feature_names)
Exemplo n.º 16
0
    def __init__(self):
        print("Loading digits dataset!!!")
        digits_data = load_digits()

        feature_vector = digits_data.images.reshape(1797, 64)
        target_vector = digits_data.target

        feature_names = map(lambda index: str((index / 8, index % 8)),
                            range(64))

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="Digits")
        print("\tDone!!")
Exemplo n.º 17
0
Arquivo: FX.py Projeto: zmasz/ltp-bot
	def __init__(self,base,quote):
		self.base = base
		self.quote = quote
		self.pair = self.base + '_' + self.quote
		self.price = Poloniex.getPrice(self,self.pair)

		Data.__init__(self)
		Charter.__init__(self)
		#Backtester.__init__(self)


#xmr = FX("BTC","XMR")
#xmr.saveChartData()


#xmr.chartCandles('7D')
#xmr.showChart()
Exemplo n.º 18
0
    def __init__(self):
        # Read data from file
        original_df = pd.read_csv("../data/housing/train.csv")

        # Get the target vector
        # Make the sale price discrete as ["low", "medium", "high"]
        target_vector = self.split(original_df["SalePrice"].values)
        df = original_df.drop(columns=["SalePrice"])

        # Convert null values to string "NA"
        df.fillna("NA", inplace=True)

        # Merge two columns
        df["Bathroom Amount"] = df["BsmtFullBath"] + df["FullBath"]
        df["Toilet Amount"] = df["BsmtHalfBath"] + df["HalfBath"]

        # Remove not needed columns
        df.drop(columns=not_used_columns, inplace=True)

        # Change values of the columns to make them more readable
        for column_name in useful_categorical_columns.keys():
            df[column_name] = df[column_name].map(
                categorical_values[column_name])
        for column_name in categorical_to_numerical.keys():
            df[column_name] = df[column_name].map(
                categorical_to_numerical[column_name])

        # Convert to numerical values to int
        df[useful_numerical_columns.keys() +
           new_columns] = df[useful_numerical_columns.keys() +
                             new_columns].astype(int)

        # Change column names to make them more readable
        df.rename(columns=useful_numerical_columns, inplace=True)
        df.rename(columns=useful_categorical_columns, inplace=True)

        feature_vector = df.values

        # Set the column names as the feature names
        feature_names = list(df)

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="Housing")
Exemplo n.º 19
0
 def __init__(self, m_file, **kwargs):
     self.surface = None
     self.tip = None
     Data.__init__(self, m_file, **kwargs)
     self.set_settings()
     self.container = gwy.gwy_file_load(self.m_file, gwy.RUN_NONINTERACTIVE)
     gwy.gwy_app_data_browser_add(self.container)
     self.img_topo_fwd = None
     self.img_topo_bwd = None
     self.topo_fwd_ch = self.return_topo_fwd_ch()
     self.topo_bwd_ch = self.return_topo_bwd_ch()
     self.size = None
     self.rotation = None
     self.line_time = None
     self.bias = None
     self.current = None
     self.xoffset = None
     self.yoffset = None
     self.scan_duration = None
     self.extract_meta(gwyddion.get_meta_ids(self.container)[0])
Exemplo n.º 20
0
    def __init__(self):
        # Read data from file
        df = pd.read_csv("../data/abalone/abalone.data", header=None)

        # Add all columns as feature vector expect the age and sex
        feature_vector = df.iloc[:, 1:-1].values

        # Make the sale price discrete as ["young","old"]
        target_vector = self.split(df.iloc[:, -1].values)

        # Set the column names as the feature names
        feature_names = [
            "length", "diameter", "height", "whole weight", "shucked weight",
            "viscera weight", "shell weight"
        ]

        Data.__init__(self,
                      feature_vector,
                      target_vector,
                      feature_names,
                      name="Abalone")
Exemplo n.º 21
0
	def __init__(self, args):
		logging.info('==================> Started Stamp-Finder <==================')
		Data.__init__(self, args)

		# See if a quick run is wanted.
		if not self.quick:
			Q = raw_input('\nDo you want to skip Hashing for faster run? [yN] ')
			if Q == ('y' or 'Y'):
				self.quick = True

		self.create_files()

		if not self.quick:
			self.Main_hash()

		self.sfinder()

		if not self.quick:
			self.Main_hash(final=True)

		return
Exemplo n.º 22
0
    def __init__(self, filename, varname, levellist=None, **kwargs):
        """
        Data4D class

        This class implements the functionality to generate Data4D objekt.


        EXAMPLES
        ========

        """
        self.levellist = {}

        if not levellist is None:
            level = 0
            for k in levellist:
                self.levellist[int(k)] = level
                level += 1

        self.data4D = []

        Data.__init__(self, filename, varname, **kwargs)
        self.mulc(self.scale_factor, copy=False)
Exemplo n.º 23
0
    def __init__(self, filename, varname, levellist=None, **kwargs):
        """
        Data4D class

        This class implements the functionality to generate Data4D objekt.


        EXAMPLES
        ========

        """
        self.levellist = {}

        if not levellist is None:
            level = 0
            for k in levellist:
                self.levellist[int(k)] = level
                level += 1

        self.data4D = []

        Data.__init__(self, filename, varname, **kwargs)
        self.mulc(self.scale_factor, copy=False)
Exemplo n.º 24
0
    def __init__(self, args):
        logging.info(
            '==================> Started Stamp-Finder <==================')
        Data.__init__(self, args)

        # See if a quick run is wanted.
        if not self.quick:
            Q = raw_input(
                '\nDo you want to skip Hashing for faster run? [yN] ')
            if Q == ('y' or 'Y'):
                self.quick = True

        self.create_files()

        if not self.quick:
            self.Main_hash()

        self.sfinder()

        if not self.quick:
            self.Main_hash(final=True)

        return
Exemplo n.º 25
0
    def __init__(self):
        basedir = "../data/"
        feature_names = [
            "weight", "food_time", "food_cho", "a1_start", "a1_duration_hrs",
            "a1_hrs_after_food", "a1_end", "a2_start", "a2_duration_hrs",
            "a2_hrs_after_food", "a2_end", "before_food_hyper",
            "before_food_hypo", "patient_adolescent", "patient_adult",
            "patient_child", "food_name_apple", "food_name_banana",
            "food_name_bread_milk", "food_name_cookie",
            "food_name_french_fries", "food_name_hamburger_meal",
            "food_name_juice_nuts", "food_name_milk_crackers",
            "food_name_peach", "food_name_rice_beans",
            "food_name_strawberries", "food_name_watermelon", "food_type_meal",
            "food_type_snack", "a1_type_0", "a1_type_activity",
            "a1_type_sports", "a1_name_0", "a1_name_bicycling_16kph",
            "a1_name_chores", "a1_name_dancing", "a1_name_mopping",
            "a1_name_mountain_climbing", "a1_name_running", "a1_name_swimming",
            "a1_name_walking", "a2_type_0", "a2_type_activity",
            "a2_type_sports", "a2_name_0", "a2_name_dancing",
            "a2_name_skating", "a2_name_walking"
        ]
        # list(genfromtxt(basedir + 'diabetes_model_feature_names.csv', delimiter=';'))

        data = genfromtxt(basedir + 'diabetes_model_x_train.csv',
                          delimiter=';')
        labels = genfromtxt(basedir + 'diabetes_model_y_train.csv',
                            delimiter=';')
        label_names = ['hyper', 'hypo', 'ok']
        labels = [label_names[np.argmax(v)] for v in labels]

        # data = pd.read_csv('../data/diabetes_model_x_train.csv', na_values="NA", names=feature_names,
        #                    header=None).values
        # labels = pd.read_csv('../data/diabetes_model_x_train.csv', na_values="NA", names=['label'],
        #                      header=None).values

        Data.__init__(self, data, labels, feature_names, name="Diabetes")
Exemplo n.º 26
0
 def __init__(self, name=None, description='', kind=None, **kwargs):
     Data.__init__(self, name=name, description=description, type=kind)
     return
Exemplo n.º 27
0
	def __init__(self, username, password, url, description):
		self.username = username
		self.password = password
		self.url = url

		Data.__init__(self, description)
    def __init__(self, path_to_data):

        start_epoch = 0  # seconds
        end_epoch = 1.25  # seconds
        sample_rate = 200
        Data.__init__(self, path_to_data, start_epoch, end_epoch, sample_rate)
Exemplo n.º 29
0
 def __init__(self, name=None, description='', kind=None, **kwargs):
     Data.__init__(self, name=name, description=description, type=kind)
     return
Exemplo n.º 30
0
 def __init__(self, m_file, **kwargs):
     Data.__init__(self, m_file, **kwargs)
Exemplo n.º 31
0
 def __init__(self, ratings=RATINGS, entity_names=MOVIE_NAMES, debug=False, load_previous=False):
     Data.__init__(self, ratings=ratings, entity_names=entity_names, debug=debug, load_previous=load_previous)
Exemplo n.º 32
0
 def __init__(self, dataset,features):
     Data.__init__(self)
     self.features = features
     self.dataset = dataset
     self._compute_features_dataset(dataset)
Exemplo n.º 33
0
 def __init__(self, x, y, test_ratio=0.1, val_ratio=0.0, k_fold=0, shuffle=True, threshold=0):
     Data.__init__(self, x, y, test_ratio, val_ratio, k_fold, shuffle)
     self.threshold = threshold
     self.vocabulary = {self.UNDEF_WORD: 0}
     self.preprocess()