Metadata-Version: 2.1
Name: predictnow-client
Version: 0.0.9
Summary: A restful client library, designed to access predictnow restful api.
Home-page: UNKNOWN
Author: Radu Ciobanu
Author-email: radu@predictnow.ai
License: BSD
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: Flask (==1.1.2)
Requires-Dist: gunicorn (==20.0.4)
Requires-Dist: pandas (==1.1.3)
Requires-Dist: honeycomb-beeline (==2.13.1)
Requires-Dist: libhoney (==1.10.0)
Requires-Dist: lightgbm (==2.3.0)
Requires-Dist: pyfcm (==1.4.7)
Requires-Dist: ray (==1.0.0)
Requires-Dist: shap (==0.33.0)
Requires-Dist: PyJWT (==1.7.1)
Requires-Dist: flask-login (==0.5.0)
Requires-Dist: flask-mail (==0.9.1)
Requires-Dist: matplotlib (==3.3.2)
Requires-Dist: email-validator (==1.1.2)
Requires-Dist: paypalrestsdk (==1.13.1)
Requires-Dist: xlrd (==1.2.0)
Requires-Dist: redis (==3.4.1)
Requires-Dist: future (==0.18.2)
Requires-Dist: Flask-Bootstrap4 (==4.0.2)
Requires-Dist: firebase-admin (==4.4.0)
Requires-Dist: wtforms (==2.3.3)
Requires-Dist: numpy (==1.19.2)
Requires-Dist: joblib (==0.17.0)
Requires-Dist: werkzeug (==1.0.1)
Requires-Dist: statsmodels (==0.12.0)
Requires-Dist: tqdm (==4.50.2)
Requires-Dist: scikit-learn (==0.23.2)
Requires-Dist: requests (==2.24.0)
Requires-Dist: setuptools (==50.3.0)
Requires-Dist: jinja2 (==2.11.2)
Requires-Dist: stripe (==2.55.1)
Requires-Dist: jsons (==1.3.0)
Requires-Dist: pyarrow (==2.0.0)
Requires-Dist: openpyxl (==3.0.5)

Usage:
=================================

from predictnow.pdapi import PredictNowClient
import pandas as pd
api_key = "%KeyProvidedToEachOfOurSubscriber"  

api_host = "http://%VMIP%"  # current makeshift api host
username = "helloWorld"
email = "helloWorld@yourmail.com"

client = PredictNowClient(api_host,api_key)

 # You will need to edit this input dataset file path and labelname!

file_path = 'my_amazing_features.xlsx'
labelname = 'Next_day_strategy_return'
import os


  # For classification problems

params = {'timeseries': 'yes', 'type': 'classification',  'feature_selection': 'shap', 'analysis': 'none', 'boost': 'gbdt',  'testsize': '0.2', 'weights': 'no', 'eda': 'yes', 'prob_calib': 'no', 'mode': 'train'}

  # For regression problems, suitable for CPO

params = {'timeseries': 'yes', 'type': 'regression',   'feature_selection': 'none', 'analysis': 'none', 'boost': 'gbdt', 'testsize': '0.2', 'weights': 'no', 'eda': 'yes', 'prob_calib': 'no', 'mode': 'train'}

response = client.create_model( username=username,
    model_name="test1",
    params=params
  )





from pandas import read_excel
df = read_excel(file_path, engine="openpyxl")  # Same here
df.name = "testdataframe"  # Optional, but recommended

########## TRAIN MODE ###################################
response = client.train(
	model_name="test1",
	input_df=df,
	label=labelname,
	username=username,
	email=email)


status = client.getstatus(
        username=username,
    train_id=response["train_id"]
)


if status["state"] == "COMPLETED":

	response = client.getresult(
	model_name="test1",
	username=username,
	)
	predicted_targets_cv = pd.read_json(response.predicted_targets_cv)
	print("predicted_targets_cv")
	print(predicted_targets_cv)

	predicted_targets_test = pd.read_json(response.predicted_targets_test)
	print("predicted_targets_test")
	print(predicted_targets_test)

	if response.feature_importance:
		feature_importance = pd.read_json(response.feature_importance)
		print("feature_importance")
		print(feature_importance)


	performance_metrics = pd.read_json(response.performance_metrics)
	print("performance_metrics")
	print(performance_metrics)

########## LIVE MODE ###################################
if status["state"] == "COMPLETED":
	df = read_csv("example_input_live.csv") # live input data
	df.name = "myfirstpredictname"  # optional, but recommended
      # Making live predictions
	response = client.predict(
	model_name="test1",
	input_df=df,username=username,
	eda="yes",
	prob_calib=params["prob_calib"],
	)
	y_pred = pd.read_json(response.labels)
	print("THE LABELS")
	print(y_pred)


