Skip to main content

Library/framework for making predictions.

Project description

mydatapreprocessing

PyPI pyversions PyPI version Language grade: Python Build Status Documentation Status License: MIT codecov

Load data from web link or local file (json, csv, excel file, parquet, h5...), consolidate it and do preprocessing like resampling, standardization, string embedding, new columns derivation, feature extraction etc. based on configuration.

Library contain 3 modules.

Preprocessing

First - preprocessing load data, consolidate it and do the preprocessing. It contains functions like load_data, data_consolidation, preprocess_data, preprocess_data_inverse, add_frequency_columns, rolling_windows, add_derived_columns etc.

Example

### Preprocessing module

import mydatapreprocessing.preprocessing as mdpp

data = "https://blockchain.info/unconfirmed-transactions?format=json"

# Load data from file or URL
data_loaded = mdpp.load_data(data, request_datatype_suffix=".json", predicted_table='txs')


#Some examples of other inputs to data_load function

# myarray_or_dataframe # Numpy array or Pandas.DataFrame
# r"/home/user/my.json" # Local file. The same with .parquet, .h5, .json or .xlsx. On windows it's necessary to use raw string - 'r' in front of string because of escape symbols \
# "https://yoururl/your.csv" # Web url (with suffix). Same with json.
# "https://blockchain.info/unconfirmed-transactions?format=json" # In this case you have to specify also 'request_datatype_suffix': "json", 'data_orientation': "index", 'predicted_table': 'txs',
# {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']} # Dict with colums or rows (index) - necessary to setup data_orientation!


# You can use more files in list and data will be concatenated. It can be list of paths or list of python objects. Example:

# [{'col_1': 3, 'col_2': 'a'}, {'col_1': 0, 'col_2': 'd'}]  # List of records
# [np.random.randn(20, 3), np.random.randn(25, 3)]  # Dataframe same way
# ["https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv", "https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv"]  # List of URLs
# ["path/to/my1.csv", "path/to/my1.csv"]


# Transform various data into defined format - pandas dataframe - convert to numeric if possible, keep
# only numeric data and resample ifg configured. It return array, dataframe
data_consolidated = mdpp.data_consolidation(
    data_loaded, predicted_column="weight", data_orientation="index", remove_nans_threshold=0.9, remove_nans_or_replace='interpolate')

# You can add some extra informations to the data that can help (beware it can slow down the machine learning model)
to_be_extended = np.array([[0, 2] * 64, [0, 0, 0, 5] * 32]).T
extended = mdpp.add_frequency_columns(to_be_extended, window=8)


to_be_extended2 = pd.DataFrame([range(30), range(30, 60)]).T
extended2 = mdpp.add_derived_columns(to_be_extended2, differences=True, second_differences=True, multiplications=True,
                                    rolling_means=True, rolling_stds=True, mean_distances=True, window=10)

# Feature extraction is under development  :[

# Preprocess data. It return preprocessed data, but also last undifferenced value and scaler for inverse
# transformation, so unpack it with _
data_preprocessed, _, _ = mdpp.preprocess_data(data_consolidated, remove_outliers=True, smoothit=False,
                                              correlation_threshold=False, data_transform=False, standardizeit='standardize')

Inputs

Second module is inputs. It take tabular time series data and put it into format (input vector X, output vector y and input for predicted value x_input) that can be inserted into machine learning models for example on sklearn or tensorflow. It contain functions make_sequences, create_inputs and create_tests_outputs

Example

import mydatapreprocessing.inputs as mdpi

data = np.array([[1, 3, 5, 2, 3, 4, 5, 66, 3]]).T
seqs, Y, x_input, test_inputs = mdpi.inputs.make_sequences(data, predicts=7, repeatit=3, n_steps_in=6, n_steps_out=1, constant=1)

Third module is generatedata. It generate some basic data like sin, ramp random. In the future, it will also import some real datasets for models KPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mydatapreprocessing-1.1.15.tar.gz (22.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mydatapreprocessing-1.1.15-py3.7.egg (49.1 kB view details)

Uploaded Egg

mydatapreprocessing-1.1.15-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file mydatapreprocessing-1.1.15.tar.gz.

File metadata

  • Download URL: mydatapreprocessing-1.1.15.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.1

File hashes

Hashes for mydatapreprocessing-1.1.15.tar.gz
Algorithm Hash digest
SHA256 c6aa5e2329650870321e59d1267e5ae436bc393e07115f8d30fdd388bd7cba8e
MD5 d6112852e7889fe27dfa98015f2f21db
BLAKE2b-256 906a65e4cc3969582a86cb1b07a53b032e35c980fcf45d3e6864c3c91f34c564

See more details on using hashes here.

File details

Details for the file mydatapreprocessing-1.1.15-py3.7.egg.

File metadata

  • Download URL: mydatapreprocessing-1.1.15-py3.7.egg
  • Upload date:
  • Size: 49.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.1

File hashes

Hashes for mydatapreprocessing-1.1.15-py3.7.egg
Algorithm Hash digest
SHA256 6714aff9b7a79a533937e5c4e77b55fbf3f8d207590c9dce27f6890fd27f3ccf
MD5 369eddc93ad9923b04bf9990a8d968c4
BLAKE2b-256 219645f25c9f44ea8d093b5ac9eb3e7ba1fea407a5f6b7481d1c0828c1f81ed9

See more details on using hashes here.

File details

Details for the file mydatapreprocessing-1.1.15-py3-none-any.whl.

File metadata

  • Download URL: mydatapreprocessing-1.1.15-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.1

File hashes

Hashes for mydatapreprocessing-1.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 ab7259f54073abeddba4b47f661dbb6039a6bfe6f6fbdb15b0454f250d843711
MD5 fdd3a78d5cd5c73f0ba6fe26009a20ff
BLAKE2b-256 9b315ace5d6c604315102c9be5e1ff7abb0d70962c3c67c7bf84b8ace12a544c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page