guides/Modeling.md in eps-0.1.0 vs guides/Modeling.md in eps-0.1.1
- old
+ new
@@ -19,11 +19,12 @@
```r
library(jsonlite)
model <- lm(dist ~ speed, cars)
-toJSON(list(coefficients=as.list(coef(model))), auto_unbox=TRUE)
+data <- toJSON(list(coefficients=as.list(coef(model))), auto_unbox=TRUE)
+write(data, file="model.json")
```
## R PMML
Install the [pmml](https://cran.r-project.org/package=pmml) package
@@ -36,11 +37,12 @@
```r
library(pmml)
model <- lm(dist ~ speed, cars)
-toString(pmml(model))
+data <- toString(pmml(model))
+write(data, file="model.pmml")
```
## R PFA
Install the [aurelius](https://cran.r-project.org/package=aurelius) package
@@ -53,11 +55,11 @@
```r
library(aurelius)
model <- lm(dist ~ speed, cars)
-write_pfa(pfa(model))
+write_pfa(pfa(model), file="model.pfa")
```
## Python JSON
Run:
@@ -78,19 +80,23 @@
coefficients = {'_intercept': model.intercept_}
for i, c in enumerate(model.coef_):
coefficients[features[i]] = c
-print(json.dumps({'coefficients': coefficients}))
+
+data = json.dumps({'coefficients': coefficients})
+
+with open('model.json', 'w') as f:
+ f.write(data)
```
## Python PMML
-Install the [sklearn2pmml](https://github.com/jpmml/sklearn2pmml) package
+Install the [scikit2pmml](https://github.com/vaclavcadek/scikit2pmml) package
```sh
-pip install sklearn2pmml
+pip install scikit2pmml
```
And run:
```python
@@ -101,11 +107,11 @@
y = [5 * xi + 3 for xi in x]
model = linear_model.LinearRegression()
model.fit([[xi] for xi in x], y)
-scikit2pmml(estimator=model, file='pymodel.pmml')
+scikit2pmml(estimator=model, file='model.pmml')
```
## Python PFA
Install the [Titus](https://github.com/opendatagroup/hadrian) package and run:
@@ -137,7 +143,10 @@
pfaDocument["cells"]["regression"]["init"] = {"const": estimator.intercept_, "coeff": list(estimator.coef_)}
return pfaDocument
-json.dumps(pfa(model))
+data = json.dumps(pfa(model))
+
+with open('model.pfa', 'w') as f:
+ f.write(data)
```