Skip to content

Commit 8d3a72d

Browse files
authored
CrossValidator: Proofreading the documentation (#220)
1 parent 348d489 commit 8d3a72d

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 16.10.3
4+
- CrossValidator:
5+
- Proofreading the documentation
6+
37
## 16.10.2
48
- KDTree:
59
- Corrected usage example

lib/src/model_selection/cross_validator/cross_validator.dart

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ import 'package:ml_algo/src/model_selection/split_indices_provider/split_indices
99
import 'package:ml_dataframe/ml_dataframe.dart';
1010
import 'package:ml_linalg/linalg.dart';
1111

12-
typedef PredictorFactory = Assessable Function(DataFrame observations);
12+
typedef ModelFactory = Assessable Function(DataFrame observations);
1313

1414
typedef DataPreprocessFn = List<DataFrame> Function(
1515
DataFrame trainData, DataFrame testData);
1616

1717
/// A factory and an interface for all the cross validator types
1818
abstract class CrossValidator {
19-
/// Creates k-fold validator to evaluate quality of a predictor.
19+
/// Creates a k-fold validator to evaluate the quality of a ML model.
2020
///
21-
/// It splits a dataset into [numberOfFolds] test sets and subsequently
22-
/// evaluates given predictor on each produced test set
21+
/// It splits a dataset into [numberOfFolds] test sets and evaluates a model
22+
/// on each produced test set
2323
///
2424
/// Parameters:
2525
///
26-
/// [samples] A dataset to be split into parts to iteratively evaluate given
27-
/// predictor's performance
26+
/// [samples] A dataset that is going to be split into [numberOfFolds] parts
27+
/// to iteratively evaluate on them a model's performance
2828
///
29-
/// [numberOfFolds] Number of splits of the [samples]
29+
/// [numberOfFolds] A number of parts of the [samples]
3030
///
31-
/// [dtype] A type for all the numerical data
31+
/// [dtype] A type for all numerical data
3232
factory CrossValidator.kFold(
3333
DataFrame samples, {
3434
int numberOfFolds = 5,
@@ -49,17 +49,17 @@ abstract class CrossValidator {
4949
);
5050
}
5151

52-
/// Creates LPO validator to evaluate performance of a predictor.
52+
/// Creates a LPO validator to evaluate the quality of a ML model.
5353
///
54-
/// It splits a dataset into all possible test sets of size [p] and
55-
/// subsequently evaluates quality of the predictor on each produced test set.
54+
/// It splits a dataset into all possible test sets of size [p] and evaluates
55+
/// the quality of a model on each produced test set.
5656
///
5757
/// Parameters:
5858
///
59-
/// [samples] A dataset to be split into parts to iteratively
60-
/// evaluate given predictor's performance
59+
/// [samples] A dataset that is going to be split into parts to iteratively
60+
/// evaluate on them a model's performance
6161
///
62-
/// [p] Size of a split of [samples].
62+
/// [p] A size of a part of [samples] in rows.
6363
///
6464
/// [dtype] A type for all the numerical data.
6565
factory CrossValidator.lpo(
@@ -81,29 +81,27 @@ abstract class CrossValidator {
8181
);
8282
}
8383

84-
/// Returns a future resolving with a vector of scores of quality of passed
85-
/// predictor depending on given [metricType]
84+
/// Returns a future that is resolved with a vector of scores of quality of a
85+
/// model depending on given [metricType]
8686
///
8787
/// Parameters:
8888
///
89-
/// [predictorFactory] A factory function that returns an evaluating predictor
89+
/// [createModel] A function that returns a model to be evaluated
9090
///
91-
/// [metricType] Metric using to assess a predictor creating by
92-
/// [predictorFactory]
91+
/// [metricType] A metric used to assess a model created by [createModel]
9392
///
9493
/// [onDataSplit] A callback that is called when a new train-test split is
95-
/// ready to be passed into evaluating predictor. One may place some
96-
/// additional data-dependent logic here, e.g., data preprocessing. The
97-
/// callback accepts train and test data from a new split and returns
98-
/// transformed split as list, where the first element is train data and
99-
/// the second one - test data, both of [DataFrame] type. This new transformed
100-
/// split will be passed into the predictor.
94+
/// ready to be passed into a model. One may place some additional
95+
/// data-dependent logic here, e.g., data preprocessing. The callback accepts
96+
/// train and test data from a new split and returns a transformed split as a
97+
/// list, where the first element is train data and the second one is test
98+
/// data, both of [DataFrame] type. This new transformed split will be passed
99+
/// into the model
101100
///
102101
/// Example:
103102
///
104103
/// ````dart
105-
/// final data = DataFrame(
106-
/// <Iterable<num>>[
104+
/// final data = DataFrame([
107105
/// [ 1, 1, 1, 1],
108106
/// [ 2, 3, 4, 5],
109107
/// [18, 71, 15, 61],
@@ -113,7 +111,7 @@ abstract class CrossValidator {
113111
/// header: header,
114112
/// headerExists: false,
115113
/// );
116-
/// final predictorFactory = (trainData) =>
114+
/// final modelFactory = (trainData) =>
117115
/// KnnRegressor(trainData, 'col_3', k: 4);
118116
/// final onDataSplit = (trainData, testData) {
119117
/// final standardizer = Standardizer(trainData);
@@ -124,7 +122,7 @@ abstract class CrossValidator {
124122
/// }
125123
/// final validator = CrossValidator.kFold(data);
126124
/// final scores = await validator.evaluate(
127-
/// predictorFactory,
125+
/// modelFactory,
128126
/// MetricType.mape,
129127
/// onDataSplit: onDataSplit,
130128
/// );
@@ -133,7 +131,7 @@ abstract class CrossValidator {
133131
/// print(averageScore);
134132
/// ````
135133
Future<Vector> evaluate(
136-
PredictorFactory predictorFactory,
134+
ModelFactory createModel,
137135
MetricType metricType, {
138136
DataPreprocessFn? onDataSplit,
139137
});

lib/src/model_selection/cross_validator/cross_validator_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CrossValidatorImpl implements CrossValidator {
2222

2323
@override
2424
Future<Vector> evaluate(
25-
PredictorFactory predictorFactory,
25+
ModelFactory predictorFactory,
2626
MetricType metricType, {
2727
DataPreprocessFn? onDataSplit,
2828
}) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ml_algo
22
description: Machine learning algorithms, Machine learning models performance evaluation functionality
3-
version: 16.10.2
3+
version: 16.10.3
44
homepage: https://github.com/gyrdym/ml_algo
55

66
environment:

0 commit comments

Comments
 (0)