当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.add_col方法代码示例

本文整理汇总了Python中pipeline.Pipeline.add_col方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.add_col方法的具体用法?Python Pipeline.add_col怎么用?Python Pipeline.add_col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pipeline.Pipeline的用法示例。


在下文中一共展示了Pipeline.add_col方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Pipeline

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import add_col [as 别名]
import build
import pandas as pd
from pipeline import Pipeline

PATH = 'cs-training.csv'
TEST = explore.snake_columns(pd.read_csv('cs-test.csv', index_col=0))
my_pipeline = Pipeline(PATH, TEST)

# explore
print('exploring')
my_pipeline.explore()

# add features
print('adding features')
#my_pipeline.add_col('monthly_income')
my_pipeline.add_col('age', transform_type='squared')
my_pipeline.create_binary('number_of_dependents')
my_pipeline.split('serious_dlqin2yrs')

# process
print('processing')
my_pipeline.impute('number_of_dependents', method='mode')
my_pipeline.impute('monthly_income', method='median')

my_pipeline.export_train_tocsv()

# build models
#['KNN','RF','LR','ET','AB','GB','NB','DT']
models=['KNN','DT','NB','LR']
#get X and y
print('building models')
开发者ID:cszc,项目名称:Machine-Learning-for-Public-Policy,代码行数:33,代码来源:assignment3_pipeline.py

示例2: Pipeline

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import add_col [as 别名]
import build
import pandas as pd
from pipeline import Pipeline

PATH = 'cs-training.csv'
TEST = explore.snake_columns(pd.read_csv('cs-test.csv', index_col=0))
my_pipeline = Pipeline(PATH, TEST)

# explore
print('exploring')
my_pipeline.explore()

# process
print('processing')
my_pipeline.impute('number_of_dependents', method='mode')
my_pipeline.impute('monthly_income', method='mean')

# add features
print('adding features')
my_pipeline.add_col('monthly_income')
my_pipeline.add_col('age', transform_type='squared')
my_pipeline.create_binary('number_of_dependents')
my_pipeline.split('serious_dlqin2yrs')
my_pipeline.export_train_tocsv()

# build models
print('building models')
my_pipeline.build('logistic')
my_pipeline.build('knn')
print(my_pipeline.models)
开发者ID:cszc,项目名称:Machine-Learning-for-Public-Policy,代码行数:32,代码来源:assignment2_pipeline.py


注:本文中的pipeline.Pipeline.add_col方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。