Spaces:
Runtime error
Runtime error
File size: 1,415 Bytes
14db87c |
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 |
import pandas as pd
import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.impute import SimpleImputer
import re
from sklearn.preprocessing import StandardScaler
class PrepProcesor(BaseEstimator, TransformerMixin):
def fit(self, X, y=None):
self.ageImputer = SimpleImputer()
self.ageImputer.fit(X[['Locked_period']])
return self
def transform(self, X, y=None):
X['Locked_period'] = self.ageImputer.transform(X[['Locked_period']])
# X['CabinClass'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^a-zA-Z]', '', x))
# X['CabinNumber'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^0-9]', '', x)).replace('', 0)
# X['Embarked'] = X['Embarked'].fillna('M')
X = StandardScaler.fit_transform(X)
#X = X.drop(['PassengerId', 'Name', 'Ticket','Cabin'], axis=1)
return X
columns = ['Wallet_distribution', 'Whale_anomalie_activities', 'Locked_period', 'Operation_duration', 'PR_articles', 'Decentralized_transaction','twitter_followers_growthrate','unique_address_growthrate', 'month_transaction_growthrate','github_update', 'code_review_report', 'publicChain_safety' , 'investedProjects','token_price', 'token_voltality_overDot', 'negative', 'neutre', 'positive', 'KOL_comments', 'media_negatifReport']
|