1 # ===============LICENSE_START=======================================================
3 # ===================================================================================
4 # Copyright (C) 2017-2018 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
5 # ===================================================================================
6 # This Acumos software file is distributed by AT&T and Tech Mahindra
7 # under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # This file 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','/Users/guy/Desktop')