Skip to content

Commit

Permalink
pylint and pybuild issue fix
Browse files Browse the repository at this point in the history
Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>
  • Loading branch information
Suresh-Nakkeran committed Jan 7, 2022
1 parent 719bb26 commit 6a421f0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/sklearnserver/custom_transformer/__init__.py
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .custom_transformer import DictToDFTransformer
from .custom_transformer import DictToDFTransformer # noqa # pylint: disable=unused-import
25 changes: 20 additions & 5 deletions python/sklearnserver/custom_transformer/custom_transformer.py
@@ -1,10 +1,25 @@
# Copyright 2021 The KServe Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pandas as pd
from sklearn.base import TransformerMixin


class DictToDFTransformer(TransformerMixin):

def transform(self, X, y = None):
return pd.DataFrame(X)
def fit(self, X, y = None):
return self
def transform(self, X, y = None):
return pd.DataFrame(X)

def fit(self, X, y = None):
return self
3 changes: 2 additions & 1 deletion python/sklearnserver/setup.py
Expand Up @@ -34,7 +34,8 @@
install_requires=[
"kserve>=0.7.0",
"scikit-learn == 1.0.1",
"joblib >= 0.13.0"
"joblib >= 0.13.0",
"pandas >= 1.3.5"
],
tests_require=tests_require,
extras_require={'test': tests_require}
Expand Down
4 changes: 3 additions & 1 deletion python/sklearnserver/sklearnserver/test_model.py
Expand Up @@ -63,7 +63,9 @@ def test_model_joblib():
def test_multi_datatype_model_joblib():
model = SKLearnModel("model", MULTI_DATATYPE_DIR)
model.load()
request = [{'MSZoning': 'RL', 'LotArea': 8450, 'LotShape': 'Reg', 'Utilities': 'AllPub', 'YrSold': 2008, 'Neighborhood': 'CollgCr', 'OverallQual': 7, 'YearBuilt': 2003, 'SaleType': 'WD', 'GarageArea': 548}]
request = [{'MSZoning': 'RL', 'LotArea': 8450, 'LotShape': 'Reg', 'Utilities': 'AllPub',
'YrSold': 2008, 'Neighborhood': 'CollgCr', 'OverallQual': 7, 'YearBuilt': 2003,
'SaleType': 'WD', 'GarageArea': 548}]
response = model.predict({"instances": request})
assert response["predictions"] == [12.202832815138274]

Expand Down

0 comments on commit 6a421f0

Please sign in to comment.