cure depression and regression
This commit is contained in:
@@ -1,12 +1,40 @@
|
|||||||
# Regression/Prediction (Totally gonna do later trust bro)
|
# Regression/Prediction (Totally gonna do later trust bro)
|
||||||
|
from sklearn.linear_model import LinearRegression
|
||||||
|
|
||||||
from sklearn.impute import SimpleImputer
|
from sklearn.impute import SimpleImputer
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
# Column2 is the column you're grouping by using the given values pls
|
def cure_depression(dataset):
|
||||||
def cure_depression(dataset, column, column2, values):
|
# this is pog
|
||||||
# Allegedly for loop here )
|
numeric = dataset.select_dtypes(include=np.number)
|
||||||
dataset[column].fillna(dataset[column].mean(), inplace=True)
|
numeric_columns = numeric.columns
|
||||||
# print(dataset)
|
dataset[numeric_columns] = dataset[numeric_columns].interpolate(
|
||||||
return dataset[column].to_list()
|
method="linear", limit_direct="forward"
|
||||||
|
)
|
||||||
|
# fuck around and find out with other methods maybe idk
|
||||||
|
return dataset
|
||||||
|
|
||||||
|
|
||||||
|
def regression_expression(dataset, column, missing_value):
|
||||||
|
lr = LinearRegression()
|
||||||
|
numeric = dataset.select_dtypes(include=np.number)
|
||||||
|
# Migrate this to digger
|
||||||
|
# the fookin nulls
|
||||||
|
testdf = numeric[numeric[column].isnull() == False]
|
||||||
|
testdf = testdf[testdf[column] != 0]
|
||||||
|
# the non nulls and non 0s
|
||||||
|
traindf = numeric[numeric[column].isnull() == False]
|
||||||
|
traindf = traindf[traindf[column] != 0]
|
||||||
|
# print(traindf.head(20))
|
||||||
|
# end of migration
|
||||||
|
|
||||||
|
y = traindf[column]
|
||||||
|
traindf.drop(column, axis=1, inplace=True)
|
||||||
|
lr.fit(traindf, y)
|
||||||
|
testdf.drop(column, axis=1, inplace=True)
|
||||||
|
pred = lr.predict(testdf)
|
||||||
|
# can't put this in data set directly because length no match
|
||||||
|
# join testdf and traindf to form dataset perhaps??
|
||||||
|
testdf[column] = pred
|
||||||
|
print(testdf.head(30))
|
||||||
|
|||||||
Reference in New Issue
Block a user