Skip to content

Commit

Permalink
changed python file in server
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelaya775 committed Apr 4, 2022
1 parent 8c50980 commit 4199bb3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 40 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function ImgMediaCard() {
</Typography>
</CardContent>
<CardActions>
<Button size="small">Share</Button>
<Button size="small">Connect</Button>
<Button size="small">Learn More</Button>
</CardActions>
</Card>
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/Pair.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import Card from '../components/Card'
import { Button } from '@mui/material'

export default function Pair() {
return (
<div className='container w-fit mx-auto flex flex-wrap gap-6'>
<div className='container mx-auto p-10 flex flex-between flex-wrap gap-6'>
<Card />
<Card />
<Card />
Expand Down
47 changes: 23 additions & 24 deletions python/interest-classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,70 @@


#import libraries
from sklearn import metrics
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import pandas as pd
import sklearn


# In[10]:


#PULL DATA
# PULL DATA

#pull class list
# pull class list

#for now
# for now
careerFieldList = ['consulting', 'biotech', 'fintech']

#pull dataset
# pull dataset

#for now
# for now


# In[11]:


#format dataset
# format dataset

#make headers
# make headers
headers = ['userID']
for careerField in careerFieldList:
headers.append(careerField + '-explicit')
headers.append(careerField + '-implicit')
#read csv
#for now

# read csv
# for now

dataset = pd.read_csv("data.csv")
dataset.head(20)

#TODO
# TODO


# In[12]:


#get values
# get values
x = dataset.iloc[:, 1:-1].values
y = dataset.iloc[:, -1].values


# In[13]:


#train/test split
from sklearn.model_selection import train_test_split
# train/test split
xTrain, xTest, yTrain, yTest = train_test_split(x, y, test_size=0.1)


# In[14]:


#scale values
from sklearn.preprocessing import StandardScaler
# scale values

scaler = StandardScaler()
scaler.fit(x)
Expand All @@ -76,8 +78,7 @@
# In[15]:


#fit model
from sklearn.neighbors import KNeighborsClassifier
# fit model

classifier = KNeighborsClassifier(n_neighbors=5)
classifier.fit(xTrain, yTrain)
Expand All @@ -86,8 +87,7 @@
# In[16]:


#test
from sklearn import metrics
# test
predictions = classifier.predict(xTest)

print('INPUT')
Expand All @@ -107,13 +107,12 @@
# In[29]:


#manual testing
exampleInput = [[5,25,9,20,7,5]]
# manual testing
exampleInput = [[5, 25, 9, 20, 7, 5]]
singlePrediction = classifier.predict(exampleInput)
probabilities = classifier.predict_proba(exampleInput)

print('INTERESTS w/ PROBABILITIES')
classes = classifier.classes_
print(classes)
print(probabilities)

13 changes: 0 additions & 13 deletions python/process.py

This file was deleted.

2 changes: 1 addition & 1 deletion routes/api/mentees.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ router.delete('/:id', (req, res) => {
// middleware function to run python script
const runModel = (req, res, next) => {
// note: responses should be in the form of an array
const child = spawn('python', ['../../python/process.py', JSON.stringify(req.body.responses)])
const child = spawn('python', ['../../python/interest-classifier.py', JSON.stringify(req.body.responses)])

child.stdout.on('data', (data) => {
const str = data.toString().replace(/'/g, `"`)
Expand Down

0 comments on commit 4199bb3

Please sign in to comment.