1 # ========================LICENSE_START=================================
4 # Copyright (c) 2019 AT&T Intellectual Property.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ========================LICENSE_END===================================
19 from acumos.session import AcumosSession
20 from acumos.modeling import Model, List, create_dataframe
24 from sklearn.datasets import load_iris
25 from sklearn.ensemble import RandomForestClassifier
31 clf = RandomForestClassifier(random_state=0)
34 # here, an appropriate NamedTuple type is inferred from a pandas DataFrame
35 X_df = pd.DataFrame(X, columns=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'])
36 IrisDataFrame = create_dataframe('IrisDataFrame', X_df)
38 # ==================================================================================
41 # IrisDataFrame = create_namedtuple('IrisDataFrame', [('sepal_length', List[float]),
42 # ('sepal_width', List[float]),
43 # ('petal_length', List[float]),
44 # ('petal_width', List[float])])
45 # ==================================================================================
47 def classify_iris(df: IrisDataFrame) -> List[int]:
48 '''Returns an array of iris classifications'''
49 X = np.column_stack(df)
52 model = Model(classify=classify_iris)
54 session = AcumosSession()
56 session.dump(model,'iris_sklearn','/temp')