-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathfeature_transform.py
More file actions
30 lines (23 loc) · 913 Bytes
/
feature_transform.py
File metadata and controls
30 lines (23 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from niaaml.preprocessing.feature_transform import Normalizer
import os
from niaaml.data import CSVDataReader
"""
This example presents how to individually use an implemented feature transform algorithm and its methods individually. In this case, we use Normalizer for demonstration, but
you can use any of the implemented feature transform algorithms in the same way.
"""
# prepare data reader using csv file
data_reader = CSVDataReader(
src=os.path.dirname(os.path.abspath(__file__)) + "/example_files/dataset.csv",
has_header=False,
contains_classes=True,
)
# instantiate Normalizer
ft = Normalizer()
# set parameters of the Normalizer
ft.set_parameters(norm="l2")
# fit the algorithm to the input data
ft.fit(data_reader.get_x())
# transform features
transformed_features = ft.transform(data_reader.get_x())
# print feature transform algorithm in a user-friendly form
print(ft.to_string())