You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A class that performs linear multiclass classification of data. To use this kind of classifier your data has to be
@@ -100,7 +104,7 @@ in your dependencies:
100
104
101
105
````
102
106
dependencies:
103
-
ml_dataframe: ^1.4.2
107
+
ml_dataframe: ^1.5.0
104
108
ml_preprocessing: ^7.0.2
105
109
````
106
110
@@ -125,11 +129,8 @@ We have 2 options here:
125
129
126
130
- Download the dataset from [Pima Indians Diabetes Database](https://www.kaggle.com/uciml/pima-indians-diabetes-database).
127
131
128
-
- Or we may simply use [getPimaIndiansDiabetesDataFrame](https://pub.dev/documentation/ml_dataframe/latest/ml_dataframe/getPimaIndiansDiabetesDataFrame.html) function
129
-
from [ml_dataframe](https://pub.dev/packages/ml_dataframe) package. The function returns a ready to use [DataFrame](https://pub.dev/documentation/ml_dataframe/latest/ml_dataframe/DataFrame-class.html) instance
130
-
filled with `Pima Indians Diabetes Database` data.
131
-
132
-
If we chose the first option, we should do the following:
132
+
<details>
133
+
<summary>Instructions</summary>
133
134
134
135
#### For a desktop application:
135
136
@@ -142,18 +143,7 @@ final samples = await fromCsv('datasets/pima_indians_diabetes_database.csv');
142
143
143
144
#### For a flutter application:
144
145
145
-
Be sure that you have ml_dataframe package version at least 1.0.0 and ml_algo package version at least 16.0.0
146
-
in your pubspec.yaml:
147
-
148
-
````
149
-
dependencies:
150
-
...
151
-
ml_algo: ^16.11.2
152
-
ml_dataframe: ^1.4.2
153
-
...
154
-
````
155
-
156
-
Then it's needed to add the dataset to the flutter assets by adding the following config in the pubspec.yaml:
146
+
It's needed to add the dataset to the flutter assets by adding the following config in the pubspec.yaml:
157
147
158
148
````
159
149
flutter:
@@ -168,10 +158,30 @@ can access the dataset:
168
158
import 'package:flutter/services.dart' show rootBundle;
169
159
import 'package:ml_dataframe/ml_dataframe.dart';
170
160
171
-
final rawCsvContent = await rootBundle.loadString('assets/datasets/pima_indians_diabetes_database.csv');
172
-
final samples = DataFrame.fromRawCsv(rawCsvContent);
161
+
void main() async {
162
+
final rawCsvContent = await rootBundle.loadString('assets/datasets/pima_indians_diabetes_database.csv');
163
+
final samples = DataFrame.fromRawCsv(rawCsvContent);
164
+
}
165
+
```
166
+
</details>
167
+
168
+
- Or we may simply use [getPimaIndiansDiabetesDataFrame](https://pub.dev/documentation/ml_dataframe/latest/ml_dataframe/getPimaIndiansDiabetesDataFrame.html) function
169
+
from [ml_dataframe](https://pub.dev/packages/ml_dataframe) package. The function returns a ready to use [DataFrame](https://pub.dev/documentation/ml_dataframe/latest/ml_dataframe/DataFrame-class.html) instance
170
+
filled with `Pima Indians Diabetes Database` data.
171
+
172
+
<details>
173
+
<summary>Instructions</summary>
174
+
175
+
```dart
176
+
import 'package:ml_dataframe/ml_dataframe.dart';
177
+
178
+
void main() {
179
+
final samples = getPimaIndiansDiabetesDataFrame();
180
+
}
173
181
```
174
182
183
+
</details>
184
+
175
185
### Prepare datasets for training and testing
176
186
177
187
Data in this file is represented by 768 records and 8 features. The 9th column is a label column, it contains either 0 or 1
@@ -475,7 +485,7 @@ final targetName = 'col_13';
475
485
then let's shuffle the data:
476
486
477
487
```dart
478
-
samples.shuffle();
488
+
final shuffledSamples = samples.shuffle();
479
489
```
480
490
481
491
Now it's the time to prepare data splits. Let's split the data into train and test subsets using the library's [splitData](https://github.com/gyrdym/ml_algo/blob/master/lib/src/model_selection/split_data.dart)
@@ -501,7 +511,7 @@ e.g. stochastic gradient descent algorithm:
501
511
502
512
```dart
503
513
final model = LinearRegressor.SGD(
504
-
samples
514
+
shuffledSamples
505
515
targetName,
506
516
iterationLimit: 90,
507
517
);
@@ -511,7 +521,7 @@ or linear regression based on coordinate descent with Lasso regularization:
511
521
512
522
```dart
513
523
final model = LinearRegressor.lasso(
514
-
samples
524
+
shuffledSamples,
515
525
targetName,
516
526
iterationLimit: 90,
517
527
);
@@ -538,14 +548,16 @@ import 'dart:io';
538
548
import 'package:ml_algo/ml_algo.dart';
539
549
import 'package:ml_dataframe/ml_dataframe.dart';
540
550
541
-
final file = File('housing_model.json');
542
-
final encodedModel = await file.readAsString();
543
-
final model = LinearRegressor.fromJson(encodedModel);
544
-
final unlabelledData = await fromCsv('some_unlabelled_data.csv');
545
-
final prediction = model.predict(unlabelledData);
546
-
547
-
print(prediction.header);
548
-
print(prediction.rows);
551
+
void main() async {
552
+
final file = File('housing_model.json');
553
+
final encodedModel = await file.readAsString();
554
+
final model = LinearRegressor.fromJson(encodedModel);
555
+
final unlabelledData = await fromCsv('some_unlabelled_data.csv');
0 commit comments