Posts

Showing posts with the label sklearn-pandas

New to ML trying to use SVM and SVR for 1st time some syntax/transposition errors

Image
Clash Royale CLAN TAG #URR8PPP New to ML trying to use SVM and SVR for 1st time some syntax/transposition errors I am trying to run A SVR on some data I got from yahoo finance. I want to use closing prices of Ethereum to predict next 10-15 days path using a supervised learning method. I have already done autoregressive model (ARIMA) but now I want to try ML techniques like pattern recognition so I start with SVR I am simply running into a problem that I dont know how to convert my data column into a row so that the SVR works...I thought it would be simple but I am new to coding overall...appreciate your help; see below: ''' building a simple model for using machine learning to do pattern recog on stock prices''' import pandas as pd import matplotlib.pyplot as plt import matplotlib.pylab as ply import numpy as np from pandas import DataFrame as df from sklearn.svm import SVR df = pd.read_csv("C:LearningETH.csv", index_col='Date', parse_dates=Tru...

Sklearn method in class

Sklearn method in class I would like to create a class that uses sklearn transformation methods. I found this article and I am using it as an example. sklearn from sklearn import preprocessing from sklearn.base import TransformerMixin def minmax(dataframe): minmax_transformer = preprocessing.MinMaxScaler() return minmax_tranformer class FunctionFeaturizer(TransformerMixin): def __init__(self, scaler): self.scaler = scaler def fit(self, X, y=None): return self def transform(self, X): fv = self.scaler(X) return fv if __name__=="__main__": scaling = FunctionFeaturizer(minmax) df = pd.DataFrame({'feature': np.arange(10)}) df_scaled = scaling.fit(df).transform(df) print(df_scaled) The output is StandardScaler(copy=True, with_mean=True, with_std=True) which is actually the result of the preprocessing.StandardScaler().fit(df) if I use it out of the class. StandardScaler(copy=True, with_mean=True, wit...