This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import KBinsDiscretizer | |
from sklearn.model_selection import RandomizedSearchCV | |
search_space = { | |
'preprocessing__binfeatures__n_bins': [10, 20], | |
'model__n_estimators': [500, 1000, 2000], | |
'model__class_weight': ['balanced', 'balanced_subsample'] | |
} | |
preprocessing = ColumnTransformer(transformers=[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Persist pipeline to disk | |
pipeline.fit(x_train, y_train) | |
joblib.dump(pipeline, 'model.joblib') | |
# Load pipeline and make prediction | |
pipeline = joblib.load('model.joblib') | |
y_hat = pipeline.predict(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.compose import ColumnTransformer | |
# Define you transformers. | |
preprocessing = ColumnTransformer(transformers=[ | |
('encode_categorical_features', OneHotEncoder(), ['categorical_column']) | |
], remainder='passthrough') | |
estimator = GradientBoostingClassifier() | |
# Define steps in the pipeline. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import OneHotEncoder | |
encoder = OneHotEncoder() | |
dummies = encoder.fit_transform(df['categorical_column']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You have you set of possible categories in a list for example. | |
# (it could be anything really...) | |
possible_categories = ['foo', 'bar] | |
# Convert the categorical column to type Categorical | |
df['categorical_column'] = pd.Categorical( | |
values=df['categorical_column'], | |
categories=possible_categories | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
dummies = pd.get_dummies(df, columns=['categorical_colum1', 'categorical_colum2']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dummies = pd.get_dummies(df['categorical_column']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws cloudformation deploy / | |
--template-file cloudformation_notebook.yaml / | |
--stack-name notebook-tutorial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: 'Cloudformation simples para subir um notebook no Sagemaker' | |
Resources: | |
NotebookTutorial: | |
Type: AWS::SageMaker::NotebookInstance | |
Properties: | |
NotebookInstanceName: "Notebook Tutorial" | |
InstanceType: ml.t2.medium | |
RoleArn: String | |
VolumeSizeInGB: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select tab.table_schema, | |
tab.table_name, | |
tinf.tbl_rows as rows | |
from svv_tables tab | |
join svv_table_info tinf | |
on tab.table_schema = tinf.schema | |
and tab.table_name = tinf.table | |
where tab.table_type = 'BASE TABLE' | |
and tab.table_schema not in('pg_catalog','information_schema') | |
and tinf.tbl_rows > 1 |
NewerOlder