Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴

Karthik Viswanathan nickinack

🌴
View GitHub Profile
View f2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View f3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View f4.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View f5.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View f6.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View f11.py
class FeatureSolver(AbstractSolver):
def __init__(
self,
problem_type=float,
fitness_func= lambda a : fitness_func(a),
pop_cnt: int = 40,
gene_size: int = 50,
max_gen: int = 2,
mutation_ratio: float = 0.2,
selection_ratio: float = 0.2,
View f12.py
def fitness_func(chromosome):
columns = []
for i in range(len(x_train.columns)):
if i in chromosome:
columns.append(x_train.columns[i])
dist.append(columns)
training_set = x_train[columns]
print(training_set)
test_set = x_test[columns]
lg = LinearRegression().fit(training_set.values, y_train.values)
View f13.py
x = df1.drop("ViolentCrimesPerPop", axis=1)
y = df1["ViolentCrimesPerPop"]
x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=0.8, random_state=24)
print(x_train.shape , y_train.shape)
print(x_test.shape , y_test.shape)
View f14.py
def drop_columns(columns , df):
'''
Given dataframe , returns updated df with removed colums
'''
for i in columns:
df = df.drop(i , axis=1)
return df
drop_list = ['state' , 'county' , 'community' , 'communityname' , 'fold' ]
View f15.py
df1 = pd.read_csv("communities.data" , header=None)
def read_header(filename):
'''
Given a filename containing headers, extract the headers and assign it to df
'''
header_list = []
with open(filename) as f:
for line in f:
if "@attribute" in line: