sklearn-pandas

difference between LinearRegression and svm.SVR(kernel=“linear”)

旧巷老猫 提交于 2019-12-04 08:18:16
First there are questions on this forum very similar to this one but trust me none matches so no duplicating please. I have encountered two methods of linear regression using scikit's sklearn and I am failing to understand the difference between the two, especially where in first code there's a method train_test_split() called while in the other one directly fit method is called. I am studying with multiple resources and this single issue is very confusing to me. First which uses SVR X = np.array(df.drop(['label'], 1)) X = preprocessing.scale(X) y = np.array(df['label']) X_train, X_test, y

Multivariate/Multiple Linear Regression in Scikit Learn?

谁都会走 提交于 2019-12-04 07:55:30
问题 I have a dataset (dataTrain.csv & dataTest.csv) in .csv file with this format: Temperature(K),Pressure(ATM),CompressibilityFactor(Z) 273.1,24.675,0.806677258 313.1,24.675,0.888394713 ...,...,... And able to build a regression model and prediction with this code: import pandas as pd from sklearn import linear_model dataTrain = pd.read_csv("dataTrain.csv") dataTest = pd.read_csv("dataTest.csv") # print df.head() x_train = dataTrain['Temperature(K)'].reshape(-1,1) y_train = dataTrain[

How to run non-linear regression in python

ⅰ亾dé卋堺 提交于 2019-12-04 05:50:15
i am having the following information(dataframe) in python product baskets scaling_factor 12345 475 95.5 12345 108 57.7 12345 2 1.4 12345 38 21.9 12345 320 88.8 and I want to run the following non-linear regression and estimate the parameters. a ,b and c Equation that i want to fit: scaling_factor = a - (b*np.exp(c*baskets)) In sas we usually run the following model:(uses gauss newton method ) proc nlin data=scaling_factors; parms a=100 b=100 c=-0.09; model scaling_factor = a - (b * (exp(c*baskets))); output out=scaling_equation_parms parms=a b c; is there a similar way to estimate the

How to perform OneHotEncoding in Sklearn, getting value error

前提是你 提交于 2019-12-03 21:54:18
I just started learning machine learning, when practicing one of the task, I am getting value error, but I followed the same steps as the instructor does. I am getting value error, please help. dff Country Name 0 AUS Sri 1 USA Vignesh 2 IND Pechi 3 USA Raj First I performed labelencoding, X=dff.values label_encoder=LabelEncoder() X[:,0]=label_encoder.fit_transform(X[:,0]) out: X array([[0, 'Sri'], [2, 'Vignesh'], [1, 'Pechi'], [2, 'Raj']], dtype=object) then performed One hot encoding for the same X onehotencoder=OneHotEncoder( categorical_features=[0]) X=onehotencoder.fit_transform(X).toarray

Loading sklearn model in Java. Model created with DNNClassifier in python

一笑奈何 提交于 2019-12-03 15:15:40
The goal is to open in Java a model created/trained in python with tensorflow.contrib.learn.learn.DNNClassifier . At the moment the main issue is to know the name of the "tensor" to give in java on the session runner method. I have this test code in python : from __future__ import division, print_function, absolute_import import tensorflow as tf import pandas as pd import tensorflow.contrib.learn as learn import numpy as np from sklearn import metrics from sklearn.cross_validation import train_test_split from tensorflow.contrib import layers from tensorflow.contrib.learn.python.learn.utils

Scikit K-means clustering performance measure

孤人 提交于 2019-12-03 06:28:48
I'm trying to do a clustering with K-means method but I would like to measure the performance of my clustering. I'm not an expert but I am eager to learn more about clustering. Here is my code : import pandas as pd from sklearn import datasets #loading the dataset iris = datasets.load_iris() df = pd.DataFrame(iris.data) #K-Means from sklearn import cluster k_means = cluster.KMeans(n_clusters=3) k_means.fit(df) #K-means training y_pred = k_means.predict(df) #We store the K-means results in a dataframe pred = pd.DataFrame(y_pred) pred.columns = ['Species'] #we merge this dataframe with df

Is there a way to import a pmml file into python?

点点圈 提交于 2019-12-02 08:53:31
问题 I have trained a model using sklearn and exported it into a pmml format using sklearn2pmml. Is there a way to convert that pmml file back into something that can be imported and run in python? The reason I am looking to do this is because I have noticed slight differences in the way the pmml model behaves compared to the sklearn model. Specifically, the pmml file sets hard upper and lower bounds for variables (uses the max and min of the variable in the training set) whereas sklearn does not.

ValueError: Cannot have number of splits n_splits=3 greater than the number of samples: 1

喜你入骨 提交于 2019-12-02 08:00:35
I am trying this training modeling using train_test_split and a decision tree regressor: import sklearn from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeRegressor from sklearn.model_selection import cross_val_score # TODO: Make a copy of the DataFrame, using the 'drop' function to drop the given feature new_data = samples.drop('Fresh', 1) # TODO: Split the data into training and testing sets using the given feature as the target X_train, X_test, y_train, y_test = train_test_split(new_data, samples['Fresh'], test_size=0.25, random_state=0) # TODO: Create

Coverting Back One Hot Encoded Results back to single Column in Python

半城伤御伤魂 提交于 2019-12-02 03:09:16
问题 I was doing Multi-class Classification using Keras.It contained 5 classes of Output. I converted the single class vector to matrix using one hot encoding and made a model. Now to evaluate the model I want to convert back the 5 class probabilistic result back to Single Column. I am getting this as output in numpy array format ..................0..................1............................2.......................3.............................4 5.35433665e-02 1.72592481e-05 1.49291719e-03 9

Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found

China☆狼群 提交于 2019-12-01 17:52:33
I tried to do the following importations for a machine learning project: from sklearn import preprocessing, cross_validation, svm from sklearn.linear_model import LinearRegression I got this error message: Traceback (most recent call last): File "C:/Users/Abdelhalim/PycharmProjects/ML/stock pricing.py", line 4, in <module> from sklearn import preprocessing, cross_validation, svm File "C:\Python27\lib\site-packages\sklearn\__init__.py", line 57, in <module> from .base import clone File "C:\Python27\lib\site-packages\sklearn\base.py", line 12, in <module> from .utils.fixes import signature File