import hana_ml
import pandas as pd
conn = hana_ml.ConnectionContext(address="lsvxc0103.sjc.sap.corp", port=30315, user="PAL_USER")
data = hana_ml.dataframe.create_dataframe_from_pandas(conn, table_name="COPD_DEMO", pandas_df=pd.read_csv("COPD.csv"), force=True, drop_exist_tab=True)
data = data.rename_columns({"Unnamed: 0" : "ID", "性别" : "GENDER", "年龄" : "AGE", "身高" : "HEIGHT", "体重": "WEIGHT", "糖尿病" : "DIABETES", "高血压": "HYPERTENSION", "住院史" : "HOSPITALIZATION", "长期接触粉尘" : "LONG DUST EXPOSURE" })
data.head(3).collect()
data
via dataset_report.from hana_ml.visualizers.dataset_report import DatasetReportBuilder
datasetReportBuilder = DatasetReportBuilder()
datasetReportBuilder.build(data, key="ID")
datasetReportBuilder.generate_notebook_iframe_report()
from hana_ml.algorithms.pal import metrics
from hana_ml.algorithms.pal.unified_classification import UnifiedClassification, json2tab_for_reason_code
from hana_ml.algorithms.pal.model_selection import RandomSearchCV
uc_hgbt = UnifiedClassification(func='hybridgradientboostingtree')
rscv = RandomSearchCV(estimator=uc_hgbt,
param_grid={
"split_threshold":[1e-5, 1e-7],
"learning_rate":[0.1, 0.01, 0.5],
"n_estimators":[6, 10],
"max_depth":[10, 12]},
train_control={"fold_num":5, "resampling_method": "cv", "random_search_times":3},
scoring="auc"
)
rscv.fit(data=data,
key= 'ID',
label='COPD',
partition_method='stratified',
stratified_column='COPD',
partition_random_state=2,
training_percent=0.7,
ntiles=2)
uc_hgbt.generate_notebook_iframe_report()
pred = pd.DataFrame({"ID": [1],
"GENDER": ['M'],
"AGE": [60],
"HEIGHT": [160],
"WEIGHT": [100],
"DIABETES": ['Y'],
"HYPERTENSION": ['N'],
"HOSPITALIZATION": [12],
"LONG DUST EXPOSURE": ['Y']})
pred_data = hana_ml.dataframe.create_dataframe_from_pandas(conn, table_name="COPD_DEMO_PRED", pandas_df=pred, force=True)
pred_res = uc_hgbt.predict(pred_data, key='ID')
pred_res.collect()
json2tab_for_reason_code(pred_res).collect()
Outlier Detection using Statistical Tests in Python Machine Learning Client for SAP HANA
Outlier Detection by Clustering using Python Machine Learning Client for SAP HANA
Outlier Detection with One-class Classification using Python Machine Learning Client for SAP HANA
Additive Model Time-series Analysis using Python Machine Learning Client for SAP HANA
Weibull Analysis using Python machine learning client for SAP HANA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |