一款令人愉悦的机器学习工具,允许您在不编写代码的情况下训练、测试和使用模型
项目描述
一款令人愉悦的机器学习工具,允许您在不编写代码的情况下训练/拟合、测试和使用模型
免费软件:MIT许可证
介绍
项目的目标是提供面向所有人的机器学习,包括技术用户和非技术用户。
有时我需要一个工具,我可以使用它来快速创建机器学习原型。无论是构建一些概念验证,创建快速草稿模型以证明某事,还是使用自动机器学习。我发现自己经常陷入编写样板代码和思考从哪里开始的困境。因此,我决定创建这个工具。
igel 是建立在其他机器学习框架之上的。它提供了一种简单的方法来使用机器学习,无需编写任何 代码行。Igel 可以 高度自定义,但仅在你想要的情况下。Igel 不会强迫你进行自定义。除了默认值之外,igel 还可以使用自动机器学习功能来找到适合你数据的模型。
你只需要一个 yaml(或 json)文件,你需要描述你想要做什么。就是这样!
Igel 支持 回归、分类和聚类。Igel 支持 自动机器学习功能,如 图像分类和文本分类。
Igel 支持数据科学领域中使用的多数数据集类型。例如,你的输入数据集可以是 csv、txt、Excel 表格、json 或甚至你想要抓取的 html 文件。如果你在使用自动机器学习功能,你甚至可以将原始数据馈送到 igel,它将找出如何处理它。更多示例将在后面介绍。
功能
支持大多数数据集类型(csv、txt、excel、json、html),甚至只是存储在文件夹中的原始数据。
支持所有最先进的机器学习模型(包括预览模型)。
支持不同的数据预处理方法。
在编写配置时提供灵活性和数据控制。
支持交叉验证。
支持超参数搜索(版本 >= 0.2.8)。
支持 yaml 和 json 格式。
从 GUI 使用。
支持回归、分类和聚类的不同 sklearn 度量标准。
支持多输出/多目标回归和分类。
支持多进程进行并行模型构建。
支持 自动机器学习。
安装
最简单的方法是使用 pip 安装 igel。
$ pip install -U igel
模型
Igel 支持的模型。
+--------------------+----------------------------+-------------------------+
| regression | classification | clustering |
+--------------------+----------------------------+-------------------------+
| LinearRegression | LogisticRegression | KMeans |
| Lasso | Ridge | AffinityPropagation |
| LassoLars | DecisionTree | Birch |
| BayesianRegression | ExtraTree | AgglomerativeClustering |
| HuberRegression | RandomForest | FeatureAgglomeration |
| Ridge | ExtraTrees | DBSCAN |
| PoissonRegression | SVM | MiniBatchKMeans |
| ARDRegression | LinearSVM | SpectralBiclustering |
| TweedieRegression | NuSVM | SpectralCoclustering |
| TheilSenRegression | NearestNeighbor | SpectralClustering |
| GammaRegression | NeuralNetwork | MeanShift |
| RANSACRegression | PassiveAgressiveClassifier | OPTICS |
| DecisionTree | Perceptron | KMedoids |
| ExtraTree | BernoulliRBM | ---- |
| RandomForest | BoltzmannMachine | ---- |
| ExtraTrees | CalibratedClassifier | ---- |
| SVM | Adaboost | ---- |
| LinearSVM | Bagging | ---- |
| NuSVM | GradientBoosting | ---- |
| NearestNeighbor | BernoulliNaiveBayes | ---- |
| NeuralNetwork | CategoricalNaiveBayes | ---- |
| ElasticNet | ComplementNaiveBayes | ---- |
| BernoulliRBM | GaussianNaiveBayes | ---- |
| BoltzmannMachine | MultinomialNaiveBayes | ---- |
| Adaboost | ---- | ---- |
| Bagging | ---- | ---- |
| GradientBoosting | ---- | ---- |
+--------------------+----------------------------+-------------------------+
对于自动机器学习。
图像分类器。
文本分类器。
图像回归器。
文本回归器。
结构化数据分类器。
结构化数据回归器。
自动模型。
快速入门
help 命令非常有用,可以检查支持的命令及其相应的参数/选项。
$ igel --help
你还可以对子命令运行 help,例如
$ igel fit --help
Igel 可以高度自定义。如果你知道你想要什么并且想要手动配置你的模型,那么请查看下一节,它将指导你如何编写 yaml 或 json 配置文件。然后,你只需告诉 igel 要做什么以及在哪里找到你的数据和配置文件。以下是一个示例
$ igel fit --data_path 'path_to_your_csv_dataset.csv' --yaml_path 'path_to_your_yaml_file.yaml'
但是,你还可以使用自动机器学习功能,让 igel 为你做所有的事情。一个很好的例子是图像分类。让我们想象你已经有一个名为 images 的文件夹中存储的原始图像数据集。
你只需要做的是运行
$ igel auto-train --data_path 'path_to_your_images_folder' --task ImageClassification
就这样!Igel 将从目录中读取图像,处理数据集(转换为矩阵、缩放、分割等)并开始训练/优化一个适用于你数据的模型。正如你所见,这很简单,你只需要提供你数据的路径和你要执行的任务。
使用
你可以运行 help 命令获取说明。你还可以运行子命令的帮助!
$ igel --help
配置步骤
第一步是提供一个 yaml 文件(如果你愿意,也可以使用 json)
你可以手动创建一个 .yaml 文件(惯例上称为 igel.yaml,但你也可以命名为你想要的任何名称)并自行编辑它。然而,如果你很懒(你很可能像我一样),你可以使用 igel init 命令快速开始,它会为你即时创建一个基本的配置文件。
"""
igel init --help
Example:
If I want to use neural networks to classify whether someone is sick or not using the indian-diabetes dataset,
then I would use this command to initialize a yaml file n.b. you may need to rename outcome column in .csv to sick:
$ igel init -type "classification" -model "NeuralNetwork" -target "sick"
"""
$ igel init
运行命令后,将在当前工作目录中为你创建一个 igel.yaml 文件。你可以检查它并修改它,如果你想要的话,否则你也可以从头开始创建一切。
演示
# model definition
model:
# in the type field, you can write the type of problem you want to solve. Whether regression, classification or clustering
# Then, provide the algorithm you want to use on the data. Here I'm using the random forest algorithm
type: classification
algorithm: RandomForest # make sure you write the name of the algorithm in pascal case
arguments:
n_estimators: 100 # here, I set the number of estimators (or trees) to 100
max_depth: 30 # set the max_depth of the tree
# target you want to predict
# Here, as an example, I'm using the famous indians-diabetes dataset, where I want to predict whether someone have diabetes or not.
# Depending on your data, you need to provide the target(s) you want to predict here
target:
- sick
在上面的例子中,我使用了随机森林来根据数据集中的一些特征来分类某人是否有糖尿病。在这个例子中,我使用了著名的印度糖尿病数据集indian-diabetes dataset。
请注意,我将n_estimators
和max_depth
作为额外的参数传递给模型。如果您不提供参数,则将使用默认值。您不必记住每个模型的参数。您可以在终端中始终运行igel models
,这将进入交互模式,您将被提示输入要使用的模型和要解决的问题类型。Igel将随后显示有关模型的信息以及一个链接,您可以点击该链接查看可用参数的列表及其用法。
训练
使用igel的预期方式是从终端(igel CLI)。
在终端中运行此命令来拟合/训练模型,其中您提供数据集的路径和yaml文件的路径。
$ igel fit --data_path 'path_to_your_csv_dataset.csv' --yaml_path 'path_to_your_yaml_file.yaml'
# or shorter
$ igel fit -dp 'path_to_your_csv_dataset.csv' -yml 'path_to_your_yaml_file.yaml'
"""
That's it. Your "trained" model can be now found in the model_results folder
(automatically created for you in your current working directory).
Furthermore, a description can be found in the description.json file inside the model_results folder.
"""
演示
评估
然后,您可以评估训练/预拟合的模型。
$ igel evaluate -dp 'path_to_your_evaluation_dataset.csv'
"""
This will automatically generate an evaluation.json file in the current directory, where all evaluation results are stored
"""
演示
预测
最后,如果您对评估结果满意,可以使用训练/预拟合的模型进行预测。
$ igel predict -dp 'path_to_your_test_dataset.csv'
"""
This will generate a predictions.csv file in your current directory, where all predictions are stored in a csv file
"""
演示
实验
您可以使用一个称为experiment的单个命令来组合训练、评估和预测阶段。
$ igel experiment -DP "path_to_train_data path_to_eval_data path_to_test_data" -yml "path_to_yaml_file"
"""
This will run fit using train_data, evaluate using eval_data and further generate predictions using the test_data
"""
演示
从Python中使用igel(而不是终端)
或者,如果您愿意,也可以编写代码。
from igel import Igel
Igel(cmd="fit", data_path="path_to_your_dataset", yaml_path="path_to_your_yaml_file")
"""
check the examples folder for more
"""
提供模型服务
下一步是将您的模型用于生产。Igel也通过提供serve命令来帮助您完成这项任务。运行serve命令将告诉igel提供您的模型。确切地说,igel将自动构建一个REST服务器并在指定的主机和端口上提供您的模型。您可以通过传递这些作为CLI选项来配置这些。
最简单的方法是运行
$ igel serve --model_results_dir "path_to_model_results_directory"
请注意,igel需要–model_results_dir
或简称为-res_dir CLI选项来加载模型并启动服务器。默认情况下,igel将在localhost:8000
上提供您的模型,但是您可以通过提供主机和端口的CLI选项轻松覆盖此设置。
$ igel serve --model_results_dir "path_to_model_results_directory" --host "127.0.0.1" --port 8000
从Python中使用igel(而不是终端)
或者,如果您愿意,也可以编写代码。
from igel import Igel
Igel(cmd="fit", data_path="path_to_your_dataset", yaml_path="path_to_your_yaml_file")
"""
check the examples folder for more
"""
概述
Igel的主要目标是提供一种方法,让您能够不编写代码即可训练/拟合、评估和使用模型。相反,您只需要在简单的yaml文件中提供/描述您想做的事情。
基本上,您在yaml文件中提供描述或更准确地说,提供配置作为键值对。以下是所有支持配置的概述(目前)。
# dataset operations
dataset:
type: csv # [str] -> type of your dataset
read_data_options: # options you want to supply for reading your data (See the detailed overview about this in the next section)
sep: # [str] -> Delimiter to use.
delimiter: # [str] -> Alias for sep.
header: # [int, list of int] -> Row number(s) to use as the column names, and the start of the data.
names: # [list] -> List of column names to use
index_col: # [int, str, list of int, list of str, False] -> Column(s) to use as the row labels of the DataFrame,
usecols: # [list, callable] -> Return a subset of the columns
squeeze: # [bool] -> If the parsed data only contains one column then return a Series.
prefix: # [str] -> Prefix to add to column numbers when no header, e.g. ‘X’ for X0, X1, …
mangle_dupe_cols: # [bool] -> Duplicate columns will be specified as ‘X’, ‘X.1’, …’X.N’, rather than ‘X’…’X’. Passing in False will cause data to be overwritten if there are duplicate names in the columns.
dtype: # [Type name, dict maping column name to type] -> Data type for data or columns
engine: # [str] -> Parser engine to use. The C engine is faster while the python engine is currently more feature-complete.
converters: # [dict] -> Dict of functions for converting values in certain columns. Keys can either be integers or column labels.
true_values: # [list] -> Values to consider as True.
false_values: # [list] -> Values to consider as False.
skipinitialspace: # [bool] -> Skip spaces after delimiter.
skiprows: # [list-like] -> Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file.
skipfooter: # [int] -> Number of lines at bottom of file to skip
nrows: # [int] -> Number of rows of file to read. Useful for reading pieces of large files.
na_values: # [scalar, str, list, dict] -> Additional strings to recognize as NA/NaN.
keep_default_na: # [bool] -> Whether or not to include the default NaN values when parsing the data.
na_filter: # [bool] -> Detect missing value markers (empty strings and the value of na_values). In data without any NAs, passing na_filter=False can improve the performance of reading a large file.
verbose: # [bool] -> Indicate number of NA values placed in non-numeric columns.
skip_blank_lines: # [bool] -> If True, skip over blank lines rather than interpreting as NaN values.
parse_dates: # [bool, list of int, list of str, list of lists, dict] -> try parsing the dates
infer_datetime_format: # [bool] -> If True and parse_dates is enabled, pandas will attempt to infer the format of the datetime strings in the columns, and if it can be inferred, switch to a faster method of parsing them.
keep_date_col: # [bool] -> If True and parse_dates specifies combining multiple columns then keep the original columns.
dayfirst: # [bool] -> DD/MM format dates, international and European format.
cache_dates: # [bool] -> If True, use a cache of unique, converted dates to apply the datetime conversion.
thousands: # [str] -> the thousands operator
decimal: # [str] -> Character to recognize as decimal point (e.g. use ‘,’ for European data).
lineterminator: # [str] -> Character to break file into lines.
escapechar: # [str] -> One-character string used to escape other characters.
comment: # [str] -> Indicates remainder of line should not be parsed. If found at the beginning of a line, the line will be ignored altogether. This parameter must be a single character.
encoding: # [str] -> Encoding to use for UTF when reading/writing (ex. ‘utf-8’).
dialect: # [str, csv.Dialect] -> If provided, this parameter will override values (default or not) for the following parameters: delimiter, doublequote, escapechar, skipinitialspace, quotechar, and quoting
delim_whitespace: # [bool] -> Specifies whether or not whitespace (e.g. ' ' or ' ') will be used as the sep
low_memory: # [bool] -> Internally process the file in chunks, resulting in lower memory use while parsing, but possibly mixed type inference.
memory_map: # [bool] -> If a filepath is provided for filepath_or_buffer, map the file object directly onto memory and access the data directly from there. Using this option can improve performance because there is no longer any I/O overhead.
random_numbers: # random numbers options in case you wanted to generate the same random numbers on each run
generate_reproducible: # [bool] -> set this to true to generate reproducible results
seed: # [int] -> the seed number is optional. A seed will be set up for you if you didn't provide any
split: # split options
test_size: 0.2 #[float] -> 0.2 means 20% for the test data, so 80% are automatically for training
shuffle: true # [bool] -> whether to shuffle the data before/while splitting
stratify: None # [list, None] -> If not None, data is split in a stratified fashion, using this as the class labels.
preprocess: # preprocessing options
missing_values: mean # [str] -> other possible values: [drop, median, most_frequent, constant] check the docs for more
encoding:
type: oneHotEncoding # [str] -> other possible values: [labelEncoding]
scale: # scaling options
method: standard # [str] -> standardization will scale values to have a 0 mean and 1 standard deviation | you can also try minmax
target: inputs # [str] -> scale inputs. | other possible values: [outputs, all] # if you choose all then all values in the dataset will be scaled
# model definition
model:
type: classification # [str] -> type of the problem you want to solve. | possible values: [regression, classification, clustering]
algorithm: NeuralNetwork # [str (notice the pascal case)] -> which algorithm you want to use. | type igel algorithms in the Terminal to know more
arguments: # model arguments: you can check the available arguments for each model by running igel help in your terminal
use_cv_estimator: false # [bool] -> if this is true, the CV class of the specific model will be used if it is supported
cross_validate:
cv: # [int] -> number of kfold (default 5)
n_jobs: # [signed int] -> The number of CPUs to use to do the computation (default None)
verbose: # [int] -> The verbosity level. (default 0)
hyperparameter_search:
method: grid_search # method you want to use: grid_search and random_search are supported
parameter_grid: # put your parameters grid here that you want to use, an example is provided below
param1: [val1, val2]
param2: [val1, val2]
arguments: # additional arguments you want to provide for the hyperparameter search
cv: 5 # number of folds
refit: true # whether to refit the model after the search
return_train_score: false # whether to return the train score
verbose: 0 # verbosity level
# target you want to predict
target: # list of strings: basically put here the column(s), you want to predict that exist in your csv dataset
- put the target you want to predict here
- you can assign many target if you are making a multioutput prediction
读取数据选项
以下是在yaml(或json)文件中可以提供的配置的详细概述。请注意,您可能不需要所有数据集的配置值。它们是可选的。通常,igel会自动确定如何读取您的数据集。
但是,您可以通过使用这个read_data_options部分提供额外字段来帮助它。例如,我认为其中一个有用的值是“sep”,它定义了csv数据集中的列如何分隔。通常,csv数据集是用逗号分隔的,这也是这里的默认值。然而,在您的情况下,它可能用分号分隔。
因此,您可以在read_data_options中提供此信息。只需在read_data_options下添加sep: ";"
即可。
参数 |
类型 |
解释 |
---|---|---|
sep |
str, 默认‘,’ |
要使用的分隔符。如果sep为None,C引擎无法自动检测分隔符,但Python解析引擎可以,这意味着后者将被使用,并自动通过Python内置的sniffer工具csv.Sniffer来检测分隔符。此外,长度超过1个字符且与‘s+’不同的分隔符将被解释为正则表达式,并将强制使用Python解析引擎。请注意,正则表达式分隔符容易忽略引号内的数据。正则表达式示例:‘rt’。 |
分隔符 |
默认值为None |
sep的别名。 |
header |
int, list of int, 默认‘infer’ |
用作列名和数据的起始行号的行号。默认行为是推断列名:如果没有传递名称,则行为与header=0相同,列名从文件的第一行推断出来;如果明确传递了列名,则行为与header=None相同。明确传递header=0可以替换现有名称。header可以是指定列的多索引的整数列表,例如[0,1,3]。未指定的间隔行将被跳过(例如,本例中的2将被跳过)。注意,如果skip_blank_lines=True,则此参数忽略注释行和空行,所以header=0表示数据的第一行而不是文件的第一行。 |
names |
array-like, 可选 |
要使用的列名列表。如果文件包含标题行,则应明确传递header=0以覆盖列名。此列表不允许有重复项。 |
index_col |
int, str, sequence of int / str, 或 False,默认 None |
用作DataFrame行标签的列,可以是字符串名称或列索引。如果给出int / str的序列,则使用多索引。注意:index_col=False可用于强制pandas不使用第一列作为索引,例如,当您有一个每行末尾有分隔符的格式错误的文件时。 |
usecols |
list-like或callable,可选 |
返回列的子集。如果为list-like,则所有元素必须是位置信息(即文档列的整数索引)或字符串,这些字符串对应于由用户在names中提供的或从文档标题行推断出的列名。例如,有效的usecols参数列表可以是[0, 1, 2]或['foo', 'bar', 'baz']。元素顺序被忽略,因此usecols=[0, 1]与[1, 0]相同。如果为callable,则可调用的函数将针对列名进行评估,返回评估为True的名称。一个有效的可调用参数示例是lambda x: x.upper() in ['AAA', 'BBB', 'DDD']。使用此参数会导致解析时间更快,内存使用更低。 |
squeeze |
bool,默认 False |
如果解析的数据只包含一个列,则返回一个Series。 |
prefix |
str,可选 |
如果没有标题,则在列号前添加的前缀,例如‘X’用于X0, X1, … |
mangle_dupe_cols |
bool,默认 True |
重复列将被指定为‘X’,‘X.1’,…‘X.N’,而不是‘X’…‘X’。传入False将导致在列中有重复名称时覆盖数据。 |
dtype |
{‘c’,‘python’},可选 |
要使用的解析引擎。C引擎更快,而Python引擎目前功能更完整。 |
converters |
dict,可选 |
特定列的值转换的函数字典。键可以是整数或列标签。 |
真值 |
列表,可选 |
视为真值的值。 |
假值 |
列表,可选 |
视为假值的值。 |
skipinitialspace |
bool,默认 False |
跳过分隔符后的空格。 |
skiprows |
类似列表的对象,整数或可调用对象,可选 |
要跳过的行号(0索引)或要跳过的行数(整数)位于文件开头。如果可调用,则将可调用的函数对行索引进行评估,如果行应该跳过则返回True,否则返回False。有效的可调用参数示例为lambda x: x in [0, 2]。 |
skipfooter |
整数,默认0 |
跳过文件底部的行数(不支持engine='c')。 |
nrows |
整数,可选 |
要读取的文件行数。对于读取大型文件的部分很有用。 |
na_values |
标量,字符串,类似列表的对象或字典,可选 |
作为NA/NaN识别的额外字符串。如果传递字典,则按列指定特定的NA值。默认情况下,以下值解释为NaN:'',‘#N/A’,‘#N/A N/A’,‘#NA’,‘-1.#IND’,‘-1.#QNAN’,‘-NaN’,‘-nan’,‘1.#IND’,‘1.#QNAN’,‘ |
keep_default_na |
bool,默认 True |
在解析数据时是否包括默认的NaN值。根据是否传递了na_values,行为如下:如果keep_default_na为True,并且指定了na_values,则将na_values附加到用于解析的默认NaN值。如果keep_default_na为True,并且没有指定na_values,则只使用默认的NaN值进行解析。如果keep_default_na为False,并且指定了na_values,则仅使用指定的na_values中的NaN值进行解析。如果keep_default_na为False,并且没有指定na_values,则不会解析任何字符串为NaN。注意,如果传递了na_filter为False,则忽略keep_default_na和na_values参数。 |
na_filter |
bool,默认 True |
检测缺失值标记(空字符串和na_values的值)。在没有NAs的数据中,通过传递na_filter=False可以提高读取大型文件的性能。 |
verbose |
bool,默认 False |
指示放置在非数字列中的NA值数量。 |
skip_blank_lines |
bool,默认 True |
如果为True,则跳过空白行,而不是将其解释为NaN值。 |
parse_dates |
布尔值或整数列表或名称或列表的列表或字典,默认False |
行为如下:布尔值。如果为True -> 尝试解析索引。整数列表或名称。例如,如果[1, 2, 3] -> 尝试将列1,2,3分别解析为单独的日期列。列表的列表。例如,如果[[1, 3]] -> 将列1和3组合并解析为单个日期列。字典,例如{‘foo’ : [1, 3]} -> 将列1,3解析为日期并将结果称为‘foo’。如果列或索引不能表示为日期时间的数组,例如由于无法解析的值或时区混合,则列或索引将作为对象数据类型返回未更改。 |
infer_datetime_format |
bool,默认 False |
如果为True且启用parse_dates,pandas将尝试推断列中日期字符串的格式,如果可以推断,则切换到解析它们更快的方法。在某些情况下,这可以提高解析速度5-10倍。 |
keep_date_col |
bool,默认 False |
如果为True且parse_dates指定了组合多个列,则保留原始列。 |
date_parser |
函数,可选 |
用于将字符串列序列转换为日期实例数组的函数。默认使用dateutil.parser.parser进行转换。Pandas将尝试以三种不同的方式调用date_parser,如果发生异常则跳到下一个:1)传递一个或多个数组(由parse_dates定义)作为参数;2)将parse_dates中定义的列的字符串值(按行连接)合并到一个数组中,并传递该数组;3)对每一行调用date_parser一次,使用一个或多个字符串(对应于由parse_dates定义的列)作为参数。 |
dayfirst |
bool,默认 False |
DD/MM格式的日期,国际和欧洲格式。 |
cache_dates |
bool,默认 True |
如果为True,则使用唯一转换后的日期缓存来应用日期转换。在解析重复的日期字符串时,尤其是带有时区偏移的字符串时,可能会产生显著的加速。 |
thousands |
str,可选 |
千位分隔符。 |
decimal |
str,默认‘.’ |
用于识别为小数点的字符(例如,对于欧洲数据使用‘,’)。 |
lineterminator |
str(长度1),可选 |
用于将文件拆分为行的字符。仅与C解析器有效。 |
escapechar |
str(长度1),可选 |
用于转义其他字符的单字符字符串。 |
comment |
str,可选 |
表示行剩余部分不应解析。如果在一行的开头找到,则整行都将被忽略。 |
encoding |
str,可选 |
用于读写UTF的编码(例如,‘utf-8’)。 |
dialect |
str或csv.Dialect,可选 |
如果提供,此参数将覆盖以下参数的值(默认或非默认):delimiter,doublequote,escapechar,skipinitialspace,quotechar,和quoting |
low_memory |
bool,默认 True |
在内部以块处理文件,在解析时使用较低的内存使用,但可能存在混合类型推断。为了确保没有混合类型,要么设置为False,要么使用dtype参数指定类型。请注意,整个文件将作为一个单独的DataFrame读取,不管怎样。 |
memory_map |
bool,默认 False |
将文件对象直接映射到内存中,并直接从那里访问数据。使用此选项可以提高性能,因为不再有任何I/O开销。 |
E2E示例
本节提供了完整的端到端解决方案,以证明igel
的功能。如前所述,您需要创建一个yaml配置文件。以下是一个使用决策树
算法预测某人是否患有糖尿病的端到端示例。数据集可以在examples文件夹中找到。
拟合/训练模型:
model:
type: classification
algorithm: DecisionTree
target:
- sick
$ igel fit -dp path_to_the_dataset -yml path_to_the_yaml_file
就是这样,igel现在将为您拟合模型并将其保存到当前目录的model_results文件夹中。
评估模型:
评估预拟合模型。igel将从model_results目录中加载预拟合模型并为您评估它。您只需要运行评估命令并提供评估数据的路径。
$ igel evaluate -dp path_to_the_evaluation_dataset
就是这样!igel将评估模型并将统计数据/结果存储在model_results文件夹中的evaluation.json
文件中
预测:
使用预拟合模型对新数据进行预测。这由igel自动完成,您只需要提供要用于预测的数据的路径。
$ igel predict -dp path_to_the_new_dataset
就是这样!igel将使用预拟合模型进行预测并将其保存到model_results文件夹中的predictions.csv
文件中
高级使用
您还可以通过在yaml文件中提供它们来执行一些预处理方法或其他操作。以下是一个示例,其中数据被分成80%用于训练和20%用于验证/测试。此外,在拆分时对数据进行洗牌。
此外,数据通过用平均值替换缺失值进行预处理(您也可以使用中位数、众数等)。有关更多信息,请参阅此链接
# dataset operations
dataset:
split:
test_size: 0.2
shuffle: True
stratify: default
preprocess: # preprocessing options
missing_values: mean # other possible values: [drop, median, most_frequent, constant] check the docs for more
encoding:
type: oneHotEncoding # other possible values: [labelEncoding]
scale: # scaling options
method: standard # standardization will scale values to have a 0 mean and 1 standard deviation | you can also try minmax
target: inputs # scale inputs. | other possible values: [outputs, all] # if you choose all then all values in the dataset will be scaled
# model definition
model:
type: classification
algorithm: RandomForest
arguments:
# notice that this is the available args for the random forest model. check different available args for all supported models by running igel help
n_estimators: 100
max_depth: 20
# target you want to predict
target:
- sick
然后,您可以像其他示例中那样运行igel命令来拟合模型
$ igel fit -dp path_to_the_dataset -yml path_to_the_yaml_file
评估
$ igel evaluate -dp path_to_the_evaluation_dataset
用于生产
$ igel predict -dp path_to_the_new_dataset
示例
在代码仓库的例子文件夹中,您将找到一个数据文件夹,其中存储了著名的印度糖尿病、鸢尾花数据集和Linnerud(来自sklearn)数据集。此外,每个文件夹内部还包含端到端示例,其中包含帮助您开始的脚本和yaml文件。
indian-diabetes-example文件夹包含两个示例,以帮助您入门
第一个示例是使用一个神经网络,配置存储在neural-network.yaml文件中
第二个示例是使用一个随机森林,配置存储在random-forest.yaml文件中
iris-example文件夹包含一个逻辑回归示例,对目标列进行了某些预处理(独热编码),以展示igel的功能。
此外,multioutput-example包含一个多输出回归示例。最后,cv-example包含一个使用交叉验证的Ridge分类器示例。
您还可以在该文件夹中找到交叉验证和超参数搜索示例。
建议您尝试使用示例和igel cli。但是,如果您愿意,也可以直接执行fit.py、evaluate.py和predict.py。
Auto ML示例
图像分类
首先,创建或修改一个图像数据集,这些图像根据图像标签/类别分为子文件夹。例如,如果您有狗和猫的图像,则需要2个子文件夹
文件夹0,包含猫的图像(在这里,标签0表示猫)
文件夹1,包含狗的图像(在这里,标签1表示狗)
假设这两个子文件夹包含在一个名为images的父文件夹中,只需将数据喂给igel即可
$ igel auto-train -dp ./images --task ImageClassification
igel将处理从预处理数据到优化超参数的所有事情。最后,最佳模型将存储在当前工作目录中。
文本分类
首先,创建或修改一个文本数据集,这些数据集根据文本标签/类别分为子文件夹。例如,如果您有一个正面和负面反馈的文本数据集,则需要2个子文件夹
文件夹0,包含负面反馈(在这里,标签0表示负面)
文件夹1,包含正面反馈(在这里,标签1表示正面)
假设这两个子文件夹包含在一个名为texts的父文件夹中,只需将数据喂给igel即可
$ igel auto-train -dp ./texts --task TextClassification
igel将处理从预处理数据到优化超参数的所有事情。最后,最佳模型将存储在当前工作目录中。
图形用户界面
如果您不熟悉终端,也可以运行igel UI。只需按照上面所述在您的机器上安装igel。然后在终端中运行此单条命令
$ igel gui
这将打开GUI,使用非常简单。您可以在此处查看GUI的示例以及如何使用它:https://github.com/nidhaloff/igel-ui
使用Docker运行
使用官方镜像(推荐)
您可以从Docker Hub首先提取镜像
$ docker pull nidhaloff/igel
然后使用它
$ docker run -it --rm -v $(pwd):/data nidhaloff/igel fit -yml 'your_file.yaml' -dp 'your_dataset.csv'
或者,如果您愿意,可以在本地创建自己的镜像
您可以在Docker中运行igel,首先构建镜像
$ docker build -t igel .
然后运行它,并将您的当前目录(不需要是igel目录)作为容器内的/data(工作目录)附加
$ docker run -it --rm -v $(pwd):/data igel fit -yml 'your_file.yaml' -dp 'your_dataset.csv'
链接
帮助/获取帮助
如果您遇到任何问题,请随时提出问题。此外,您可以联系作者获取更多信息/问题。
你喜欢igel吗?您可以通过以下方式帮助此项目的开发
在github和/或twitter上关注
星标github仓库
关注github仓库以获取新版本
关于这个包推文
帮助github上的其他人解决问题
创建问题和拉取请求
赞助项目
贡献
你认为这个项目有用,并想提出新想法、新功能、错误修复、扩展文档吗?
贡献始终欢迎。首先请确保阅读指导方针
许可证
MIT许可证
版权(c)2020-至今,Nidhal Baccouri
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
构建分布
igel-1.0.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d2bbdb345b8a0990e01c09036b0993eff1861447adba115a25895f1ae422d439 |
|
MD5 | fe45aa812c5f8b6e0ff119e185118e6f |
|
BLAKE2b-256 | 88b2eb055bee5110d2e5194022bcb91e573fa89183c67ce428f0e4556c6333e8 |
igel-1.0.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | aab1ee367ded22c28e6f302dc0d6e663407006870941d9caeec360c96695ee7d |
|
MD5 | ef4e0477681f0e2067e3fb9345230215 |
|
BLAKE2b-256 | b557a3f244c808bef604e1817ad7d5b53bb24ffef55c1ec921549e989e40dcbd |